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 | c0204fd2b8fe047b18b67e07e1bf2a03691240cd (patch) | |
tree | d6cf75bc11d08f190c0757ba98b5ae6baef49402 /fs/nfs/dir.c | |
parent | 535918f14176396646b5547b7d1353c932f24f5e (diff) |
NFS: Clean up nfs4_proc_create()
Remove all remaining references to the struct nameidata from the low level
NFS layers. Again pass down a partially initialised struct nfs_open_context
when we want to do atomic open+create.
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/dir.c')
-rw-r--r-- | fs/nfs/dir.c | 47 |
1 files changed, 41 insertions, 6 deletions
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index dc93d356341b..e37ffddd79c2 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c | |||
@@ -105,8 +105,9 @@ const struct inode_operations nfs3_dir_inode_operations = { | |||
105 | #ifdef CONFIG_NFS_V4 | 105 | #ifdef CONFIG_NFS_V4 |
106 | 106 | ||
107 | static struct dentry *nfs_atomic_lookup(struct inode *, struct dentry *, struct nameidata *); | 107 | static struct dentry *nfs_atomic_lookup(struct inode *, struct dentry *, struct nameidata *); |
108 | static int nfs_open_create(struct inode *dir, struct dentry *dentry, int mode, struct nameidata *nd); | ||
108 | const struct inode_operations nfs4_dir_inode_operations = { | 109 | const struct inode_operations nfs4_dir_inode_operations = { |
109 | .create = nfs_create, | 110 | .create = nfs_open_create, |
110 | .lookup = nfs_atomic_lookup, | 111 | .lookup = nfs_atomic_lookup, |
111 | .link = nfs_link, | 112 | .link = nfs_link, |
112 | .unlink = nfs_unlink, | 113 | .unlink = nfs_unlink, |
@@ -1239,6 +1240,44 @@ no_open_dput: | |||
1239 | no_open: | 1240 | no_open: |
1240 | return nfs_lookup_revalidate(dentry, nd); | 1241 | return nfs_lookup_revalidate(dentry, nd); |
1241 | } | 1242 | } |
1243 | |||
1244 | static int nfs_open_create(struct inode *dir, struct dentry *dentry, int mode, | ||
1245 | struct nameidata *nd) | ||
1246 | { | ||
1247 | struct nfs_open_context *ctx = NULL; | ||
1248 | struct iattr attr; | ||
1249 | int error; | ||
1250 | int open_flags = 0; | ||
1251 | |||
1252 | dfprintk(VFS, "NFS: create(%s/%ld), %s\n", | ||
1253 | dir->i_sb->s_id, dir->i_ino, dentry->d_name.name); | ||
1254 | |||
1255 | attr.ia_mode = mode; | ||
1256 | attr.ia_valid = ATTR_MODE; | ||
1257 | |||
1258 | if ((nd->flags & LOOKUP_CREATE) != 0) { | ||
1259 | open_flags = nd->intent.open.flags; | ||
1260 | |||
1261 | ctx = nameidata_to_nfs_open_context(dentry, nd); | ||
1262 | error = PTR_ERR(ctx); | ||
1263 | if (IS_ERR(ctx)) | ||
1264 | goto out_err; | ||
1265 | } | ||
1266 | |||
1267 | error = NFS_PROTO(dir)->create(dir, dentry, &attr, open_flags, ctx); | ||
1268 | if (error != 0) | ||
1269 | goto out_put_ctx; | ||
1270 | if (ctx != NULL) | ||
1271 | nfs_intent_set_file(nd, ctx); | ||
1272 | return 0; | ||
1273 | out_put_ctx: | ||
1274 | if (ctx != NULL) | ||
1275 | put_nfs_open_context(ctx); | ||
1276 | out_err: | ||
1277 | d_drop(dentry); | ||
1278 | return error; | ||
1279 | } | ||
1280 | |||
1242 | #endif /* CONFIG_NFSV4 */ | 1281 | #endif /* CONFIG_NFSV4 */ |
1243 | 1282 | ||
1244 | static struct dentry *nfs_readdir_lookup(nfs_readdir_descriptor_t *desc) | 1283 | static struct dentry *nfs_readdir_lookup(nfs_readdir_descriptor_t *desc) |
@@ -1369,7 +1408,6 @@ static int nfs_create(struct inode *dir, struct dentry *dentry, int mode, | |||
1369 | { | 1408 | { |
1370 | struct iattr attr; | 1409 | struct iattr attr; |
1371 | int error; | 1410 | int error; |
1372 | int open_flags = 0; | ||
1373 | 1411 | ||
1374 | dfprintk(VFS, "NFS: create(%s/%ld), %s\n", | 1412 | dfprintk(VFS, "NFS: create(%s/%ld), %s\n", |
1375 | dir->i_sb->s_id, dir->i_ino, dentry->d_name.name); | 1413 | dir->i_sb->s_id, dir->i_ino, dentry->d_name.name); |
@@ -1377,10 +1415,7 @@ static int nfs_create(struct inode *dir, struct dentry *dentry, int mode, | |||
1377 | attr.ia_mode = mode; | 1415 | attr.ia_mode = mode; |
1378 | attr.ia_valid = ATTR_MODE; | 1416 | attr.ia_valid = ATTR_MODE; |
1379 | 1417 | ||
1380 | if ((nd->flags & LOOKUP_CREATE) != 0) | 1418 | error = NFS_PROTO(dir)->create(dir, dentry, &attr, 0, NULL); |
1381 | open_flags = nd->intent.open.flags; | ||
1382 | |||
1383 | error = NFS_PROTO(dir)->create(dir, dentry, &attr, open_flags, nd); | ||
1384 | if (error != 0) | 1419 | if (error != 0) |
1385 | goto out_err; | 1420 | goto out_err; |
1386 | return 0; | 1421 | return 0; |