Commit fd44907c authored by Jeff Layton's avatar Jeff Layton Committed by J. Bruce Fields

nfsd: clean up nfsd4_release_lockowner

Now that we know that we won't have several lockowners with the same,
owner->data, we can simplify nfsd4_release_lockowner and get rid of
the lo_list in the process.
Signed-off-by: default avatarJeff Layton <jlayton@primarydata.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
parent b3c32bcd
...@@ -4783,11 +4783,10 @@ nfsd4_release_lockowner(struct svc_rqst *rqstp, ...@@ -4783,11 +4783,10 @@ 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; struct nfs4_stateowner *sop = NULL, *tmp;
struct nfs4_lockowner *lo; struct nfs4_lockowner *lo;
struct nfs4_ol_stateid *stp; struct nfs4_ol_stateid *stp;
struct xdr_netobj *owner = &rlockowner->rl_owner; struct xdr_netobj *owner = &rlockowner->rl_owner;
struct list_head matches;
unsigned int hashval = ownerstr_hashval(clid->cl_id, owner); unsigned int hashval = ownerstr_hashval(clid->cl_id, owner);
__be32 status; __be32 status;
struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id); struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id);
...@@ -4802,33 +4801,32 @@ nfsd4_release_lockowner(struct svc_rqst *rqstp, ...@@ -4802,33 +4801,32 @@ nfsd4_release_lockowner(struct svc_rqst *rqstp,
goto out; goto out;
status = nfserr_locks_held; status = nfserr_locks_held;
INIT_LIST_HEAD(&matches);
list_for_each_entry(sop, &nn->ownerstr_hashtbl[hashval], so_strhash) { /* Find the matching lock stateowner */
if (sop->so_is_open_owner) list_for_each_entry(tmp, &nn->ownerstr_hashtbl[hashval], so_strhash) {
continue; if (tmp->so_is_open_owner)
if (!same_owner_str(sop, owner, clid))
continue; continue;
list_for_each_entry(stp, &sop->so_stateids, if (same_owner_str(tmp, owner, clid)) {
st_perstateowner) { sop = tmp;
lo = lockowner(sop); break;
if (check_for_locks(stp->st_file, lo))
goto out;
list_add(&lo->lo_list, &matches);
} }
} }
/* Clients probably won't expect us to return with some (but not all)
* of the lockowner state released; so don't release any until all /* No matching owner found, maybe a replay? Just declare victory... */
* have been checked. */ if (!sop) {
status = nfs_ok; status = nfs_ok;
while (!list_empty(&matches)) { goto out;
lo = list_entry(matches.next, struct nfs4_lockowner, }
lo_list);
/* unhash_stateowner deletes so_perclient only lo = lockowner(sop);
* for openowners. */ /* see if there are still any locks associated with it */
list_del(&lo->lo_list); list_for_each_entry(stp, &sop->so_stateids, st_perstateowner) {
release_lockowner(lo); if (check_for_locks(stp->st_file, lo))
goto out;
} }
status = nfs_ok;
release_lockowner(lo);
out: out:
nfs4_unlock_state(); nfs4_unlock_state();
return status; return status;
......
...@@ -364,7 +364,6 @@ struct nfs4_openowner { ...@@ -364,7 +364,6 @@ struct nfs4_openowner {
struct nfs4_lockowner { struct nfs4_lockowner {
struct nfs4_stateowner lo_owner; /* must be first element */ struct nfs4_stateowner lo_owner; /* must be first element */
struct list_head lo_list; /* for temporary uses */
}; };
static inline struct nfs4_openowner * openowner(struct nfs4_stateowner *so) static inline struct nfs4_openowner * openowner(struct nfs4_stateowner *so)
......
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