summaryrefslogtreecommitdiff
path: root/fs/nfsd/nfs4state.c
diff options
context:
space:
mode:
authorJeff Layton <jlayton@primarydata.com>2014-07-30 05:34:37 +0400
committerJ. Bruce Fields <bfields@redhat.com>2014-07-31 22:20:27 +0400
commit882e9d25e11d644b24e578866c688d3f8f0d3712 (patch)
tree06f0f66a6f78fd2f93d326dd81af0da143b15ab0 /fs/nfsd/nfs4state.c
parentd4f0489f38512027fdf5190d5d1d8007e155e88f (diff)
downloadlinux-882e9d25e11d644b24e578866c688d3f8f0d3712.tar.xz
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: Jeff Layton <jlayton@primarydata.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs/nfsd/nfs4state.c')
-rw-r--r--fs/nfsd/nfs4state.c49
1 files changed, 18 insertions, 31 deletions
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 4af4e5eff491..cd7d7df03afa 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -5424,8 +5424,8 @@ nfsd4_release_lockowner(struct svc_rqst *rqstp,
struct nfsd4_release_lockowner *rlockowner)
{
clientid_t *clid = &rlockowner->rl_clientid;
- struct nfs4_stateowner *sop = NULL, *tmp;
- struct nfs4_lockowner *lo;
+ struct nfs4_stateowner *sop;
+ struct nfs4_lockowner *lo = NULL;
struct nfs4_ol_stateid *stp;
struct xdr_netobj *owner = &rlockowner->rl_owner;
unsigned int hashval = ownerstr_hashval(owner);
@@ -5442,45 +5442,32 @@ nfsd4_release_lockowner(struct svc_rqst *rqstp,
if (status)
goto out;
- status = nfserr_locks_held;
-
clp = cstate->clp;
/* Find the matching lock stateowner */
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) {
- 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) {
- spin_unlock(&clp->cl_lock);
- status = nfs_ok;
- goto out;
- }
+ if (sop->so_is_open_owner || !same_owner_str(sop, owner))
+ continue;
- lo = lockowner(sop);
- /* see if there are still any locks associated with it */
- list_for_each_entry(stp, &sop->so_stateids, st_perstateowner) {
- if (check_for_locks(stp->st_stid.sc_file, lo)) {
- spin_unlock(&clp->cl_lock);
- goto out;
+ /* see if there are still any locks associated with it */
+ lo = lockowner(sop);
+ list_for_each_entry(stp, &sop->so_stateids, st_perstateowner) {
+ if (check_for_locks(stp->st_stid.sc_file, lo)) {
+ status = nfserr_locks_held;
+ spin_unlock(&clp->cl_lock);
+ goto out;
+ }
}
+
+ atomic_inc(&sop->so_count);
+ break;
}
spin_unlock(&clp->cl_lock);
-
- status = nfs_ok;
- sop = NULL;
- release_lockowner(lo);
+ if (lo)
+ release_lockowner(lo);
out:
- if (sop)
- nfs4_put_stateowner(sop);
nfs4_unlock_state();
return status;
}