linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "J. Bruce Fields" <bfields@fieldses.org>
To: Trond Myklebust <Trond.Myklebust@netapp.com>
Cc: linux-nfs@vger.kernel.org, viro@zeniv.linux.org.uk, hch@infradead.org
Subject: Re: [PATCH 2/6] NFSv4: Further minor cleanups for nfs4_atomic_open()
Date: Fri, 17 Sep 2010 13:23:09 -0400	[thread overview]
Message-ID: <20100917172308.GA25515@fieldses.org> (raw)
In-Reply-To: <1284670903-28475-3-git-send-email-Trond.Myklebust@netapp.com>

On Thu, Sep 16, 2010 at 05:01:39PM -0400, Trond Myklebust wrote:
> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
> ---
>  fs/nfs/dir.c      |   21 +++++++++++++++------
>  fs/nfs/nfs4_fs.h  |    2 +-
>  fs/nfs/nfs4proc.c |   28 ++++------------------------
>  3 files changed, 20 insertions(+), 31 deletions(-)
> 
> diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
> index 17529b5..194676c 100644
> --- a/fs/nfs/dir.c
> +++ b/fs/nfs/dir.c
> @@ -1084,8 +1084,8 @@ static struct dentry *nfs_atomic_lookup(struct inode *dir, struct dentry *dentry
>  	struct nfs_open_context *ctx;
>  	struct iattr attr;
>  	struct dentry *res = NULL;
> +	struct inode *inode;
>  	int open_flags;
> -	int error;
>  
>  	dfprintk(VFS, "NFS: atomic_lookup(%s/%ld), %s\n",
>  			dir->i_sb->s_id, dir->i_ino, dentry->d_name.name);
> @@ -1125,13 +1125,15 @@ static struct dentry *nfs_atomic_lookup(struct inode *dir, struct dentry *dentry
>  	}
>  
>  	/* Open the file on the server */
> -	res = nfs4_atomic_open(dir, ctx, open_flags, &attr);
> -	if (IS_ERR(res)) {
> +	nfs_block_sillyrename(dentry->d_parent);

This looks like a bugfix, not just "minor cleanups"?

--b.

> +	inode = nfs4_atomic_open(dir, ctx, open_flags, &attr);
> +	if (IS_ERR(inode)) {
> +		nfs_unblock_sillyrename(dentry->d_parent);
>  		put_nfs_open_context(ctx);
> -		error = PTR_ERR(res);
> -		switch (error) {
> +		switch (PTR_ERR(inode)) {
>  			/* Make a negative dentry */
>  			case -ENOENT:
> +				d_add(dentry, NULL);
>  				res = NULL;
>  				goto out;
>  			/* This turned out not to be a regular file */
> @@ -1143,13 +1145,20 @@ static struct dentry *nfs_atomic_lookup(struct inode *dir, struct dentry *dentry
>  					goto no_open;
>  			/* case -EINVAL: */
>  			default:
> +				res = ERR_CAST(inode);
>  				goto out;
>  		}
>  	}
> -	if (res != NULL)
> +	res = d_add_unique(dentry, inode);
> +	if (res != NULL) {
> +		dput(ctx->path.dentry);
> +		ctx->path.dentry = dget(res);
>  		dentry = res;
> +	}
>  	nfs_intent_set_file(nd, ctx);
> +	nfs_unblock_sillyrename(dentry->d_parent);
>  out:
> +	nfs_set_verifier(dentry, nfs_save_change_attribute(dir));
>  	return res;
>  no_open:
>  	return nfs_lookup(dir, dentry, nd);
> diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h
> index c5cc2a6..8e1f639 100644
> --- a/fs/nfs/nfs4_fs.h
> +++ b/fs/nfs/nfs4_fs.h
> @@ -242,7 +242,7 @@ extern int nfs4_proc_renew(struct nfs_client *, struct rpc_cred *);
>  extern int nfs4_init_clientid(struct nfs_client *, struct rpc_cred *);
>  extern int nfs41_init_clientid(struct nfs_client *, struct rpc_cred *);
>  extern int nfs4_do_close(struct path *path, struct nfs4_state *state, gfp_t gfp_mask, int wait);
> -extern struct dentry *nfs4_atomic_open(struct inode *, struct nfs_open_context *, int, struct iattr *);
> +extern struct inode *nfs4_atomic_open(struct inode *, struct nfs_open_context *, int, struct iattr *);
>  extern int nfs4_open_revalidate(struct inode *, struct dentry *, int, struct nameidata *);
>  extern int nfs4_server_capabilities(struct nfs_server *server, struct nfs_fh *fhandle);
>  extern int nfs4_proc_fs_locations(struct inode *dir, const struct qstr *name,
> diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
> index 38c3bed..f8d41ee 100644
> --- a/fs/nfs/nfs4proc.c
> +++ b/fs/nfs/nfs4proc.c
> @@ -2024,37 +2024,17 @@ out_close:
>  	return ret;
>  }
>  
> -struct dentry *
> +struct inode *
>  nfs4_atomic_open(struct inode *dir, struct nfs_open_context *ctx, int open_flags, struct iattr *attr)
>  {
> -	struct dentry *dentry = ctx->path.dentry;
> -	struct dentry *parent;
>  	struct nfs4_state *state;
> -	struct dentry *res;
>  
> -	parent = dentry->d_parent;
>  	/* Protect against concurrent sillydeletes */
> -	nfs_block_sillyrename(parent);
>  	state = nfs4_do_open(dir, &ctx->path, ctx->mode, open_flags, attr, ctx->cred);
> -	if (IS_ERR(state)) {
> -		if (PTR_ERR(state) == -ENOENT) {
> -			d_add(dentry, NULL);
> -			nfs_set_verifier(dentry, nfs_save_change_attribute(dir));
> -		}
> -		nfs_unblock_sillyrename(parent);
> -		return (struct dentry *)state;
> -	}
> -	res = d_add_unique(dentry, igrab(state->inode));
> -	if (res != NULL) {
> -		struct dentry *dummy = ctx->path.dentry;
> -
> -		ctx->path.dentry = dget(res);
> -		dput(dummy);
> -	}
> +	if (IS_ERR(state))
> +		return ERR_CAST(state);
>  	ctx->state = state;
> -	nfs_set_verifier(ctx->path.dentry, nfs_save_change_attribute(dir));
> -	nfs_unblock_sillyrename(parent);
> -	return res;
> +	return igrab(state->inode);
>  }
>  
>  int
> -- 
> 1.7.2.3
> 
> --
> 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

      parent reply	other threads:[~2010-09-17 17:24 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-16 21:01 [PATCH 0/6] Remove struct nameidata from lower level NFS code Trond Myklebust
2010-09-16 21:01 ` [PATCH 1/6] NFSv4: Clean up nfs4_atomic_open Trond Myklebust
2010-09-16 21:01   ` [PATCH 2/6] NFSv4: Further minor cleanups for nfs4_atomic_open() Trond Myklebust
2010-09-16 21:01     ` [PATCH 3/6] NFSv4: Clean up nfs4_open_revalidate Trond Myklebust
2010-09-16 21:01       ` [PATCH 4/6] NFSv4: Further cleanups for nfs4_open_revalidate() Trond Myklebust
2010-09-16 21:01         ` [PATCH 5/6] NFS: Clean up nfs4_proc_create() Trond Myklebust
2010-09-16 21:01           ` [PATCH 6/6] NFS: Add an 'open_context' element to struct nfs_rpc_ops Trond Myklebust
2010-09-17 17:23     ` J. Bruce Fields [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=20100917172308.GA25515@fieldses.org \
    --to=bfields@fieldses.org \
    --cc=Trond.Myklebust@netapp.com \
    --cc=hch@infradead.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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).