Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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 <jlayton@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>

Chuck Lever edf7b905 e58691ea

+20 -11
+2 -2
fs/nfsd/nfs4layouts.c
··· 65 65 return; 66 66 67 67 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); 69 69 70 70 spin_lock(&nfsd_devid_lock); 71 71 if (fhp->fh_export->ex_devid_map) ··· 75 75 list_for_each_entry(old, &nfsd_devid_hash[i], hash) { 76 76 if (old->fsid_type != fh->fh_fsid_type) 77 77 continue; 78 - if (memcmp(old->fsid, fh->fh_fsid, 78 + if (memcmp(old->fsid, fh_fsid(fh), 79 79 key_len(old->fsid_type))) 80 80 continue; 81 81
+9 -7
fs/nfsd/nfsfh.c
··· 172 172 if (len == 0) 173 173 return error; 174 174 if (fh->fh_fsid_type == FSID_MAJOR_MINOR) { 175 + u32 *fsid = fh_fsid(fh); 176 + 175 177 /* deprecated, convert to type 3 */ 176 178 len = key_len(FSID_ENCODE_DEV)/4; 177 179 fh->fh_fsid_type = FSID_ENCODE_DEV; ··· 183 181 * confuses sparse, so we must use __force here to 184 182 * keep it from complaining. 185 183 */ 186 - fh->fh_fsid[0] = new_encode_dev(MKDEV(ntohl((__force __be32)fh->fh_fsid[0]), 187 - ntohl((__force __be32)fh->fh_fsid[1]))); 188 - fh->fh_fsid[1] = fh->fh_fsid[2]; 184 + fsid[0] = new_encode_dev(MKDEV(ntohl((__force __be32)fsid[0]), 185 + ntohl((__force __be32)fsid[1]))); 186 + fsid[1] = fsid[2]; 189 187 } 190 188 data_left -= len; 191 189 if (data_left < 0) 192 190 return error; 193 191 exp = rqst_exp_find(rqstp ? &rqstp->rq_chandle : NULL, 194 192 net, client, gssclient, 195 - fh->fh_fsid_type, fh->fh_fsid); 196 - fid = (struct fid *)(fh->fh_fsid + len); 193 + fh->fh_fsid_type, fh_fsid(fh)); 194 + fid = (struct fid *)(fh_fsid(fh) + len); 197 195 198 196 error = nfserr_stale; 199 197 if (IS_ERR(exp)) { ··· 465 463 { 466 464 if (dentry != exp->ex_path.dentry) { 467 465 struct fid *fid = (struct fid *) 468 - (fhp->fh_handle.fh_fsid + fhp->fh_handle.fh_size/4 - 1); 466 + (fh_fsid(&fhp->fh_handle) + fhp->fh_handle.fh_size/4 - 1); 469 467 int maxsize = (fhp->fh_maxsize - fhp->fh_handle.fh_size)/4; 470 468 int fh_flags = (exp->ex_flags & NFSEXP_NOSUBTREECHECK) ? 0 : 471 469 EXPORT_FH_CONNECTABLE; ··· 616 614 fhp->fh_handle.fh_auth_type = 0; 617 615 618 616 mk_fsid(fhp->fh_handle.fh_fsid_type, 619 - fhp->fh_handle.fh_fsid, 617 + fh_fsid(&fhp->fh_handle), 620 618 ex_dev, 621 619 d_inode(exp->ex_path.dentry)->i_ino, 622 620 exp->ex_fsid, exp->ex_uuid);
+9 -2
fs/nfsd/nfsfh.h
··· 56 56 u8 fh_auth_type; /* deprecated */ 57 57 u8 fh_fsid_type; 58 58 u8 fh_fileid_type; 59 - u32 fh_fsid[NFS4_FHSIZE / 4 - 1]; 60 59 }; 61 60 }; 62 61 }; 62 + 63 + static inline u32 *fh_fsid(const struct knfsd_fh *fh) 64 + { 65 + return (u32 *)&fh->fh_raw[4]; 66 + } 63 67 64 68 static inline __u32 ino_t_to_u32(ino_t ino) 65 69 { ··· 264 260 static inline bool fh_fsid_match(const struct knfsd_fh *fh1, 265 261 const struct knfsd_fh *fh2) 266 262 { 263 + u32 *fsid1 = fh_fsid(fh1); 264 + u32 *fsid2 = fh_fsid(fh2); 265 + 267 266 if (fh1->fh_fsid_type != fh2->fh_fsid_type) 268 267 return false; 269 - if (memcmp(fh1->fh_fsid, fh2->fh_fsid, key_len(fh1->fh_fsid_type)) != 0) 268 + if (memcmp(fsid1, fsid2, key_len(fh1->fh_fsid_type)) != 0) 270 269 return false; 271 270 return true; 272 271 }