diff options
author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2010-09-17 10:56:50 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2010-09-17 10:56:50 -0400 |
commit | f46e0bd34ec002d0727761da52b8fd47f06d4440 (patch) | |
tree | bb4ce4d00a9857b370765abf6faf89a09f4c4ff4 | |
parent | cd9a1c0e5ac681871d64804f82291649e2a0accb (diff) |
NFSv4: Further minor cleanups for nfs4_atomic_open()
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
-rw-r--r-- | fs/nfs/dir.c | 21 | ||||
-rw-r--r-- | fs/nfs/nfs4_fs.h | 2 | ||||
-rw-r--r-- | 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 17529b5bc551..194676cc5b04 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 | |||
1084 | struct nfs_open_context *ctx; | 1084 | struct nfs_open_context *ctx; |
1085 | struct iattr attr; | 1085 | struct iattr attr; |
1086 | struct dentry *res = NULL; | 1086 | struct dentry *res = NULL; |
1087 | struct inode *inode; | ||
1087 | int open_flags; | 1088 | int open_flags; |
1088 | int error; | ||
1089 | 1089 | ||
1090 | dfprintk(VFS, "NFS: atomic_lookup(%s/%ld), %s\n", | 1090 | dfprintk(VFS, "NFS: atomic_lookup(%s/%ld), %s\n", |
1091 | dir->i_sb->s_id, dir->i_ino, dentry->d_name.name); | 1091 | 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 | |||
1125 | } | 1125 | } |
1126 | 1126 | ||
1127 | /* Open the file on the server */ | 1127 | /* Open the file on the server */ |
1128 | res = nfs4_atomic_open(dir, ctx, open_flags, &attr); | 1128 | nfs_block_sillyrename(dentry->d_parent); |
1129 | if (IS_ERR(res)) { | 1129 | inode = nfs4_atomic_open(dir, ctx, open_flags, &attr); |
1130 | if (IS_ERR(inode)) { | ||
1131 | nfs_unblock_sillyrename(dentry->d_parent); | ||
1130 | put_nfs_open_context(ctx); | 1132 | put_nfs_open_context(ctx); |
1131 | error = PTR_ERR(res); | 1133 | switch (PTR_ERR(inode)) { |
1132 | switch (error) { | ||
1133 | /* Make a negative dentry */ | 1134 | /* Make a negative dentry */ |
1134 | case -ENOENT: | 1135 | case -ENOENT: |
1136 | d_add(dentry, NULL); | ||
1135 | res = NULL; | 1137 | res = NULL; |
1136 | goto out; | 1138 | goto out; |
1137 | /* This turned out not to be a regular file */ | 1139 | /* 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 | |||
1143 | goto no_open; | 1145 | goto no_open; |
1144 | /* case -EINVAL: */ | 1146 | /* case -EINVAL: */ |
1145 | default: | 1147 | default: |
1148 | res = ERR_CAST(inode); | ||
1146 | goto out; | 1149 | goto out; |
1147 | } | 1150 | } |
1148 | } | 1151 | } |
1149 | if (res != NULL) | 1152 | res = d_add_unique(dentry, inode); |
1153 | if (res != NULL) { | ||
1154 | dput(ctx->path.dentry); | ||
1155 | ctx->path.dentry = dget(res); | ||
1150 | dentry = res; | 1156 | dentry = res; |
1157 | } | ||
1151 | nfs_intent_set_file(nd, ctx); | 1158 | nfs_intent_set_file(nd, ctx); |
1159 | nfs_unblock_sillyrename(dentry->d_parent); | ||
1152 | out: | 1160 | out: |
1161 | nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); | ||
1153 | return res; | 1162 | return res; |
1154 | no_open: | 1163 | no_open: |
1155 | return nfs_lookup(dir, dentry, nd); | 1164 | return nfs_lookup(dir, dentry, nd); |
diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h index c5cc2a6aceb0..8e1f6396d3de 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 *); | |||
242 | extern int nfs4_init_clientid(struct nfs_client *, struct rpc_cred *); | 242 | extern int nfs4_init_clientid(struct nfs_client *, struct rpc_cred *); |
243 | extern int nfs41_init_clientid(struct nfs_client *, struct rpc_cred *); | 243 | extern int nfs41_init_clientid(struct nfs_client *, struct rpc_cred *); |
244 | extern int nfs4_do_close(struct path *path, struct nfs4_state *state, gfp_t gfp_mask, int wait); | 244 | extern int nfs4_do_close(struct path *path, struct nfs4_state *state, gfp_t gfp_mask, int wait); |
245 | extern struct dentry *nfs4_atomic_open(struct inode *, struct nfs_open_context *, int, struct iattr *); | 245 | extern struct inode *nfs4_atomic_open(struct inode *, struct nfs_open_context *, int, struct iattr *); |
246 | extern int nfs4_open_revalidate(struct inode *, struct dentry *, int, struct nameidata *); | 246 | extern int nfs4_open_revalidate(struct inode *, struct dentry *, int, struct nameidata *); |
247 | extern int nfs4_server_capabilities(struct nfs_server *server, struct nfs_fh *fhandle); | 247 | extern int nfs4_server_capabilities(struct nfs_server *server, struct nfs_fh *fhandle); |
248 | extern int nfs4_proc_fs_locations(struct inode *dir, const struct qstr *name, | 248 | 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 38c3bed2240d..f8d41eed9a6b 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c | |||
@@ -2024,37 +2024,17 @@ out_close: | |||
2024 | return ret; | 2024 | return ret; |
2025 | } | 2025 | } |
2026 | 2026 | ||
2027 | struct dentry * | 2027 | struct inode * |
2028 | nfs4_atomic_open(struct inode *dir, struct nfs_open_context *ctx, int open_flags, struct iattr *attr) | 2028 | nfs4_atomic_open(struct inode *dir, struct nfs_open_context *ctx, int open_flags, struct iattr *attr) |
2029 | { | 2029 | { |
2030 | struct dentry *dentry = ctx->path.dentry; | ||
2031 | struct dentry *parent; | ||
2032 | struct nfs4_state *state; | 2030 | struct nfs4_state *state; |
2033 | struct dentry *res; | ||
2034 | 2031 | ||
2035 | parent = dentry->d_parent; | ||
2036 | /* Protect against concurrent sillydeletes */ | 2032 | /* Protect against concurrent sillydeletes */ |
2037 | nfs_block_sillyrename(parent); | ||
2038 | state = nfs4_do_open(dir, &ctx->path, ctx->mode, open_flags, attr, ctx->cred); | 2033 | state = nfs4_do_open(dir, &ctx->path, ctx->mode, open_flags, attr, ctx->cred); |
2039 | if (IS_ERR(state)) { | 2034 | if (IS_ERR(state)) |
2040 | if (PTR_ERR(state) == -ENOENT) { | 2035 | return ERR_CAST(state); |
2041 | d_add(dentry, NULL); | ||
2042 | nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); | ||
2043 | } | ||
2044 | nfs_unblock_sillyrename(parent); | ||
2045 | return (struct dentry *)state; | ||
2046 | } | ||
2047 | res = d_add_unique(dentry, igrab(state->inode)); | ||
2048 | if (res != NULL) { | ||
2049 | struct dentry *dummy = ctx->path.dentry; | ||
2050 | |||
2051 | ctx->path.dentry = dget(res); | ||
2052 | dput(dummy); | ||
2053 | } | ||
2054 | ctx->state = state; | 2036 | ctx->state = state; |
2055 | nfs_set_verifier(ctx->path.dentry, nfs_save_change_attribute(dir)); | 2037 | return igrab(state->inode); |
2056 | nfs_unblock_sillyrename(parent); | ||
2057 | return res; | ||
2058 | } | 2038 | } |
2059 | 2039 | ||
2060 | int | 2040 | int |