Skip to content

Commit e4fd72a

Browse files
Trond MyklebustTrond Myklebust
authored andcommitted
NFSv4: cleanup idmapper functions to take an nfs_server argument
...instead of the nfs_client. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
1 parent f0b8516 commit e4fd72a

File tree

3 files changed

+25
-26
lines changed

3 files changed

+25
-26
lines changed

fs/nfs/idmap.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -241,29 +241,29 @@ static int nfs_idmap_lookup_id(const char *name, size_t namelen,
241241
return ret;
242242
}
243243

244-
int nfs_map_name_to_uid(struct nfs_client *clp, const char *name, size_t namelen, __u32 *uid)
244+
int nfs_map_name_to_uid(const struct nfs_server *server, const char *name, size_t namelen, __u32 *uid)
245245
{
246246
if (nfs_map_string_to_numeric(name, namelen, uid))
247247
return 0;
248248
return nfs_idmap_lookup_id(name, namelen, "uid", uid);
249249
}
250250

251-
int nfs_map_group_to_gid(struct nfs_client *clp, const char *name, size_t namelen, __u32 *gid)
251+
int nfs_map_group_to_gid(const struct nfs_server *server, const char *name, size_t namelen, __u32 *gid)
252252
{
253253
if (nfs_map_string_to_numeric(name, namelen, gid))
254254
return 0;
255255
return nfs_idmap_lookup_id(name, namelen, "gid", gid);
256256
}
257257

258-
int nfs_map_uid_to_name(struct nfs_client *clp, __u32 uid, char *buf, size_t buflen)
258+
int nfs_map_uid_to_name(const struct nfs_server *server, __u32 uid, char *buf, size_t buflen)
259259
{
260260
int ret;
261261
ret = nfs_idmap_lookup_name(uid, "user", buf, buflen);
262262
if (ret < 0)
263263
ret = nfs_map_numeric_to_string(uid, buf, buflen);
264264
return ret;
265265
}
266-
int nfs_map_gid_to_group(struct nfs_client *clp, __u32 gid, char *buf, size_t buflen)
266+
int nfs_map_gid_to_group(const struct nfs_server *server, __u32 gid, char *buf, size_t buflen)
267267
{
268268
int ret;
269269

@@ -729,37 +729,37 @@ static unsigned int fnvhash32(const void *buf, size_t buflen)
729729
return hash;
730730
}
731731

732-
int nfs_map_name_to_uid(struct nfs_client *clp, const char *name, size_t namelen, __u32 *uid)
732+
int nfs_map_name_to_uid(const struct nfs_server *server, const char *name, size_t namelen, __u32 *uid)
733733
{
734-
struct idmap *idmap = clp->cl_idmap;
734+
struct idmap *idmap = server->nfs_client->cl_idmap;
735735

736736
if (nfs_map_string_to_numeric(name, namelen, uid))
737737
return 0;
738738
return nfs_idmap_id(idmap, &idmap->idmap_user_hash, name, namelen, uid);
739739
}
740740

741-
int nfs_map_group_to_gid(struct nfs_client *clp, const char *name, size_t namelen, __u32 *uid)
741+
int nfs_map_group_to_gid(const struct nfs_server *server, const char *name, size_t namelen, __u32 *uid)
742742
{
743-
struct idmap *idmap = clp->cl_idmap;
743+
struct idmap *idmap = server->nfs_client->cl_idmap;
744744

745745
if (nfs_map_string_to_numeric(name, namelen, uid))
746746
return 0;
747747
return nfs_idmap_id(idmap, &idmap->idmap_group_hash, name, namelen, uid);
748748
}
749749

750-
int nfs_map_uid_to_name(struct nfs_client *clp, __u32 uid, char *buf, size_t buflen)
750+
int nfs_map_uid_to_name(const struct nfs_server *server, __u32 uid, char *buf, size_t buflen)
751751
{
752-
struct idmap *idmap = clp->cl_idmap;
752+
struct idmap *idmap = server->nfs_client->cl_idmap;
753753
int ret;
754754

755755
ret = nfs_idmap_name(idmap, &idmap->idmap_user_hash, uid, buf);
756756
if (ret < 0)
757757
ret = nfs_map_numeric_to_string(uid, buf, buflen);
758758
return ret;
759759
}
760-
int nfs_map_gid_to_group(struct nfs_client *clp, __u32 uid, char *buf, size_t buflen)
760+
int nfs_map_gid_to_group(const struct nfs_server *server, __u32 uid, char *buf, size_t buflen)
761761
{
762-
struct idmap *idmap = clp->cl_idmap;
762+
struct idmap *idmap = server->nfs_client->cl_idmap;
763763
int ret;
764764

765765
ret = nfs_idmap_name(idmap, &idmap->idmap_group_hash, uid, buf);

fs/nfs/nfs4xdr.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,7 @@ static void encode_attrs(struct xdr_stream *xdr, const struct iattr *iap, const
844844
if (iap->ia_valid & ATTR_MODE)
845845
len += 4;
846846
if (iap->ia_valid & ATTR_UID) {
847-
owner_namelen = nfs_map_uid_to_name(server->nfs_client, iap->ia_uid, owner_name, IDMAP_NAMESZ);
847+
owner_namelen = nfs_map_uid_to_name(server, iap->ia_uid, owner_name, IDMAP_NAMESZ);
848848
if (owner_namelen < 0) {
849849
dprintk("nfs: couldn't resolve uid %d to string\n",
850850
iap->ia_uid);
@@ -856,7 +856,7 @@ static void encode_attrs(struct xdr_stream *xdr, const struct iattr *iap, const
856856
len += 4 + (XDR_QUADLEN(owner_namelen) << 2);
857857
}
858858
if (iap->ia_valid & ATTR_GID) {
859-
owner_grouplen = nfs_map_gid_to_group(server->nfs_client, iap->ia_gid, owner_group, IDMAP_NAMESZ);
859+
owner_grouplen = nfs_map_gid_to_group(server, iap->ia_gid, owner_group, IDMAP_NAMESZ);
860860
if (owner_grouplen < 0) {
861861
dprintk("nfs: couldn't resolve gid %d to string\n",
862862
iap->ia_gid);
@@ -3387,7 +3387,7 @@ static int decode_attr_nlink(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t
33873387
}
33883388

33893389
static int decode_attr_owner(struct xdr_stream *xdr, uint32_t *bitmap,
3390-
struct nfs_client *clp, uint32_t *uid, int may_sleep)
3390+
const struct nfs_server *server, uint32_t *uid, int may_sleep)
33913391
{
33923392
uint32_t len;
33933393
__be32 *p;
@@ -3407,7 +3407,7 @@ static int decode_attr_owner(struct xdr_stream *xdr, uint32_t *bitmap,
34073407
if (!may_sleep) {
34083408
/* do nothing */
34093409
} else if (len < XDR_MAX_NETOBJ) {
3410-
if (nfs_map_name_to_uid(clp, (char *)p, len, uid) == 0)
3410+
if (nfs_map_name_to_uid(server, (char *)p, len, uid) == 0)
34113411
ret = NFS_ATTR_FATTR_OWNER;
34123412
else
34133413
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,
34253425
}
34263426

34273427
static int decode_attr_group(struct xdr_stream *xdr, uint32_t *bitmap,
3428-
struct nfs_client *clp, uint32_t *gid, int may_sleep)
3428+
const struct nfs_server *server, uint32_t *gid, int may_sleep)
34293429
{
34303430
uint32_t len;
34313431
__be32 *p;
@@ -3445,7 +3445,7 @@ static int decode_attr_group(struct xdr_stream *xdr, uint32_t *bitmap,
34453445
if (!may_sleep) {
34463446
/* do nothing */
34473447
} else if (len < XDR_MAX_NETOBJ) {
3448-
if (nfs_map_group_to_gid(clp, (char *)p, len, gid) == 0)
3448+
if (nfs_map_group_to_gid(server, (char *)p, len, gid) == 0)
34493449
ret = NFS_ATTR_FATTR_GROUP;
34503450
else
34513451
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,
39443944
goto xdr_error;
39453945
fattr->valid |= status;
39463946

3947-
status = decode_attr_owner(xdr, bitmap, server->nfs_client,
3948-
&fattr->uid, may_sleep);
3947+
status = decode_attr_owner(xdr, bitmap, server, &fattr->uid, may_sleep);
39493948
if (status < 0)
39503949
goto xdr_error;
39513950
fattr->valid |= status;
39523951

3953-
status = decode_attr_group(xdr, bitmap, server->nfs_client,
3954-
&fattr->gid, may_sleep);
3952+
status = decode_attr_group(xdr, bitmap, server, &fattr->gid, may_sleep);
39553953
if (status < 0)
39563954
goto xdr_error;
39573955
fattr->valid |= status;

include/linux/nfs_idmap.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ struct idmap_msg {
6565

6666
/* Forward declaration to make this header independent of others */
6767
struct nfs_client;
68+
struct nfs_server;
6869

6970
#ifdef CONFIG_NFS_USE_NEW_IDMAPPER
7071

@@ -96,10 +97,10 @@ void nfs_idmap_delete(struct nfs_client *);
9697

9798
#endif /* CONFIG_NFS_USE_NEW_IDMAPPER */
9899

99-
int nfs_map_name_to_uid(struct nfs_client *, const char *, size_t, __u32 *);
100-
int nfs_map_group_to_gid(struct nfs_client *, const char *, size_t, __u32 *);
101-
int nfs_map_uid_to_name(struct nfs_client *, __u32, char *, size_t);
102-
int nfs_map_gid_to_group(struct nfs_client *, __u32, char *, size_t);
100+
int nfs_map_name_to_uid(const struct nfs_server *, const char *, size_t, __u32 *);
101+
int nfs_map_group_to_gid(const struct nfs_server *, const char *, size_t, __u32 *);
102+
int nfs_map_uid_to_name(const struct nfs_server *, __u32, char *, size_t);
103+
int nfs_map_gid_to_group(const struct nfs_server *, __u32, char *, size_t);
103104

104105
extern unsigned int nfs_idmap_cache_timeout;
105106
#endif /* __KERNEL__ */

0 commit comments

Comments
 (0)