提交 0667b1e9 编写于 作者: T Trond Myklebust 提交者: J. Bruce Fields

nfsd: Add reference counting to nfs4_preprocess_confirmed_seqid_op

Ensure that all the callers put the open stateid after use.
Necessary step toward client_mutex removal.
Signed-off-by: NTrond Myklebust <trond.myklebust@primarydata.com>
Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
上级 2585fc79
...@@ -4405,6 +4405,8 @@ static __be32 nfs4_preprocess_confirmed_seqid_op(struct nfsd4_compound_state *cs ...@@ -4405,6 +4405,8 @@ static __be32 nfs4_preprocess_confirmed_seqid_op(struct nfsd4_compound_state *cs
NFS4_OPEN_STID, stpp, nn); NFS4_OPEN_STID, stpp, nn);
if (status) if (status)
return status; return status;
/* FIXME: move into nfs4_preprocess_seqid_op */
atomic_inc(&(*stpp)->st_stid.sc_count);
oo = openowner((*stpp)->st_stateowner); oo = openowner((*stpp)->st_stateowner);
if (!(oo->oo_flags & NFS4_OO_CONFIRMED)) if (!(oo->oo_flags & NFS4_OO_CONFIRMED))
return nfserr_bad_stateid; return nfserr_bad_stateid;
...@@ -4509,12 +4511,12 @@ nfsd4_open_downgrade(struct svc_rqst *rqstp, ...@@ -4509,12 +4511,12 @@ nfsd4_open_downgrade(struct svc_rqst *rqstp,
if (!test_access(od->od_share_access, stp)) { if (!test_access(od->od_share_access, stp)) {
dprintk("NFSD: access not a subset of current bitmap: 0x%hhx, input access=%08x\n", dprintk("NFSD: access not a subset of current bitmap: 0x%hhx, input access=%08x\n",
stp->st_access_bmap, od->od_share_access); stp->st_access_bmap, od->od_share_access);
goto out; goto put_stateid;
} }
if (!test_deny(od->od_share_deny, stp)) { if (!test_deny(od->od_share_deny, stp)) {
dprintk("NFSD: deny not a subset of current bitmap: 0x%hhx, input deny=%08x\n", dprintk("NFSD: deny not a subset of current bitmap: 0x%hhx, input deny=%08x\n",
stp->st_deny_bmap, od->od_share_deny); stp->st_deny_bmap, od->od_share_deny);
goto out; goto put_stateid;
} }
nfs4_stateid_downgrade(stp, od->od_share_access); nfs4_stateid_downgrade(stp, od->od_share_access);
...@@ -4523,6 +4525,8 @@ nfsd4_open_downgrade(struct svc_rqst *rqstp, ...@@ -4523,6 +4525,8 @@ nfsd4_open_downgrade(struct svc_rqst *rqstp,
update_stateid(&stp->st_stid.sc_stateid); update_stateid(&stp->st_stid.sc_stateid);
memcpy(&od->od_stateid, &stp->st_stid.sc_stateid, sizeof(stateid_t)); memcpy(&od->od_stateid, &stp->st_stid.sc_stateid, sizeof(stateid_t));
status = nfs_ok; status = nfs_ok;
put_stateid:
nfs4_put_stid(&stp->st_stid);
out: out:
nfsd4_bump_seqid(cstate, status); nfsd4_bump_seqid(cstate, status);
if (!cstate->replay_owner) if (!cstate->replay_owner)
...@@ -4883,6 +4887,7 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, ...@@ -4883,6 +4887,7 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
struct nfs4_openowner *open_sop = NULL; struct nfs4_openowner *open_sop = NULL;
struct nfs4_lockowner *lock_sop = NULL; struct nfs4_lockowner *lock_sop = NULL;
struct nfs4_ol_stateid *lock_stp = NULL; struct nfs4_ol_stateid *lock_stp = NULL;
struct nfs4_ol_stateid *open_stp = NULL;
struct nfs4_file *fp; struct nfs4_file *fp;
struct file *filp = NULL; struct file *filp = NULL;
struct file_lock *file_lock = NULL; struct file_lock *file_lock = NULL;
...@@ -4910,8 +4915,6 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, ...@@ -4910,8 +4915,6 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
nfs4_lock_state(); nfs4_lock_state();
if (lock->lk_is_new) { if (lock->lk_is_new) {
struct nfs4_ol_stateid *open_stp = NULL;
if (nfsd4_has_session(cstate)) if (nfsd4_has_session(cstate))
/* See rfc 5661 18.10.3: given clientid is ignored: */ /* See rfc 5661 18.10.3: given clientid is ignored: */
memcpy(&lock->v.new.clientid, memcpy(&lock->v.new.clientid,
...@@ -5039,6 +5042,8 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, ...@@ -5039,6 +5042,8 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
fput(filp); fput(filp);
if (lock_stp) if (lock_stp)
nfs4_put_stid(&lock_stp->st_stid); nfs4_put_stid(&lock_stp->st_stid);
if (open_stp)
nfs4_put_stid(&open_stp->st_stid);
if (status && new_state) if (status && new_state)
release_lock_stateid(lock_stp); release_lock_stateid(lock_stp);
nfsd4_bump_seqid(cstate, status); nfsd4_bump_seqid(cstate, status);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册