Skip to content

Commit

Permalink
NFSv4: Only pass the delegation to setattr if we're sending a truncate
Browse files Browse the repository at this point in the history
Even then it isn't really necessary. The reason why we may not want to
pass in a stateid in other cases is that we cannot use the delegation
credential.

Signed-off-by: Trond Myklebust <[email protected]>
  • Loading branch information
trondmypd authored and Trond Myklebust committed May 31, 2018
1 parent 2f26102 commit 991eedb
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions fs/nfs/nfs4proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -3032,19 +3032,19 @@ static int _nfs4_do_setattr(struct inode *inode,
};
struct rpc_cred *delegation_cred = NULL;
unsigned long timestamp = jiffies;
fmode_t fmode;
bool truncate;
int status;

nfs_fattr_init(res->fattr);

/* Servers should only apply open mode checks for file size changes */
truncate = (arg->iap->ia_valid & ATTR_SIZE) ? true : false;
fmode = truncate ? FMODE_WRITE : FMODE_READ;
if (!truncate)
goto zero_stateid;

if (nfs4_copy_delegation_stateid(inode, fmode, &arg->stateid, &delegation_cred)) {
if (nfs4_copy_delegation_stateid(inode, FMODE_WRITE, &arg->stateid, &delegation_cred)) {
/* Use that stateid */
} else if (truncate && ctx != NULL) {
} else if (ctx != NULL) {
struct nfs_lock_context *l_ctx;
if (!nfs4_valid_open_stateid(ctx->state))
return -EBADF;
Expand All @@ -3056,8 +3056,10 @@ static int _nfs4_do_setattr(struct inode *inode,
nfs_put_lock_context(l_ctx);
if (status == -EIO)
return -EBADF;
} else
} else {
zero_stateid:
nfs4_stateid_copy(&arg->stateid, &zero_stateid);
}
if (delegation_cred)
msg.rpc_cred = delegation_cred;

Expand Down

0 comments on commit 991eedb

Please sign in to comment.