Skip to content

Commit edf7b90

Browse files
committed
NFSD: Access a knfsd_fh's fsid by pointer
I'm about to remove the union in struct knfsd_fh. First step is to add an accessor function for the file handle's fsid portion. Reviewed-by: Jeff Layton <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
1 parent e58691e commit edf7b90

3 files changed

Lines changed: 20 additions & 11 deletions

File tree

fs/nfsd/nfs4layouts.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ nfsd4_alloc_devid_map(const struct svc_fh *fhp)
6565
return;
6666

6767
map->fsid_type = fh->fh_fsid_type;
68-
memcpy(&map->fsid, fh->fh_fsid, fsid_len);
68+
memcpy(&map->fsid, fh_fsid(fh), fsid_len);
6969

7070
spin_lock(&nfsd_devid_lock);
7171
if (fhp->fh_export->ex_devid_map)
@@ -75,7 +75,7 @@ nfsd4_alloc_devid_map(const struct svc_fh *fhp)
7575
list_for_each_entry(old, &nfsd_devid_hash[i], hash) {
7676
if (old->fsid_type != fh->fh_fsid_type)
7777
continue;
78-
if (memcmp(old->fsid, fh->fh_fsid,
78+
if (memcmp(old->fsid, fh_fsid(fh),
7979
key_len(old->fsid_type)))
8080
continue;
8181

fs/nfsd/nfsfh.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ static __be32 nfsd_set_fh_dentry(struct svc_rqst *rqstp, struct net *net,
172172
if (len == 0)
173173
return error;
174174
if (fh->fh_fsid_type == FSID_MAJOR_MINOR) {
175+
u32 *fsid = fh_fsid(fh);
176+
175177
/* deprecated, convert to type 3 */
176178
len = key_len(FSID_ENCODE_DEV)/4;
177179
fh->fh_fsid_type = FSID_ENCODE_DEV;
@@ -181,17 +183,17 @@ static __be32 nfsd_set_fh_dentry(struct svc_rqst *rqstp, struct net *net,
181183
* confuses sparse, so we must use __force here to
182184
* keep it from complaining.
183185
*/
184-
fh->fh_fsid[0] = new_encode_dev(MKDEV(ntohl((__force __be32)fh->fh_fsid[0]),
185-
ntohl((__force __be32)fh->fh_fsid[1])));
186-
fh->fh_fsid[1] = fh->fh_fsid[2];
186+
fsid[0] = new_encode_dev(MKDEV(ntohl((__force __be32)fsid[0]),
187+
ntohl((__force __be32)fsid[1])));
188+
fsid[1] = fsid[2];
187189
}
188190
data_left -= len;
189191
if (data_left < 0)
190192
return error;
191193
exp = rqst_exp_find(rqstp ? &rqstp->rq_chandle : NULL,
192194
net, client, gssclient,
193-
fh->fh_fsid_type, fh->fh_fsid);
194-
fid = (struct fid *)(fh->fh_fsid + len);
195+
fh->fh_fsid_type, fh_fsid(fh));
196+
fid = (struct fid *)(fh_fsid(fh) + len);
195197

196198
error = nfserr_stale;
197199
if (IS_ERR(exp)) {
@@ -463,7 +465,7 @@ static void _fh_update(struct svc_fh *fhp, struct svc_export *exp,
463465
{
464466
if (dentry != exp->ex_path.dentry) {
465467
struct fid *fid = (struct fid *)
466-
(fhp->fh_handle.fh_fsid + fhp->fh_handle.fh_size/4 - 1);
468+
(fh_fsid(&fhp->fh_handle) + fhp->fh_handle.fh_size/4 - 1);
467469
int maxsize = (fhp->fh_maxsize - fhp->fh_handle.fh_size)/4;
468470
int fh_flags = (exp->ex_flags & NFSEXP_NOSUBTREECHECK) ? 0 :
469471
EXPORT_FH_CONNECTABLE;
@@ -614,7 +616,7 @@ fh_compose(struct svc_fh *fhp, struct svc_export *exp, struct dentry *dentry,
614616
fhp->fh_handle.fh_auth_type = 0;
615617

616618
mk_fsid(fhp->fh_handle.fh_fsid_type,
617-
fhp->fh_handle.fh_fsid,
619+
fh_fsid(&fhp->fh_handle),
618620
ex_dev,
619621
d_inode(exp->ex_path.dentry)->i_ino,
620622
exp->ex_fsid, exp->ex_uuid);

fs/nfsd/nfsfh.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,15 @@ struct knfsd_fh {
5656
u8 fh_auth_type; /* deprecated */
5757
u8 fh_fsid_type;
5858
u8 fh_fileid_type;
59-
u32 fh_fsid[NFS4_FHSIZE / 4 - 1];
6059
};
6160
};
6261
};
6362

63+
static inline u32 *fh_fsid(const struct knfsd_fh *fh)
64+
{
65+
return (u32 *)&fh->fh_raw[4];
66+
}
67+
6468
static inline __u32 ino_t_to_u32(ino_t ino)
6569
{
6670
return (__u32) ino;
@@ -260,9 +264,12 @@ static inline bool fh_match(const struct knfsd_fh *fh1,
260264
static inline bool fh_fsid_match(const struct knfsd_fh *fh1,
261265
const struct knfsd_fh *fh2)
262266
{
267+
u32 *fsid1 = fh_fsid(fh1);
268+
u32 *fsid2 = fh_fsid(fh2);
269+
263270
if (fh1->fh_fsid_type != fh2->fh_fsid_type)
264271
return false;
265-
if (memcmp(fh1->fh_fsid, fh2->fh_fsid, key_len(fh1->fh_fsid_type)) != 0)
272+
if (memcmp(fsid1, fsid2, key_len(fh1->fh_fsid_type)) != 0)
266273
return false;
267274
return true;
268275
}

0 commit comments

Comments
 (0)