提交 882e9d25 编写于 作者: J Jeff Layton 提交者: J. Bruce Fields

nfsd: clean up and reorganize release_lockowner

Do more within the main loop, and simplify the function a bit. Also,
there's no need to take a stateowner reference unless we're going to call
release_lockowner.
Signed-off-by: NJeff Layton <jlayton@primarydata.com>
Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
上级 d4f0489f
...@@ -5424,8 +5424,8 @@ nfsd4_release_lockowner(struct svc_rqst *rqstp, ...@@ -5424,8 +5424,8 @@ nfsd4_release_lockowner(struct svc_rqst *rqstp,
struct nfsd4_release_lockowner *rlockowner) struct nfsd4_release_lockowner *rlockowner)
{ {
clientid_t *clid = &rlockowner->rl_clientid; clientid_t *clid = &rlockowner->rl_clientid;
struct nfs4_stateowner *sop = NULL, *tmp; struct nfs4_stateowner *sop;
struct nfs4_lockowner *lo; struct nfs4_lockowner *lo = NULL;
struct nfs4_ol_stateid *stp; struct nfs4_ol_stateid *stp;
struct xdr_netobj *owner = &rlockowner->rl_owner; struct xdr_netobj *owner = &rlockowner->rl_owner;
unsigned int hashval = ownerstr_hashval(owner); unsigned int hashval = ownerstr_hashval(owner);
...@@ -5442,45 +5442,32 @@ nfsd4_release_lockowner(struct svc_rqst *rqstp, ...@@ -5442,45 +5442,32 @@ nfsd4_release_lockowner(struct svc_rqst *rqstp,
if (status) if (status)
goto out; goto out;
status = nfserr_locks_held;
clp = cstate->clp; clp = cstate->clp;
/* Find the matching lock stateowner */ /* Find the matching lock stateowner */
spin_lock(&clp->cl_lock); spin_lock(&clp->cl_lock);
list_for_each_entry(tmp, &clp->cl_ownerstr_hashtbl[hashval], list_for_each_entry(sop, &clp->cl_ownerstr_hashtbl[hashval],
so_strhash) { so_strhash) {
if (tmp->so_is_open_owner)
continue;
if (same_owner_str(tmp, owner)) {
sop = tmp;
atomic_inc(&sop->so_count);
break;
}
}
/* No matching owner found, maybe a replay? Just declare victory... */ if (sop->so_is_open_owner || !same_owner_str(sop, owner))
if (!sop) { continue;
spin_unlock(&clp->cl_lock);
status = nfs_ok;
goto out;
}
lo = lockowner(sop); /* see if there are still any locks associated with it */
/* see if there are still any locks associated with it */ lo = lockowner(sop);
list_for_each_entry(stp, &sop->so_stateids, st_perstateowner) { list_for_each_entry(stp, &sop->so_stateids, st_perstateowner) {
if (check_for_locks(stp->st_stid.sc_file, lo)) { if (check_for_locks(stp->st_stid.sc_file, lo)) {
spin_unlock(&clp->cl_lock); status = nfserr_locks_held;
goto out; spin_unlock(&clp->cl_lock);
goto out;
}
} }
atomic_inc(&sop->so_count);
break;
} }
spin_unlock(&clp->cl_lock); spin_unlock(&clp->cl_lock);
if (lo)
status = nfs_ok; release_lockowner(lo);
sop = NULL;
release_lockowner(lo);
out: out:
if (sop)
nfs4_put_stateowner(sop);
nfs4_unlock_state(); nfs4_unlock_state();
return status; return status;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册