aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2013-05-29 13:11:28 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2013-06-06 16:24:43 -0400
commit275bb307865a316cef390e01e6ab5e21e97023a2 (patch)
treefb7948a7d16dc90a8e6c8959757ae59fc8d21ea9 /fs/nfs
parent3efb9722475e56c8878ce09395dd8ccb7a1a3611 (diff)
NFSv4: Move dentry instantiation into the NFSv4-specific atomic open code
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs')
-rw-r--r--fs/nfs/dir.c19
-rw-r--r--fs/nfs/nfs4file.c1
-rw-r--r--fs/nfs/nfs4proc.c21
3 files changed, 20 insertions, 21 deletions
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index bf4e5f47d686..c662ff6befd6 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -1357,11 +1357,6 @@ static int nfs_finish_open(struct nfs_open_context *ctx,
1357{ 1357{
1358 int err; 1358 int err;
1359 1359
1360 if (ctx->dentry != dentry) {
1361 dput(ctx->dentry);
1362 ctx->dentry = dget(dentry);
1363 }
1364
1365 err = finish_open(file, dentry, do_open, opened); 1360 err = finish_open(file, dentry, do_open, opened);
1366 if (err) 1361 if (err)
1367 goto out; 1362 goto out;
@@ -1420,13 +1415,13 @@ int nfs_atomic_open(struct inode *dir, struct dentry *dentry,
1420 1415
1421 nfs_block_sillyrename(dentry->d_parent); 1416 nfs_block_sillyrename(dentry->d_parent);
1422 inode = NFS_PROTO(dir)->open_context(dir, ctx, open_flags, &attr); 1417 inode = NFS_PROTO(dir)->open_context(dir, ctx, open_flags, &attr);
1423 d_drop(dentry); 1418 nfs_unblock_sillyrename(dentry->d_parent);
1424 if (IS_ERR(inode)) { 1419 if (IS_ERR(inode)) {
1425 nfs_unblock_sillyrename(dentry->d_parent);
1426 put_nfs_open_context(ctx); 1420 put_nfs_open_context(ctx);
1427 err = PTR_ERR(inode); 1421 err = PTR_ERR(inode);
1428 switch (err) { 1422 switch (err) {
1429 case -ENOENT: 1423 case -ENOENT:
1424 d_drop(dentry);
1430 d_add(dentry, NULL); 1425 d_add(dentry, NULL);
1431 break; 1426 break;
1432 case -EISDIR: 1427 case -EISDIR:
@@ -1442,16 +1437,8 @@ int nfs_atomic_open(struct inode *dir, struct dentry *dentry,
1442 } 1437 }
1443 goto out; 1438 goto out;
1444 } 1439 }
1445 res = d_add_unique(dentry, inode);
1446 if (res != NULL)
1447 dentry = res;
1448
1449 nfs_unblock_sillyrename(dentry->d_parent);
1450 nfs_set_verifier(dentry, nfs_save_change_attribute(dir));
1451
1452 err = nfs_finish_open(ctx, dentry, file, open_flags, opened);
1453 1440
1454 dput(res); 1441 err = nfs_finish_open(ctx, ctx->dentry, file, open_flags, opened);
1455out: 1442out:
1456 return err; 1443 return err;
1457 1444
diff --git a/fs/nfs/nfs4file.c b/fs/nfs/nfs4file.c
index 13e6bb3e3fe5..e5b804dd944c 100644
--- a/fs/nfs/nfs4file.c
+++ b/fs/nfs/nfs4file.c
@@ -69,7 +69,6 @@ nfs4_file_open(struct inode *inode, struct file *filp)
69 goto out_drop; 69 goto out_drop;
70 } 70 }
71 } 71 }
72 iput(inode);
73 if (inode != dentry->d_inode) 72 if (inode != dentry->d_inode)
74 goto out_drop; 73 goto out_drop;
75 74
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 70f378f071d8..aaf2c1324be7 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -1964,6 +1964,7 @@ static int _nfs4_open_and_get_state(struct nfs4_opendata *opendata,
1964{ 1964{
1965 struct nfs4_state_owner *sp = opendata->owner; 1965 struct nfs4_state_owner *sp = opendata->owner;
1966 struct nfs_server *server = sp->so_server; 1966 struct nfs_server *server = sp->so_server;
1967 struct dentry *dentry;
1967 struct nfs4_state *state; 1968 struct nfs4_state *state;
1968 unsigned int seq; 1969 unsigned int seq;
1969 int ret; 1970 int ret;
@@ -1981,6 +1982,21 @@ static int _nfs4_open_and_get_state(struct nfs4_opendata *opendata,
1981 if (server->caps & NFS_CAP_POSIX_LOCK) 1982 if (server->caps & NFS_CAP_POSIX_LOCK)
1982 set_bit(NFS_STATE_POSIX_LOCKS, &state->flags); 1983 set_bit(NFS_STATE_POSIX_LOCKS, &state->flags);
1983 1984
1985 dentry = opendata->dentry;
1986 if (dentry->d_inode == NULL) {
1987 /* FIXME: Is this d_drop() ever needed? */
1988 d_drop(dentry);
1989 dentry = d_add_unique(dentry, igrab(state->inode));
1990 if (dentry == NULL) {
1991 dentry = opendata->dentry;
1992 } else if (dentry != ctx->dentry) {
1993 dput(ctx->dentry);
1994 ctx->dentry = dget(dentry);
1995 }
1996 nfs_set_verifier(dentry,
1997 nfs_save_change_attribute(opendata->dir->d_inode));
1998 }
1999
1984 ret = nfs4_opendata_access(sp->so_cred, opendata, state, fmode, flags); 2000 ret = nfs4_opendata_access(sp->so_cred, opendata, state, fmode, flags);
1985 if (ret != 0) 2001 if (ret != 0)
1986 goto out; 2002 goto out;
@@ -2444,7 +2460,7 @@ nfs4_atomic_open(struct inode *dir, struct nfs_open_context *ctx, int open_flags
2444 state = nfs4_do_open(dir, ctx, open_flags, attr); 2460 state = nfs4_do_open(dir, ctx, open_flags, attr);
2445 if (IS_ERR(state)) 2461 if (IS_ERR(state))
2446 return ERR_CAST(state); 2462 return ERR_CAST(state);
2447 return igrab(state->inode); 2463 return state->inode;
2448} 2464}
2449 2465
2450static void nfs4_close_context(struct nfs_open_context *ctx, int is_sync) 2466static void nfs4_close_context(struct nfs_open_context *ctx, int is_sync)
@@ -3050,13 +3066,10 @@ nfs4_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
3050 3066
3051 sattr->ia_mode &= ~current_umask(); 3067 sattr->ia_mode &= ~current_umask();
3052 state = nfs4_do_open(dir, ctx, flags, sattr); 3068 state = nfs4_do_open(dir, ctx, flags, sattr);
3053 d_drop(dentry);
3054 if (IS_ERR(state)) { 3069 if (IS_ERR(state)) {
3055 status = PTR_ERR(state); 3070 status = PTR_ERR(state);
3056 goto out; 3071 goto out;
3057 } 3072 }
3058 d_add(dentry, igrab(state->inode));
3059 nfs_set_verifier(dentry, nfs_save_change_attribute(dir));
3060out: 3073out:
3061 put_nfs_open_context(ctx); 3074 put_nfs_open_context(ctx);
3062 return status; 3075 return status;