diff options
Diffstat (limited to 'fs')
-rw-r--r-- | fs/nfs/nfs4proc.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 553cb8f98194..844eafbf1564 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c | |||
@@ -3032,7 +3032,6 @@ static int _nfs4_do_setattr(struct inode *inode, | |||
3032 | }; | 3032 | }; |
3033 | struct rpc_cred *delegation_cred = NULL; | 3033 | struct rpc_cred *delegation_cred = NULL; |
3034 | unsigned long timestamp = jiffies; | 3034 | unsigned long timestamp = jiffies; |
3035 | fmode_t fmode; | ||
3036 | bool truncate; | 3035 | bool truncate; |
3037 | int status; | 3036 | int status; |
3038 | 3037 | ||
@@ -3040,11 +3039,12 @@ static int _nfs4_do_setattr(struct inode *inode, | |||
3040 | 3039 | ||
3041 | /* Servers should only apply open mode checks for file size changes */ | 3040 | /* Servers should only apply open mode checks for file size changes */ |
3042 | truncate = (arg->iap->ia_valid & ATTR_SIZE) ? true : false; | 3041 | truncate = (arg->iap->ia_valid & ATTR_SIZE) ? true : false; |
3043 | fmode = truncate ? FMODE_WRITE : FMODE_READ; | 3042 | if (!truncate) |
3043 | goto zero_stateid; | ||
3044 | 3044 | ||
3045 | if (nfs4_copy_delegation_stateid(inode, fmode, &arg->stateid, &delegation_cred)) { | 3045 | if (nfs4_copy_delegation_stateid(inode, FMODE_WRITE, &arg->stateid, &delegation_cred)) { |
3046 | /* Use that stateid */ | 3046 | /* Use that stateid */ |
3047 | } else if (truncate && ctx != NULL) { | 3047 | } else if (ctx != NULL) { |
3048 | struct nfs_lock_context *l_ctx; | 3048 | struct nfs_lock_context *l_ctx; |
3049 | if (!nfs4_valid_open_stateid(ctx->state)) | 3049 | if (!nfs4_valid_open_stateid(ctx->state)) |
3050 | return -EBADF; | 3050 | return -EBADF; |
@@ -3056,8 +3056,10 @@ static int _nfs4_do_setattr(struct inode *inode, | |||
3056 | nfs_put_lock_context(l_ctx); | 3056 | nfs_put_lock_context(l_ctx); |
3057 | if (status == -EIO) | 3057 | if (status == -EIO) |
3058 | return -EBADF; | 3058 | return -EBADF; |
3059 | } else | 3059 | } else { |
3060 | zero_stateid: | ||
3060 | nfs4_stateid_copy(&arg->stateid, &zero_stateid); | 3061 | nfs4_stateid_copy(&arg->stateid, &zero_stateid); |
3062 | } | ||
3061 | if (delegation_cred) | 3063 | if (delegation_cred) |
3062 | msg.rpc_cred = delegation_cred; | 3064 | msg.rpc_cred = delegation_cred; |
3063 | 3065 | ||