Commit 3efb9722 authored by Trond Myklebust's avatar Trond Myklebust

NFSv4: Refactor _nfs4_open_and_get_state to set ctx->state

Instead of having the callers set ctx->state, do it inside
_nfs4_open_and_get_state.
Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
parent 4197a055
...@@ -1960,7 +1960,7 @@ static inline void nfs4_exclusive_attrset(struct nfs4_opendata *opendata, struct ...@@ -1960,7 +1960,7 @@ static inline void nfs4_exclusive_attrset(struct nfs4_opendata *opendata, struct
static int _nfs4_open_and_get_state(struct nfs4_opendata *opendata, static int _nfs4_open_and_get_state(struct nfs4_opendata *opendata,
fmode_t fmode, fmode_t fmode,
int flags, int flags,
struct nfs4_state **res) struct nfs_open_context *ctx)
{ {
struct nfs4_state_owner *sp = opendata->owner; struct nfs4_state_owner *sp = opendata->owner;
struct nfs_server *server = sp->so_server; struct nfs_server *server = sp->so_server;
...@@ -1985,9 +1985,9 @@ static int _nfs4_open_and_get_state(struct nfs4_opendata *opendata, ...@@ -1985,9 +1985,9 @@ static int _nfs4_open_and_get_state(struct nfs4_opendata *opendata,
if (ret != 0) if (ret != 0)
goto out; goto out;
ctx->state = state;
if (read_seqcount_retry(&sp->so_reclaim_seqcount, seq)) if (read_seqcount_retry(&sp->so_reclaim_seqcount, seq))
nfs4_schedule_stateid_recovery(server, state); nfs4_schedule_stateid_recovery(server, state);
*res = state;
out: out:
return ret; return ret;
} }
...@@ -1998,8 +1998,7 @@ static int _nfs4_open_and_get_state(struct nfs4_opendata *opendata, ...@@ -1998,8 +1998,7 @@ static int _nfs4_open_and_get_state(struct nfs4_opendata *opendata,
static int _nfs4_do_open(struct inode *dir, static int _nfs4_do_open(struct inode *dir,
struct nfs_open_context *ctx, struct nfs_open_context *ctx,
int flags, int flags,
struct iattr *sattr, struct iattr *sattr)
struct nfs4_state **res)
{ {
struct nfs4_state_owner *sp; struct nfs4_state_owner *sp;
struct nfs4_state *state = NULL; struct nfs4_state *state = NULL;
...@@ -2041,9 +2040,10 @@ static int _nfs4_do_open(struct inode *dir, ...@@ -2041,9 +2040,10 @@ static int _nfs4_do_open(struct inode *dir,
if (dentry->d_inode != NULL) if (dentry->d_inode != NULL)
opendata->state = nfs4_get_open_state(dentry->d_inode, sp); opendata->state = nfs4_get_open_state(dentry->d_inode, sp);
status = _nfs4_open_and_get_state(opendata, fmode, flags, &state); status = _nfs4_open_and_get_state(opendata, fmode, flags, ctx);
if (status != 0) if (status != 0)
goto err_opendata_put; goto err_opendata_put;
state = ctx->state;
if ((opendata->o_arg.open_flags & O_EXCL) && if ((opendata->o_arg.open_flags & O_EXCL) &&
(opendata->o_arg.createmode != NFS4_CREATE_GUARDED)) { (opendata->o_arg.createmode != NFS4_CREATE_GUARDED)) {
...@@ -2066,7 +2066,6 @@ static int _nfs4_do_open(struct inode *dir, ...@@ -2066,7 +2066,6 @@ static int _nfs4_do_open(struct inode *dir,
nfs4_opendata_put(opendata); nfs4_opendata_put(opendata);
nfs4_put_state_owner(sp); nfs4_put_state_owner(sp);
*res = state;
return 0; return 0;
err_opendata_put: err_opendata_put:
kfree(opendata->f_attr.mdsthreshold); kfree(opendata->f_attr.mdsthreshold);
...@@ -2074,7 +2073,6 @@ static int _nfs4_do_open(struct inode *dir, ...@@ -2074,7 +2073,6 @@ static int _nfs4_do_open(struct inode *dir,
err_put_state_owner: err_put_state_owner:
nfs4_put_state_owner(sp); nfs4_put_state_owner(sp);
out_err: out_err:
*res = NULL;
return status; return status;
} }
...@@ -2090,7 +2088,8 @@ static struct nfs4_state *nfs4_do_open(struct inode *dir, ...@@ -2090,7 +2088,8 @@ static struct nfs4_state *nfs4_do_open(struct inode *dir,
int status; int status;
do { do {
status = _nfs4_do_open(dir, ctx, flags, sattr, &res); status = _nfs4_do_open(dir, ctx, flags, sattr);
res = ctx->state;
if (status == 0) if (status == 0)
break; break;
/* NOTE: BAD_SEQID means the server and client disagree about the /* NOTE: BAD_SEQID means the server and client disagree about the
...@@ -2445,7 +2444,6 @@ nfs4_atomic_open(struct inode *dir, struct nfs_open_context *ctx, int open_flags ...@@ -2445,7 +2444,6 @@ nfs4_atomic_open(struct inode *dir, struct nfs_open_context *ctx, int open_flags
state = nfs4_do_open(dir, ctx, open_flags, attr); state = nfs4_do_open(dir, ctx, open_flags, attr);
if (IS_ERR(state)) if (IS_ERR(state))
return ERR_CAST(state); return ERR_CAST(state);
ctx->state = state;
return igrab(state->inode); return igrab(state->inode);
} }
...@@ -3059,7 +3057,6 @@ nfs4_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr, ...@@ -3059,7 +3057,6 @@ nfs4_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
} }
d_add(dentry, igrab(state->inode)); d_add(dentry, igrab(state->inode));
nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); nfs_set_verifier(dentry, nfs_save_change_attribute(dir));
ctx->state = state;
out: out:
put_nfs_open_context(ctx); put_nfs_open_context(ctx);
return status; return status;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment