Skip to content

Commit 2669940

Browse files
androsadamsonTrond Myklebust
authored andcommitted
NFSv4 do not send an empty SETATTR compound
Commit 536e43d ATTR_OPEN check can result in an ia_valid with only ATTR_FILE set, and no NFS_VALID_ATTRS attributes to request from the server. Signed-off-by: Andy Adamson <andros@netapp.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
1 parent 64f9a83 commit 2669940

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

‎fs/nfs/nfs4proc.c‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2549,6 +2549,14 @@ nfs4_proc_setattr(struct dentry *dentry, struct nfs_fattr *fattr,
25492549

25502550
nfs_fattr_init(fattr);
25512551

2552+
/* Deal with open(O_TRUNC) */
2553+
if (sattr->ia_valid & ATTR_OPEN)
2554+
sattr->ia_valid &= ~(ATTR_MTIME|ATTR_CTIME|ATTR_OPEN);
2555+
2556+
/* Optimization: if the end result is no change, don't RPC */
2557+
if ((sattr->ia_valid & ~(ATTR_FILE)) == 0)
2558+
return 0;
2559+
25522560
/* Search for an existing open(O_WRITE) file */
25532561
if (sattr->ia_valid & ATTR_FILE) {
25542562
struct nfs_open_context *ctx;
@@ -2560,10 +2568,6 @@ nfs4_proc_setattr(struct dentry *dentry, struct nfs_fattr *fattr,
25602568
}
25612569
}
25622570

2563-
/* Deal with open(O_TRUNC) */
2564-
if (sattr->ia_valid & ATTR_OPEN)
2565-
sattr->ia_valid &= ~(ATTR_MTIME|ATTR_CTIME|ATTR_OPEN);
2566-
25672571
status = nfs4_do_setattr(inode, cred, fattr, sattr, state);
25682572
if (status == 0)
25692573
nfs_setattr_update_inode(inode, sattr);

0 commit comments

Comments
 (0)