Skip to content

Commit c689bdd

Browse files
neilbrownchucklever
authored andcommitted
nfsd: further centralize protocol version checks.
With this patch the only places that test ->rq_vers against a specific version are nfsd_v4client() and nfsd_set_fh_dentry(). The latter sets some flags in the svc_fh, which now includes: fh_64bit_cookies fh_use_wgather Signed-off-by: NeilBrown <[email protected]> Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
1 parent 4f67d24 commit c689bdd

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

fs/nfsd/nfsfh.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,13 +284,17 @@ static __be32 nfsd_set_fh_dentry(struct svc_rqst *rqstp, struct svc_fh *fhp)
284284
case 4:
285285
if (dentry->d_sb->s_export_op->flags & EXPORT_OP_NOATOMIC_ATTR)
286286
fhp->fh_no_atomic_attr = true;
287+
fhp->fh_64bit_cookies = true;
287288
break;
288289
case 3:
289290
if (dentry->d_sb->s_export_op->flags & EXPORT_OP_NOWCC)
290291
fhp->fh_no_wcc = true;
292+
fhp->fh_64bit_cookies = true;
291293
break;
292294
case 2:
293295
fhp->fh_no_wcc = true;
296+
if (EX_WGATHER(exp))
297+
fhp->fh_use_wgather = true;
294298
}
295299

296300
return 0;

fs/nfsd/nfsfh.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ typedef struct svc_fh {
8888
* wcc data is not atomic with
8989
* operation
9090
*/
91+
bool fh_use_wgather; /* NFSv2 wgather option */
92+
bool fh_64bit_cookies;/* readdir cookie size */
9193
int fh_flags; /* FH flags */
9294
bool fh_post_saved; /* post-op attrs saved */
9395
bool fh_pre_saved; /* pre-op attrs saved */

fs/nfsd/vfs.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,7 +1162,6 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct nfsd_file *nf,
11621162
errseq_t since;
11631163
__be32 nfserr;
11641164
int host_err;
1165-
int use_wgather;
11661165
loff_t pos = offset;
11671166
unsigned long exp_op_flags = 0;
11681167
unsigned int pflags = current->flags;
@@ -1188,12 +1187,11 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct nfsd_file *nf,
11881187
}
11891188

11901189
exp = fhp->fh_export;
1191-
use_wgather = (rqstp->rq_vers == 2) && EX_WGATHER(exp);
11921190

11931191
if (!EX_ISSYNC(exp))
11941192
stable = NFS_UNSTABLE;
11951193

1196-
if (stable && !use_wgather)
1194+
if (stable && !fhp->fh_use_wgather)
11971195
flags |= RWF_SYNC;
11981196

11991197
iov_iter_kvec(&iter, ITER_SOURCE, vec, vlen, *cnt);
@@ -1212,7 +1210,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct nfsd_file *nf,
12121210
if (host_err < 0)
12131211
goto out_nfserr;
12141212

1215-
if (stable && use_wgather) {
1213+
if (stable && fhp->fh_use_wgather) {
12161214
host_err = wait_for_concurrent_writes(file);
12171215
if (host_err < 0)
12181216
commit_reset_write_verifier(nn, rqstp, host_err);
@@ -2181,8 +2179,7 @@ nfsd_readdir(struct svc_rqst *rqstp, struct svc_fh *fhp, loff_t *offsetp,
21812179
loff_t offset = *offsetp;
21822180
int may_flags = NFSD_MAY_READ;
21832181

2184-
/* NFSv2 only supports 32 bit cookies */
2185-
if (rqstp->rq_vers > 2)
2182+
if (fhp->fh_64bit_cookies)
21862183
may_flags |= NFSD_MAY_64BIT_COOKIE;
21872184

21882185
err = nfsd_open(rqstp, fhp, S_IFDIR, may_flags, &file);

0 commit comments

Comments
 (0)