linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton@redhat.com>
To: Nadav Shemer <nadav@tonian.com>
Cc: Trond.Myklebust@netapp.com, linux-nfs@vger.kernel.org
Subject: Re: [PATCH V2] nfs: fix open(O_RDONLY|O_TRUNC) in NFS4.0
Date: Mon, 22 Jul 2013 06:41:59 -0400	[thread overview]
Message-ID: <20130722064159.0a2eb1e7@corrin.poochiereds.net> (raw)
In-Reply-To: <1374416503-3693-1-git-send-email-nadav@tonian.com>

On Sun, 21 Jul 2013 17:21:43 +0300
Nadav Shemer <nadav@tonian.com> wrote:

> 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)

I think that looks more reasonable...

Reviewed-by: Jeff Layton <jlayton@redhat.com>

      reply	other threads:[~2013-07-22 10:41 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       ` [PATCH V2] nfs: fix open(O_RDONLY|O_TRUNC) in NFS4.0 Nadav Shemer
2013-07-22 10:41         ` Jeff Layton [this message]

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=20130722064159.0a2eb1e7@corrin.poochiereds.net \
    --to=jlayton@redhat.com \
    --cc=Trond.Myklebust@netapp.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=nadav@tonian.com \
    /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).