From 6fea45e2a7a4c781791d1a97b6534de93ba374a4 Mon Sep 17 00:00:00 2001 From: Trond Myklebust Date: Mon, 29 Apr 2013 10:35:36 -0400 Subject: [PATCH] --- yaml --- r: 367341 b: refs/heads/master c: ee3ae84ef40154c734dc2cbca5cf4b2f54c6c7c7 h: refs/heads/master i: 367339: a31d47d11aea934d833376f74088b260ea4cbf40 v: v3 --- [refs] | 2 +- trunk/fs/nfs/nfs4proc.c | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/[refs] b/[refs] index bbef69466be5..956f73d22a3c 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: b0212b84fb19cf89305ab96c73abdf3a76d05ef8 +refs/heads/master: ee3ae84ef40154c734dc2cbca5cf4b2f54c6c7c7 diff --git a/trunk/fs/nfs/nfs4proc.c b/trunk/fs/nfs/nfs4proc.c index 3bc847ce4838..982b4527551d 100644 --- a/trunk/fs/nfs/nfs4proc.c +++ b/trunk/fs/nfs/nfs4proc.c @@ -2142,20 +2142,25 @@ static int _nfs4_do_setattr(struct inode *inode, struct rpc_cred *cred, .rpc_cred = cred, }; unsigned long timestamp = jiffies; + fmode_t fmode; + bool truncate; int status; nfs_fattr_init(fattr); - if (state != NULL && nfs4_valid_open_stateid(state)) { + /* Servers should only apply open mode checks for file size changes */ + truncate = (sattr->ia_valid & ATTR_SIZE) ? true : false; + fmode = truncate ? FMODE_WRITE : FMODE_READ; + + if (nfs4_copy_delegation_stateid(&arg.stateid, inode, fmode)) { + /* Use that stateid */ + } else if (truncate && state != NULL && nfs4_valid_open_stateid(state)) { struct nfs_lockowner lockowner = { .l_owner = current->files, .l_pid = current->tgid, }; nfs4_select_rw_stateid(&arg.stateid, state, FMODE_WRITE, &lockowner); - } else if (nfs4_copy_delegation_stateid(&arg.stateid, inode, - FMODE_WRITE)) { - /* Use that stateid */ } else nfs4_stateid_copy(&arg.stateid, &zero_stateid);