Skip to content

Commit 913ff52

Browse files
Trond Myklebustgregkh
authored andcommitted
nfsd: Fix a regression in nfsd_setattr()
[ Upstream commit 6412e44 ] 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 <trond.myklebust@hammerspace.com> Reviewed-by: Jeff Layton <jlayton@kernel.org> Reviewed-by: NeilBrown <neilb@suse.de> Message-ID: <20240216012451.22725-1-trondmy@kernel.org> Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Stable-dep-of: d7d8e31 ("NFSD: nfsd_unlink() clobbers non-zero status returned from fh_fill_pre_attrs()") Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 392260e commit 913ff52

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
@@ -1131,6 +1131,7 @@ nfsd4_setattr(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
11311131
};
11321132
struct inode *inode;
11331133
__be32 status = nfs_ok;
1134+
bool save_no_wcc;
11341135
int err;
11351136

11361137
if (setattr->sa_iattr.ia_valid & ATTR_SIZE) {
@@ -1156,8 +1157,11 @@ nfsd4_setattr(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
11561157

11571158
if (status)
11581159
goto out;
1160+
save_no_wcc = cstate->current_fh.fh_no_wcc;
1161+
cstate->current_fh.fh_no_wcc = true;
11591162
status = nfsd_setattr(rqstp, &cstate->current_fh, &attrs,
11601163
0, (time64_t)0);
1164+
cstate->current_fh.fh_no_wcc = save_no_wcc;
11611165
if (!status)
11621166
status = nfserrno(attrs.na_labelerr);
11631167
if (!status)

fs/nfsd/vfs.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp,
480480
int accmode = NFSD_MAY_SATTR;
481481
umode_t ftype = 0;
482482
__be32 err;
483-
int host_err;
483+
int host_err = 0;
484484
bool get_write_count;
485485
bool size_change = (iap->ia_valid & ATTR_SIZE);
486486
int retries;
@@ -538,6 +538,9 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp,
538538
}
539539

540540
inode_lock(inode);
541+
err = fh_fill_pre_attrs(fhp);
542+
if (err)
543+
goto out_unlock;
541544
for (retries = 1;;) {
542545
struct iattr attrs;
543546

@@ -565,13 +568,15 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp,
565568
attr->na_aclerr = set_posix_acl(&nop_mnt_idmap,
566569
dentry, ACL_TYPE_DEFAULT,
567570
attr->na_dpacl);
571+
fh_fill_post_attrs(fhp);
572+
out_unlock:
568573
inode_unlock(inode);
569574
if (size_change)
570575
put_write_access(inode);
571576
out:
572577
if (!host_err)
573578
host_err = commit_metadata(fhp);
574-
return nfserrno(host_err);
579+
return err != 0 ? err : nfserrno(host_err);
575580
}
576581

577582
#if defined(CONFIG_NFSD_V4)

0 commit comments

Comments
 (0)