Commit 9af5102f authored by Neil Brown's avatar Neil Brown Committed by Linus Torvalds

[PATCH] knfsd: simplify nfsd4_release_lockowner

Simplify nfsd4_release_lockowner a bit, factor out code that we need for
another patch.

Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>        
Signed-off-by: default avatarNeil Brown <neilb@cse.unsw.edu.au>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent d27e20aa
...@@ -1850,6 +1850,21 @@ nfs4_set_lock_denied(struct file_lock *fl, struct nfsd4_lock_denied *deny) ...@@ -1850,6 +1850,21 @@ nfs4_set_lock_denied(struct file_lock *fl, struct nfsd4_lock_denied *deny)
deny->ld_type = NFS4_WRITE_LT; deny->ld_type = NFS4_WRITE_LT;
} }
static struct nfs4_stateowner *
find_lockstateowner(struct xdr_netobj *owner, clientid_t *clid)
{
struct nfs4_stateowner *local = NULL;
int i;
for (i = 0; i < LOCK_HASH_SIZE; i++) {
list_for_each_entry(local, &lock_ownerid_hashtbl[i], so_idhash) {
if(!cmp_owner_str(local, owner, clid))
continue;
return local;
}
}
return NULL;
}
static int static int
find_lockstateowner_str(unsigned int hashval, struct xdr_netobj *owner, clientid_t *clid, struct nfs4_stateowner **op) { find_lockstateowner_str(unsigned int hashval, struct xdr_netobj *owner, clientid_t *clid, struct nfs4_stateowner **op) {
...@@ -2315,7 +2330,7 @@ nfsd4_release_lockowner(struct svc_rqst *rqstp, struct nfsd4_release_lockowner * ...@@ -2315,7 +2330,7 @@ nfsd4_release_lockowner(struct svc_rqst *rqstp, struct nfsd4_release_lockowner *
clientid_t *clid = &rlockowner->rl_clientid; clientid_t *clid = &rlockowner->rl_clientid;
struct nfs4_stateowner *local = NULL; struct nfs4_stateowner *local = NULL;
struct xdr_netobj *owner = &rlockowner->rl_owner; struct xdr_netobj *owner = &rlockowner->rl_owner;
int status, i; int status;
dprintk("nfsd4_release_lockowner clientid: (%08x/%08x):\n", dprintk("nfsd4_release_lockowner clientid: (%08x/%08x):\n",
clid->cl_boot, clid->cl_id); clid->cl_boot, clid->cl_id);
...@@ -2330,11 +2345,9 @@ nfsd4_release_lockowner(struct svc_rqst *rqstp, struct nfsd4_release_lockowner * ...@@ -2330,11 +2345,9 @@ nfsd4_release_lockowner(struct svc_rqst *rqstp, struct nfsd4_release_lockowner *
nfs4_lock_state(); nfs4_lock_state();
/* find the lockowner */
status = nfs_ok; status = nfs_ok;
for (i=0; i < LOCK_HASH_SIZE; i++) local = find_lockstateowner(owner, clid);
list_for_each_entry(local, &lock_ownerstr_hashtbl[i], so_strhash) if (local) {
if(cmp_owner_str(local, owner, clid)) {
struct nfs4_stateid *stp; struct nfs4_stateid *stp;
/* check for any locks held by any stateid /* check for any locks held by any stateid
...@@ -2343,15 +2356,13 @@ nfsd4_release_lockowner(struct svc_rqst *rqstp, struct nfsd4_release_lockowner * ...@@ -2343,15 +2356,13 @@ nfsd4_release_lockowner(struct svc_rqst *rqstp, struct nfsd4_release_lockowner *
list_for_each_entry(stp, &local->so_perfilestate, list_for_each_entry(stp, &local->so_perfilestate,
st_perfilestate) { st_perfilestate) {
if(stp->st_vfs_set) { if(stp->st_vfs_set) {
if (check_for_locks(&stp->st_vfs_file, if (check_for_locks(&stp->st_vfs_file, local))
local))
goto out; goto out;
} }
} }
/* no locks held by (lock) stateowner */ /* no locks held by (lock) stateowner */
status = nfs_ok; status = nfs_ok;
release_stateowner(local); release_stateowner(local);
goto out;
} }
out: out:
nfs4_unlock_state(); nfs4_unlock_state();
......
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