linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nadav Shemer <nadav@tonian.com>
To: Trond.Myklebust@netapp.com, jlayton@redhat.com
Cc: linux-nfs@vger.kernel.org
Subject: [PATCH V2] nfs: fix open(O_RDONLY|O_TRUNC) in NFS4.0
Date: Sun, 21 Jul 2013 17:21:43 +0300	[thread overview]
Message-ID: <1374416503-3693-1-git-send-email-nadav@tonian.com> (raw)
In-Reply-To: <CADnca3sTH7XWOsKB1KihR5ig6_DPpZaOak=m75W+nL2JV7dsTw@mail.gmail.com>

nfs4_proc_setattr removes ATTR_OPEN from sattr->ia_valid, but later
nfs4_do_setattr checks for it
---
v2: Don't break the 'no change, don't RPC' optimization
    Much smaller patch

 fs/nfs/nfs4proc.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 6634109..e979f1d 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -2444,34 +2444,34 @@ static int
 nfs4_proc_setattr(struct dentry *dentry, struct nfs_fattr *fattr,
 		  struct iattr *sattr)
 {
 	struct inode *inode = dentry->d_inode;
 	struct rpc_cred *cred = NULL;
 	struct nfs4_state *state = NULL;
 	int status;
 
 	if (pnfs_ld_layoutret_on_setattr(inode))
 		pnfs_return_layout(inode);
 
 	nfs_fattr_init(fattr);
 	
 	/* Deal with open(O_TRUNC) */
 	if (sattr->ia_valid & ATTR_OPEN)
-		sattr->ia_valid &= ~(ATTR_MTIME|ATTR_CTIME|ATTR_OPEN);
+		sattr->ia_valid &= ~(ATTR_MTIME|ATTR_CTIME);
 
 	/* Optimization: if the end result is no change, don't RPC */
-	if ((sattr->ia_valid & ~(ATTR_FILE)) == 0)
+	if ((sattr->ia_valid & ~(ATTR_FILE|ATTR_OPEN)) == 0)
 		return 0;
 
 	/* Search for an existing open(O_WRITE) file */
 	if (sattr->ia_valid & ATTR_FILE) {
 		struct nfs_open_context *ctx;
 
 		ctx = nfs_file_open_context(sattr->ia_file);
 		if (ctx) {
 			cred = ctx->cred;
 			state = ctx->state;
 		}
 	}
 
 	status = nfs4_do_setattr(inode, cred, fattr, sattr, state);
 	if (status == 0)
-- 
1.7.6.5


  reply	other threads:[~2013-07-21 14:24 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-09 16:16 [PATCH] NFSv4: fix open(O_RDONLY|O_TRUNC) returning EBADF Nadav Shemer
2013-07-11 14:49 ` Jeff Layton
2013-07-19 14:21   ` Jeff Layton
2013-07-21 14:23     ` Nadav Shemer
2013-07-21 14:21       ` Nadav Shemer [this message]
2013-07-22 10:41         ` [PATCH V2] nfs: fix open(O_RDONLY|O_TRUNC) in NFS4.0 Jeff Layton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1374416503-3693-1-git-send-email-nadav@tonian.com \
    --to=nadav@tonian.com \
    --cc=Trond.Myklebust@netapp.com \
    --cc=jlayton@redhat.com \
    --cc=linux-nfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).