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 /fs/nfs/dir.c | |
parent | cd9a1c0e5ac681871d64804f82291649e2a0accb (diff) |
NFSv4: Further minor cleanups for nfs4_atomic_open()
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/dir.c')
-rw-r--r-- | fs/nfs/dir.c | 21 |
1 files changed, 15 insertions, 6 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); |