aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2010-09-17 10:56:51 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2010-09-17 10:56:51 -0400
commit535918f14176396646b5547b7d1353c932f24f5e (patch)
tree0736137c736ac8c35cfbdd99a1de68eb556e4b4a /fs
parentb8d4caddd871758ffa156be51b4c8be82fea470d (diff)
NFSv4: Further cleanups for nfs4_open_revalidate()
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/nfs/dir.c32
-rw-r--r--fs/nfs/nfs4_fs.h1
-rw-r--r--fs/nfs/nfs4proc.c28
3 files changed, 26 insertions, 35 deletions
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index 196775c70948..dc93d356341b 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -1204,16 +1204,36 @@ static int nfs_open_revalidate(struct dentry *dentry, struct nameidata *nd)
1204 * operations that change the directory. We therefore save the 1204 * operations that change the directory. We therefore save the
1205 * change attribute *before* we do the RPC call. 1205 * change attribute *before* we do the RPC call.
1206 */ 1206 */
1207 ret = nfs4_open_revalidate(dir, ctx, openflags); 1207 inode = nfs4_atomic_open(dir, ctx, openflags, NULL);
1208 if (ret == 1) 1208 if (IS_ERR(inode)) {
1209 ret = PTR_ERR(inode);
1210 switch (ret) {
1211 case -EPERM:
1212 case -EACCES:
1213 case -EDQUOT:
1214 case -ENOSPC:
1215 case -EROFS:
1216 goto out_put_ctx;
1217 default:
1218 goto out_drop;
1219 }
1220 }
1221 iput(inode);
1222 if (inode == dentry->d_inode) {
1223 nfs_set_verifier(dentry, nfs_save_change_attribute(dir));
1209 nfs_intent_set_file(nd, ctx); 1224 nfs_intent_set_file(nd, ctx);
1210 else 1225 } else
1211 put_nfs_open_context(ctx); 1226 goto out_drop;
1212out: 1227out:
1213 dput(parent); 1228 dput(parent);
1214 if (!ret)
1215 d_drop(dentry);
1216 return ret; 1229 return ret;
1230out_drop:
1231 d_drop(dentry);
1232 ret = 0;
1233out_put_ctx:
1234 put_nfs_open_context(ctx);
1235 goto out;
1236
1217no_open_dput: 1237no_open_dput:
1218 dput(parent); 1238 dput(parent);
1219no_open: 1239no_open:
diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h
index 76ec1c6d92ac..6cf12ba9f4e7 100644
--- a/fs/nfs/nfs4_fs.h
+++ b/fs/nfs/nfs4_fs.h
@@ -243,7 +243,6 @@ extern int nfs4_init_clientid(struct nfs_client *, struct rpc_cred *);
243extern int nfs41_init_clientid(struct nfs_client *, struct rpc_cred *); 243extern int nfs41_init_clientid(struct nfs_client *, struct rpc_cred *);
244extern int nfs4_do_close(struct path *path, struct nfs4_state *state, gfp_t gfp_mask, int wait); 244extern int nfs4_do_close(struct path *path, struct nfs4_state *state, gfp_t gfp_mask, int wait);
245extern struct inode *nfs4_atomic_open(struct inode *, struct nfs_open_context *, int, struct iattr *); 245extern struct inode *nfs4_atomic_open(struct inode *, struct nfs_open_context *, int, struct iattr *);
246extern int nfs4_open_revalidate(struct inode *, struct nfs_open_context *, int);
247extern int nfs4_server_capabilities(struct nfs_server *server, struct nfs_fh *fhandle); 246extern int nfs4_server_capabilities(struct nfs_server *server, struct nfs_fh *fhandle);
248extern int nfs4_proc_fs_locations(struct inode *dir, const struct qstr *name, 247extern int nfs4_proc_fs_locations(struct inode *dir, const struct qstr *name,
249 struct nfs4_fs_locations *fs_locations, struct page *page); 248 struct nfs4_fs_locations *fs_locations, struct page *page);
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index b4762463b19f..83c5ef6e7cef 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -2037,34 +2037,6 @@ nfs4_atomic_open(struct inode *dir, struct nfs_open_context *ctx, int open_flags
2037 return igrab(state->inode); 2037 return igrab(state->inode);
2038} 2038}
2039 2039
2040int
2041nfs4_open_revalidate(struct inode *dir, struct nfs_open_context *ctx, int openflags)
2042{
2043 struct nfs4_state *state;
2044
2045 state = nfs4_do_open(dir, &ctx->path, ctx->mode, openflags, NULL, ctx->cred);
2046 if (IS_ERR(state)) {
2047 switch (PTR_ERR(state)) {
2048 case -EPERM:
2049 case -EACCES:
2050 case -EDQUOT:
2051 case -ENOSPC:
2052 case -EROFS:
2053 return PTR_ERR(state);
2054 default:
2055 goto out_drop;
2056 }
2057 }
2058 ctx->state = state;
2059 if (state->inode == ctx->path.dentry->d_inode) {
2060 nfs_set_verifier(ctx->path.dentry, nfs_save_change_attribute(dir));
2061 return 1;
2062 }
2063out_drop:
2064 d_drop(ctx->path.dentry);
2065 return 0;
2066}
2067
2068static void nfs4_close_context(struct nfs_open_context *ctx, int is_sync) 2040static void nfs4_close_context(struct nfs_open_context *ctx, int is_sync)
2069{ 2041{
2070 if (ctx->state == NULL) 2042 if (ctx->state == NULL)