diff options
author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2010-09-17 10:56:51 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2010-09-17 10:56:51 -0400 |
commit | b8d4caddd871758ffa156be51b4c8be82fea470d (patch) | |
tree | c388304ca2f1163b2737409ccc4cbc2d29ad3f41 /fs/nfs | |
parent | f46e0bd34ec002d0727761da52b8fd47f06d4440 (diff) |
NFSv4: Clean up nfs4_open_revalidate
Remove references to 'struct nameidata' from the low-level open_revalidate
code, and replace them with a struct nfs_open_context which will be
correctly initialised upon success.
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs')
-rw-r--r-- | fs/nfs/dir.c | 11 | ||||
-rw-r--r-- | fs/nfs/nfs4_fs.h | 2 | ||||
-rw-r--r-- | fs/nfs/nfs4proc.c | 23 |
3 files changed, 17 insertions, 19 deletions
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 194676cc5b04..196775c70948 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c | |||
@@ -1169,6 +1169,7 @@ static int nfs_open_revalidate(struct dentry *dentry, struct nameidata *nd) | |||
1169 | struct dentry *parent = NULL; | 1169 | struct dentry *parent = NULL; |
1170 | struct inode *inode = dentry->d_inode; | 1170 | struct inode *inode = dentry->d_inode; |
1171 | struct inode *dir; | 1171 | struct inode *dir; |
1172 | struct nfs_open_context *ctx; | ||
1172 | int openflags, ret = 0; | 1173 | int openflags, ret = 0; |
1173 | 1174 | ||
1174 | if (!is_atomic_open(nd) || d_mountpoint(dentry)) | 1175 | if (!is_atomic_open(nd) || d_mountpoint(dentry)) |
@@ -1194,12 +1195,20 @@ static int nfs_open_revalidate(struct dentry *dentry, struct nameidata *nd) | |||
1194 | /* We can't create new files, or truncate existing ones here */ | 1195 | /* We can't create new files, or truncate existing ones here */ |
1195 | openflags &= ~(O_CREAT|O_EXCL|O_TRUNC); | 1196 | openflags &= ~(O_CREAT|O_EXCL|O_TRUNC); |
1196 | 1197 | ||
1198 | ctx = nameidata_to_nfs_open_context(dentry, nd); | ||
1199 | ret = PTR_ERR(ctx); | ||
1200 | if (IS_ERR(ctx)) | ||
1201 | goto out; | ||
1197 | /* | 1202 | /* |
1198 | * Note: we're not holding inode->i_mutex and so may be racing with | 1203 | * Note: we're not holding inode->i_mutex and so may be racing with |
1199 | * operations that change the directory. We therefore save the | 1204 | * operations that change the directory. We therefore save the |
1200 | * change attribute *before* we do the RPC call. | 1205 | * change attribute *before* we do the RPC call. |
1201 | */ | 1206 | */ |
1202 | ret = nfs4_open_revalidate(dir, dentry, openflags, nd); | 1207 | ret = nfs4_open_revalidate(dir, ctx, openflags); |
1208 | if (ret == 1) | ||
1209 | nfs_intent_set_file(nd, ctx); | ||
1210 | else | ||
1211 | put_nfs_open_context(ctx); | ||
1203 | out: | 1212 | out: |
1204 | dput(parent); | 1213 | dput(parent); |
1205 | if (!ret) | 1214 | if (!ret) |
diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h index 8e1f6396d3de..76ec1c6d92ac 100644 --- a/fs/nfs/nfs4_fs.h +++ b/fs/nfs/nfs4_fs.h | |||
@@ -243,7 +243,7 @@ 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 inode *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 nfs_open_context *, int); |
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, |
249 | struct nfs4_fs_locations *fs_locations, struct page *page); | 249 | struct nfs4_fs_locations *fs_locations, struct page *page); |
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index f8d41eed9a6b..b4762463b19f 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c | |||
@@ -2038,21 +2038,11 @@ nfs4_atomic_open(struct inode *dir, struct nfs_open_context *ctx, int open_flags | |||
2038 | } | 2038 | } |
2039 | 2039 | ||
2040 | int | 2040 | int |
2041 | nfs4_open_revalidate(struct inode *dir, struct dentry *dentry, int openflags, struct nameidata *nd) | 2041 | nfs4_open_revalidate(struct inode *dir, struct nfs_open_context *ctx, int openflags) |
2042 | { | 2042 | { |
2043 | struct path path = { | ||
2044 | .mnt = nd->path.mnt, | ||
2045 | .dentry = dentry, | ||
2046 | }; | ||
2047 | struct rpc_cred *cred; | ||
2048 | struct nfs4_state *state; | 2043 | struct nfs4_state *state; |
2049 | fmode_t fmode = openflags & (FMODE_READ | FMODE_WRITE); | ||
2050 | 2044 | ||
2051 | cred = rpc_lookup_cred(); | 2045 | state = nfs4_do_open(dir, &ctx->path, ctx->mode, openflags, NULL, ctx->cred); |
2052 | if (IS_ERR(cred)) | ||
2053 | return PTR_ERR(cred); | ||
2054 | state = nfs4_do_open(dir, &path, fmode, openflags, NULL, cred); | ||
2055 | put_rpccred(cred); | ||
2056 | if (IS_ERR(state)) { | 2046 | if (IS_ERR(state)) { |
2057 | switch (PTR_ERR(state)) { | 2047 | switch (PTR_ERR(state)) { |
2058 | case -EPERM: | 2048 | case -EPERM: |
@@ -2065,14 +2055,13 @@ nfs4_open_revalidate(struct inode *dir, struct dentry *dentry, int openflags, st | |||
2065 | goto out_drop; | 2055 | goto out_drop; |
2066 | } | 2056 | } |
2067 | } | 2057 | } |
2068 | if (state->inode == dentry->d_inode) { | 2058 | ctx->state = state; |
2069 | nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); | 2059 | if (state->inode == ctx->path.dentry->d_inode) { |
2070 | nfs4_intent_set_file(nd, &path, state, fmode); | 2060 | nfs_set_verifier(ctx->path.dentry, nfs_save_change_attribute(dir)); |
2071 | return 1; | 2061 | return 1; |
2072 | } | 2062 | } |
2073 | nfs4_close_sync(&path, state, fmode); | ||
2074 | out_drop: | 2063 | out_drop: |
2075 | d_drop(dentry); | 2064 | d_drop(ctx->path.dentry); |
2076 | return 0; | 2065 | return 0; |
2077 | } | 2066 | } |
2078 | 2067 | ||