提交 991eedb1 编写于 作者: T Trond Myklebust 提交者: Trond Myklebust

NFSv4: Only pass the delegation to setattr if we're sending a truncate

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: NTrond Myklebust <trond.myklebust@hammerspace.com>
上级 2f261020
...@@ -3032,7 +3032,6 @@ static int _nfs4_do_setattr(struct inode *inode, ...@@ -3032,7 +3032,6 @@ static int _nfs4_do_setattr(struct inode *inode,
}; };
struct rpc_cred *delegation_cred = NULL; struct rpc_cred *delegation_cred = NULL;
unsigned long timestamp = jiffies; unsigned long timestamp = jiffies;
fmode_t fmode;
bool truncate; bool truncate;
int status; int status;
...@@ -3040,11 +3039,12 @@ static int _nfs4_do_setattr(struct inode *inode, ...@@ -3040,11 +3039,12 @@ static int _nfs4_do_setattr(struct inode *inode,
/* Servers should only apply open mode checks for file size changes */ /* Servers should only apply open mode checks for file size changes */
truncate = (arg->iap->ia_valid & ATTR_SIZE) ? true : false; 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 */ /* Use that stateid */
} else if (truncate && ctx != NULL) { } else if (ctx != NULL) {
struct nfs_lock_context *l_ctx; struct nfs_lock_context *l_ctx;
if (!nfs4_valid_open_stateid(ctx->state)) if (!nfs4_valid_open_stateid(ctx->state))
return -EBADF; return -EBADF;
...@@ -3056,8 +3056,10 @@ static int _nfs4_do_setattr(struct inode *inode, ...@@ -3056,8 +3056,10 @@ static int _nfs4_do_setattr(struct inode *inode,
nfs_put_lock_context(l_ctx); nfs_put_lock_context(l_ctx);
if (status == -EIO) if (status == -EIO)
return -EBADF; return -EBADF;
} else } else {
zero_stateid:
nfs4_stateid_copy(&arg->stateid, &zero_stateid); nfs4_stateid_copy(&arg->stateid, &zero_stateid);
}
if (delegation_cred) if (delegation_cred)
msg.rpc_cred = delegation_cred; msg.rpc_cred = delegation_cred;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册