]> git.karo-electronics.de Git - mv-sheeva.git/commitdiff
NFSv4: Further minor cleanups for nfs4_atomic_open()
authorTrond Myklebust <Trond.Myklebust@netapp.com>
Fri, 17 Sep 2010 14:56:50 +0000 (10:56 -0400)
committerTrond Myklebust <Trond.Myklebust@netapp.com>
Fri, 17 Sep 2010 14:56:50 +0000 (10:56 -0400)
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
fs/nfs/dir.c
fs/nfs/nfs4_fs.h
fs/nfs/nfs4proc.c

index 17529b5bc551c8c55cbddb788ba4eb4b9b82cb6b..194676cc5b0457a174e70013e7f7661a048b05fd 100644 (file)
@@ -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);
+       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);
index c5cc2a6aceb0d2eefec10796be7a1e69e431e09b..8e1f6396d3def66cc13c6de3f81b97d1f7f0f6fa 100644 (file)
@@ -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,
index 38c3bed2240de9f204e9bc6597ad1ff94989a25f..f8d41eed9a6bee49ea629b64559ea7a9c457c9fb 100644 (file)
@@ -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