Skip to content

Commit

Permalink
NFSv4: Refactor _nfs4_open_and_get_state to set ctx->state
Browse files Browse the repository at this point in the history
Instead of having the callers set ctx->state, do it inside
_nfs4_open_and_get_state.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
  • Loading branch information
Trond Myklebust authored and Trond Myklebust committed Jun 6, 2013
1 parent 4197a05 commit 3efb972
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions fs/nfs/nfs4proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
fmode_t fmode,
int flags,
struct nfs4_state **res)
struct nfs_open_context *ctx)
{
struct nfs4_state_owner *sp = opendata->owner;
struct nfs_server *server = sp->so_server;
Expand All @@ -1985,9 +1985,9 @@ static int _nfs4_open_and_get_state(struct nfs4_opendata *opendata,
if (ret != 0)
goto out;

ctx->state = state;
if (read_seqcount_retry(&sp->so_reclaim_seqcount, seq))
nfs4_schedule_stateid_recovery(server, state);
*res = state;
out:
return ret;
}
Expand All @@ -1998,8 +1998,7 @@ static int _nfs4_open_and_get_state(struct nfs4_opendata *opendata,
static int _nfs4_do_open(struct inode *dir,
struct nfs_open_context *ctx,
int flags,
struct iattr *sattr,
struct nfs4_state **res)
struct iattr *sattr)
{
struct nfs4_state_owner *sp;
struct nfs4_state *state = NULL;
Expand Down Expand Up @@ -2041,9 +2040,10 @@ static int _nfs4_do_open(struct inode *dir,
if (dentry->d_inode != NULL)
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)
goto err_opendata_put;
state = ctx->state;

if ((opendata->o_arg.open_flags & O_EXCL) &&
(opendata->o_arg.createmode != NFS4_CREATE_GUARDED)) {
Expand All @@ -2066,15 +2066,13 @@ static int _nfs4_do_open(struct inode *dir,

nfs4_opendata_put(opendata);
nfs4_put_state_owner(sp);
*res = state;
return 0;
err_opendata_put:
kfree(opendata->f_attr.mdsthreshold);
nfs4_opendata_put(opendata);
err_put_state_owner:
nfs4_put_state_owner(sp);
out_err:
*res = NULL;
return status;
}

Expand All @@ -2090,7 +2088,8 @@ static struct nfs4_state *nfs4_do_open(struct inode *dir,
int status;

do {
status = _nfs4_do_open(dir, ctx, flags, sattr, &res);
status = _nfs4_do_open(dir, ctx, flags, sattr);
res = ctx->state;
if (status == 0)
break;
/* NOTE: BAD_SEQID means the server and client disagree about the
Expand Down Expand Up @@ -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);
if (IS_ERR(state))
return ERR_CAST(state);
ctx->state = state;
return igrab(state->inode);
}

Expand Down Expand Up @@ -3059,7 +3057,6 @@ nfs4_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
}
d_add(dentry, igrab(state->inode));
nfs_set_verifier(dentry, nfs_save_change_attribute(dir));
ctx->state = state;
out:
put_nfs_open_context(ctx);
return status;
Expand Down

0 comments on commit 3efb972

Please sign in to comment.