aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/nfs4proc.c
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2010-09-17 10:56:50 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2010-09-17 10:56:50 -0400
commitcd9a1c0e5ac681871d64804f82291649e2a0accb (patch)
tree900c2bf6ba75c2a02af07091afcf4ba4cfdb2396 /fs/nfs/nfs4proc.c
parent859d5024f450686ad0a42ed3c06f2fa20295c9e6 (diff)
NFSv4: Clean up nfs4_atomic_open
Start moving the 'struct nameidata' dependent code out of the lower level NFS code in preparation for the removal of open intents. Instead of the struct nameidata, we pass down a partially initialised struct nfs_open_context that will be fully initialised by the atomic open upon success. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/nfs4proc.c')
-rw-r--r--fs/nfs/nfs4proc.c40
1 files changed, 11 insertions, 29 deletions
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 089da5b5d20a..38c3bed2240d 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -2025,39 +2025,17 @@ out_close:
2025} 2025}
2026 2026
2027struct dentry * 2027struct dentry *
2028nfs4_atomic_open(struct inode *dir, struct dentry *dentry, struct nameidata *nd) 2028nfs4_atomic_open(struct inode *dir, struct nfs_open_context *ctx, int open_flags, struct iattr *attr)
2029{ 2029{
2030 struct path path = { 2030 struct dentry *dentry = ctx->path.dentry;
2031 .mnt = nd->path.mnt,
2032 .dentry = dentry,
2033 };
2034 struct dentry *parent; 2031 struct dentry *parent;
2035 struct iattr attr;
2036 struct rpc_cred *cred;
2037 struct nfs4_state *state; 2032 struct nfs4_state *state;
2038 struct dentry *res; 2033 struct dentry *res;
2039 int open_flags = nd->intent.open.flags;
2040 fmode_t fmode = open_flags & (FMODE_READ | FMODE_WRITE | FMODE_EXEC);
2041
2042 if (nd->flags & LOOKUP_CREATE) {
2043 attr.ia_mode = nd->intent.open.create_mode;
2044 attr.ia_valid = ATTR_MODE;
2045 if (!IS_POSIXACL(dir))
2046 attr.ia_mode &= ~current_umask();
2047 } else {
2048 open_flags &= ~O_EXCL;
2049 attr.ia_valid = 0;
2050 BUG_ON(open_flags & O_CREAT);
2051 }
2052 2034
2053 cred = rpc_lookup_cred();
2054 if (IS_ERR(cred))
2055 return (struct dentry *)cred;
2056 parent = dentry->d_parent; 2035 parent = dentry->d_parent;
2057 /* Protect against concurrent sillydeletes */ 2036 /* Protect against concurrent sillydeletes */
2058 nfs_block_sillyrename(parent); 2037 nfs_block_sillyrename(parent);
2059 state = nfs4_do_open(dir, &path, fmode, open_flags, &attr, cred); 2038 state = nfs4_do_open(dir, &ctx->path, ctx->mode, open_flags, attr, ctx->cred);
2060 put_rpccred(cred);
2061 if (IS_ERR(state)) { 2039 if (IS_ERR(state)) {
2062 if (PTR_ERR(state) == -ENOENT) { 2040 if (PTR_ERR(state) == -ENOENT) {
2063 d_add(dentry, NULL); 2041 d_add(dentry, NULL);
@@ -2067,11 +2045,15 @@ nfs4_atomic_open(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
2067 return (struct dentry *)state; 2045 return (struct dentry *)state;
2068 } 2046 }
2069 res = d_add_unique(dentry, igrab(state->inode)); 2047 res = d_add_unique(dentry, igrab(state->inode));
2070 if (res != NULL) 2048 if (res != NULL) {
2071 path.dentry = res; 2049 struct dentry *dummy = ctx->path.dentry;
2072 nfs_set_verifier(path.dentry, nfs_save_change_attribute(dir)); 2050
2051 ctx->path.dentry = dget(res);
2052 dput(dummy);
2053 }
2054 ctx->state = state;
2055 nfs_set_verifier(ctx->path.dentry, nfs_save_change_attribute(dir));
2073 nfs_unblock_sillyrename(parent); 2056 nfs_unblock_sillyrename(parent);
2074 nfs4_intent_set_file(nd, &path, state, fmode);
2075 return res; 2057 return res;
2076} 2058}
2077 2059