Skip to content

Commit 6412e44

Browse files
Trond Myklebustchucklever
authored andcommitted
nfsd: Fix a regression in nfsd_setattr()
Commit bb4d53d ("NFSD: use (un)lock_inode instead of fh_(un)lock for file operations") broke the NFSv3 pre/post op attributes behaviour when doing a SETATTR rpc call by stripping out the calls to fh_fill_pre_attrs() and fh_fill_post_attrs(). Fixes: bb4d53d ("NFSD: use (un)lock_inode instead of fh_(un)lock for file operations") Signed-off-by: Trond Myklebust <[email protected]> Reviewed-by: Jeff Layton <[email protected]> Reviewed-by: NeilBrown <[email protected]> Message-ID: <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
1 parent 5826e09 commit 6412e44

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

fs/nfsd/nfs4proc.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,6 +1143,7 @@ nfsd4_setattr(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
11431143
};
11441144
struct inode *inode;
11451145
__be32 status = nfs_ok;
1146+
bool save_no_wcc;
11461147
int err;
11471148

11481149
if (setattr->sa_iattr.ia_valid & ATTR_SIZE) {
@@ -1168,8 +1169,11 @@ nfsd4_setattr(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
11681169

11691170
if (status)
11701171
goto out;
1172+
save_no_wcc = cstate->current_fh.fh_no_wcc;
1173+
cstate->current_fh.fh_no_wcc = true;
11711174
status = nfsd_setattr(rqstp, &cstate->current_fh, &attrs,
11721175
0, (time64_t)0);
1176+
cstate->current_fh.fh_no_wcc = save_no_wcc;
11731177
if (!status)
11741178
status = nfserrno(attrs.na_labelerr);
11751179
if (!status)

fs/nfsd/vfs.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp,
497497
int accmode = NFSD_MAY_SATTR;
498498
umode_t ftype = 0;
499499
__be32 err;
500-
int host_err;
500+
int host_err = 0;
501501
bool get_write_count;
502502
bool size_change = (iap->ia_valid & ATTR_SIZE);
503503
int retries;
@@ -555,6 +555,9 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp,
555555
}
556556

557557
inode_lock(inode);
558+
err = fh_fill_pre_attrs(fhp);
559+
if (err)
560+
goto out_unlock;
558561
for (retries = 1;;) {
559562
struct iattr attrs;
560563

@@ -582,13 +585,15 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp,
582585
attr->na_aclerr = set_posix_acl(&nop_mnt_idmap,
583586
dentry, ACL_TYPE_DEFAULT,
584587
attr->na_dpacl);
588+
fh_fill_post_attrs(fhp);
589+
out_unlock:
585590
inode_unlock(inode);
586591
if (size_change)
587592
put_write_access(inode);
588593
out:
589594
if (!host_err)
590595
host_err = commit_metadata(fhp);
591-
return nfserrno(host_err);
596+
return err != 0 ? err : nfserrno(host_err);
592597
}
593598

594599
#if defined(CONFIG_NFSD_V4)

0 commit comments

Comments
 (0)