diff options
author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2013-05-29 13:11:28 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2013-06-06 16:24:43 -0400 |
commit | 275bb307865a316cef390e01e6ab5e21e97023a2 (patch) | |
tree | fb7948a7d16dc90a8e6c8959757ae59fc8d21ea9 /fs/nfs/nfs4proc.c | |
parent | 3efb9722475e56c8878ce09395dd8ccb7a1a3611 (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/nfs4proc.c')
-rw-r--r-- | fs/nfs/nfs4proc.c | 21 |
1 files changed, 17 insertions, 4 deletions
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 | ||
2450 | static void nfs4_close_context(struct nfs_open_context *ctx, int is_sync) | 2466 | static 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)); | ||
3060 | out: | 3073 | out: |
3061 | put_nfs_open_context(ctx); | 3074 | put_nfs_open_context(ctx); |
3062 | return status; | 3075 | return status; |