提交 e4fd72a1 编写于 作者: T Trond Myklebust

NFSv4: cleanup idmapper functions to take an nfs_server argument

...instead of the nfs_client.
Signed-off-by: NTrond Myklebust <Trond.Myklebust@netapp.com>
上级 f0b85168
...@@ -241,21 +241,21 @@ static int nfs_idmap_lookup_id(const char *name, size_t namelen, ...@@ -241,21 +241,21 @@ static int nfs_idmap_lookup_id(const char *name, size_t namelen,
return ret; return ret;
} }
int nfs_map_name_to_uid(struct nfs_client *clp, const char *name, size_t namelen, __u32 *uid) int nfs_map_name_to_uid(const struct nfs_server *server, const char *name, size_t namelen, __u32 *uid)
{ {
if (nfs_map_string_to_numeric(name, namelen, uid)) if (nfs_map_string_to_numeric(name, namelen, uid))
return 0; return 0;
return nfs_idmap_lookup_id(name, namelen, "uid", uid); return nfs_idmap_lookup_id(name, namelen, "uid", uid);
} }
int nfs_map_group_to_gid(struct nfs_client *clp, const char *name, size_t namelen, __u32 *gid) int nfs_map_group_to_gid(const struct nfs_server *server, const char *name, size_t namelen, __u32 *gid)
{ {
if (nfs_map_string_to_numeric(name, namelen, gid)) if (nfs_map_string_to_numeric(name, namelen, gid))
return 0; return 0;
return nfs_idmap_lookup_id(name, namelen, "gid", gid); return nfs_idmap_lookup_id(name, namelen, "gid", gid);
} }
int nfs_map_uid_to_name(struct nfs_client *clp, __u32 uid, char *buf, size_t buflen) int nfs_map_uid_to_name(const struct nfs_server *server, __u32 uid, char *buf, size_t buflen)
{ {
int ret; int ret;
ret = nfs_idmap_lookup_name(uid, "user", buf, buflen); ret = nfs_idmap_lookup_name(uid, "user", buf, buflen);
...@@ -263,7 +263,7 @@ int nfs_map_uid_to_name(struct nfs_client *clp, __u32 uid, char *buf, size_t buf ...@@ -263,7 +263,7 @@ int nfs_map_uid_to_name(struct nfs_client *clp, __u32 uid, char *buf, size_t buf
ret = nfs_map_numeric_to_string(uid, buf, buflen); ret = nfs_map_numeric_to_string(uid, buf, buflen);
return ret; return ret;
} }
int nfs_map_gid_to_group(struct nfs_client *clp, __u32 gid, char *buf, size_t buflen) int nfs_map_gid_to_group(const struct nfs_server *server, __u32 gid, char *buf, size_t buflen)
{ {
int ret; int ret;
...@@ -729,27 +729,27 @@ static unsigned int fnvhash32(const void *buf, size_t buflen) ...@@ -729,27 +729,27 @@ static unsigned int fnvhash32(const void *buf, size_t buflen)
return hash; return hash;
} }
int nfs_map_name_to_uid(struct nfs_client *clp, const char *name, size_t namelen, __u32 *uid) int nfs_map_name_to_uid(const struct nfs_server *server, const char *name, size_t namelen, __u32 *uid)
{ {
struct idmap *idmap = clp->cl_idmap; struct idmap *idmap = server->nfs_client->cl_idmap;
if (nfs_map_string_to_numeric(name, namelen, uid)) if (nfs_map_string_to_numeric(name, namelen, uid))
return 0; return 0;
return nfs_idmap_id(idmap, &idmap->idmap_user_hash, name, namelen, uid); return nfs_idmap_id(idmap, &idmap->idmap_user_hash, name, namelen, uid);
} }
int nfs_map_group_to_gid(struct nfs_client *clp, const char *name, size_t namelen, __u32 *uid) int nfs_map_group_to_gid(const struct nfs_server *server, const char *name, size_t namelen, __u32 *uid)
{ {
struct idmap *idmap = clp->cl_idmap; struct idmap *idmap = server->nfs_client->cl_idmap;
if (nfs_map_string_to_numeric(name, namelen, uid)) if (nfs_map_string_to_numeric(name, namelen, uid))
return 0; return 0;
return nfs_idmap_id(idmap, &idmap->idmap_group_hash, name, namelen, uid); return nfs_idmap_id(idmap, &idmap->idmap_group_hash, name, namelen, uid);
} }
int nfs_map_uid_to_name(struct nfs_client *clp, __u32 uid, char *buf, size_t buflen) int nfs_map_uid_to_name(const struct nfs_server *server, __u32 uid, char *buf, size_t buflen)
{ {
struct idmap *idmap = clp->cl_idmap; struct idmap *idmap = server->nfs_client->cl_idmap;
int ret; int ret;
ret = nfs_idmap_name(idmap, &idmap->idmap_user_hash, uid, buf); ret = nfs_idmap_name(idmap, &idmap->idmap_user_hash, uid, buf);
...@@ -757,9 +757,9 @@ int nfs_map_uid_to_name(struct nfs_client *clp, __u32 uid, char *buf, size_t buf ...@@ -757,9 +757,9 @@ int nfs_map_uid_to_name(struct nfs_client *clp, __u32 uid, char *buf, size_t buf
ret = nfs_map_numeric_to_string(uid, buf, buflen); ret = nfs_map_numeric_to_string(uid, buf, buflen);
return ret; return ret;
} }
int nfs_map_gid_to_group(struct nfs_client *clp, __u32 uid, char *buf, size_t buflen) int nfs_map_gid_to_group(const struct nfs_server *server, __u32 uid, char *buf, size_t buflen)
{ {
struct idmap *idmap = clp->cl_idmap; struct idmap *idmap = server->nfs_client->cl_idmap;
int ret; int ret;
ret = nfs_idmap_name(idmap, &idmap->idmap_group_hash, uid, buf); ret = nfs_idmap_name(idmap, &idmap->idmap_group_hash, uid, buf);
......
...@@ -844,7 +844,7 @@ static void encode_attrs(struct xdr_stream *xdr, const struct iattr *iap, const ...@@ -844,7 +844,7 @@ static void encode_attrs(struct xdr_stream *xdr, const struct iattr *iap, const
if (iap->ia_valid & ATTR_MODE) if (iap->ia_valid & ATTR_MODE)
len += 4; len += 4;
if (iap->ia_valid & ATTR_UID) { if (iap->ia_valid & ATTR_UID) {
owner_namelen = nfs_map_uid_to_name(server->nfs_client, iap->ia_uid, owner_name, IDMAP_NAMESZ); owner_namelen = nfs_map_uid_to_name(server, iap->ia_uid, owner_name, IDMAP_NAMESZ);
if (owner_namelen < 0) { if (owner_namelen < 0) {
dprintk("nfs: couldn't resolve uid %d to string\n", dprintk("nfs: couldn't resolve uid %d to string\n",
iap->ia_uid); iap->ia_uid);
...@@ -856,7 +856,7 @@ static void encode_attrs(struct xdr_stream *xdr, const struct iattr *iap, const ...@@ -856,7 +856,7 @@ static void encode_attrs(struct xdr_stream *xdr, const struct iattr *iap, const
len += 4 + (XDR_QUADLEN(owner_namelen) << 2); len += 4 + (XDR_QUADLEN(owner_namelen) << 2);
} }
if (iap->ia_valid & ATTR_GID) { if (iap->ia_valid & ATTR_GID) {
owner_grouplen = nfs_map_gid_to_group(server->nfs_client, iap->ia_gid, owner_group, IDMAP_NAMESZ); owner_grouplen = nfs_map_gid_to_group(server, iap->ia_gid, owner_group, IDMAP_NAMESZ);
if (owner_grouplen < 0) { if (owner_grouplen < 0) {
dprintk("nfs: couldn't resolve gid %d to string\n", dprintk("nfs: couldn't resolve gid %d to string\n",
iap->ia_gid); iap->ia_gid);
...@@ -3387,7 +3387,7 @@ static int decode_attr_nlink(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t ...@@ -3387,7 +3387,7 @@ static int decode_attr_nlink(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t
} }
static int decode_attr_owner(struct xdr_stream *xdr, uint32_t *bitmap, static int decode_attr_owner(struct xdr_stream *xdr, uint32_t *bitmap,
struct nfs_client *clp, uint32_t *uid, int may_sleep) const struct nfs_server *server, uint32_t *uid, int may_sleep)
{ {
uint32_t len; uint32_t len;
__be32 *p; __be32 *p;
...@@ -3407,7 +3407,7 @@ static int decode_attr_owner(struct xdr_stream *xdr, uint32_t *bitmap, ...@@ -3407,7 +3407,7 @@ static int decode_attr_owner(struct xdr_stream *xdr, uint32_t *bitmap,
if (!may_sleep) { if (!may_sleep) {
/* do nothing */ /* do nothing */
} else if (len < XDR_MAX_NETOBJ) { } else if (len < XDR_MAX_NETOBJ) {
if (nfs_map_name_to_uid(clp, (char *)p, len, uid) == 0) if (nfs_map_name_to_uid(server, (char *)p, len, uid) == 0)
ret = NFS_ATTR_FATTR_OWNER; ret = NFS_ATTR_FATTR_OWNER;
else else
dprintk("%s: nfs_map_name_to_uid failed!\n", dprintk("%s: nfs_map_name_to_uid failed!\n",
...@@ -3425,7 +3425,7 @@ static int decode_attr_owner(struct xdr_stream *xdr, uint32_t *bitmap, ...@@ -3425,7 +3425,7 @@ static int decode_attr_owner(struct xdr_stream *xdr, uint32_t *bitmap,
} }
static int decode_attr_group(struct xdr_stream *xdr, uint32_t *bitmap, static int decode_attr_group(struct xdr_stream *xdr, uint32_t *bitmap,
struct nfs_client *clp, uint32_t *gid, int may_sleep) const struct nfs_server *server, uint32_t *gid, int may_sleep)
{ {
uint32_t len; uint32_t len;
__be32 *p; __be32 *p;
...@@ -3445,7 +3445,7 @@ static int decode_attr_group(struct xdr_stream *xdr, uint32_t *bitmap, ...@@ -3445,7 +3445,7 @@ static int decode_attr_group(struct xdr_stream *xdr, uint32_t *bitmap,
if (!may_sleep) { if (!may_sleep) {
/* do nothing */ /* do nothing */
} else if (len < XDR_MAX_NETOBJ) { } else if (len < XDR_MAX_NETOBJ) {
if (nfs_map_group_to_gid(clp, (char *)p, len, gid) == 0) if (nfs_map_group_to_gid(server, (char *)p, len, gid) == 0)
ret = NFS_ATTR_FATTR_GROUP; ret = NFS_ATTR_FATTR_GROUP;
else else
dprintk("%s: nfs_map_group_to_gid failed!\n", dprintk("%s: nfs_map_group_to_gid failed!\n",
...@@ -3944,14 +3944,12 @@ static int decode_getfattr_attrs(struct xdr_stream *xdr, uint32_t *bitmap, ...@@ -3944,14 +3944,12 @@ static int decode_getfattr_attrs(struct xdr_stream *xdr, uint32_t *bitmap,
goto xdr_error; goto xdr_error;
fattr->valid |= status; fattr->valid |= status;
status = decode_attr_owner(xdr, bitmap, server->nfs_client, status = decode_attr_owner(xdr, bitmap, server, &fattr->uid, may_sleep);
&fattr->uid, may_sleep);
if (status < 0) if (status < 0)
goto xdr_error; goto xdr_error;
fattr->valid |= status; fattr->valid |= status;
status = decode_attr_group(xdr, bitmap, server->nfs_client, status = decode_attr_group(xdr, bitmap, server, &fattr->gid, may_sleep);
&fattr->gid, may_sleep);
if (status < 0) if (status < 0)
goto xdr_error; goto xdr_error;
fattr->valid |= status; fattr->valid |= status;
......
...@@ -65,6 +65,7 @@ struct idmap_msg { ...@@ -65,6 +65,7 @@ struct idmap_msg {
/* Forward declaration to make this header independent of others */ /* Forward declaration to make this header independent of others */
struct nfs_client; struct nfs_client;
struct nfs_server;
#ifdef CONFIG_NFS_USE_NEW_IDMAPPER #ifdef CONFIG_NFS_USE_NEW_IDMAPPER
...@@ -96,10 +97,10 @@ void nfs_idmap_delete(struct nfs_client *); ...@@ -96,10 +97,10 @@ void nfs_idmap_delete(struct nfs_client *);
#endif /* CONFIG_NFS_USE_NEW_IDMAPPER */ #endif /* CONFIG_NFS_USE_NEW_IDMAPPER */
int nfs_map_name_to_uid(struct nfs_client *, const char *, size_t, __u32 *); int nfs_map_name_to_uid(const struct nfs_server *, const char *, size_t, __u32 *);
int nfs_map_group_to_gid(struct nfs_client *, const char *, size_t, __u32 *); int nfs_map_group_to_gid(const struct nfs_server *, const char *, size_t, __u32 *);
int nfs_map_uid_to_name(struct nfs_client *, __u32, char *, size_t); int nfs_map_uid_to_name(const struct nfs_server *, __u32, char *, size_t);
int nfs_map_gid_to_group(struct nfs_client *, __u32, char *, size_t); int nfs_map_gid_to_group(const struct nfs_server *, __u32, char *, size_t);
extern unsigned int nfs_idmap_cache_timeout; extern unsigned int nfs_idmap_cache_timeout;
#endif /* __KERNEL__ */ #endif /* __KERNEL__ */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册