diff mbox

[V2] nfs: fix open(O_RDONLY|O_TRUNC) in NFS4.0

Message ID 1374416503-3693-1-git-send-email-nadav@tonian.com (mailing list archive)
State New, archived
Headers show

Commit Message

Nadav Shemer July 21, 2013, 2:21 p.m. UTC
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(-)

Comments

Jeff Layton July 22, 2013, 10:41 a.m. UTC | #1
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>
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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)