Commit 723bb5b5 authored by Chuck Lever's avatar Chuck Lever Committed by Trond Myklebust

lockd: Add nlm_destroy_host_locked()

Refactor the tail of nlm_gc_hosts() into nlm_destroy_host() so that
this logic can be used separately from garbage collection.

Rename it _locked() to document that it must be called with the hosts
cache mutex held.
Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
parent a7952f40
...@@ -231,16 +231,21 @@ static struct nlm_host *nlm_lookup_host(struct nlm_lookup_host_info *ni) ...@@ -231,16 +231,21 @@ static struct nlm_host *nlm_lookup_host(struct nlm_lookup_host_info *ni)
} }
/* /*
* Destroy a host * Destroy an nlm_host and free associated resources
*
* Caller must hold nlm_host_mutex.
*/ */
static void static void nlm_destroy_host_locked(struct nlm_host *host)
nlm_destroy_host(struct nlm_host *host)
{ {
struct rpc_clnt *clnt; struct rpc_clnt *clnt;
dprintk("lockd: destroy host %s\n", host->h_name);
BUG_ON(!list_empty(&host->h_lockowners)); BUG_ON(!list_empty(&host->h_lockowners));
BUG_ON(atomic_read(&host->h_count)); BUG_ON(atomic_read(&host->h_count));
hlist_del_init(&host->h_hash);
nsm_unmonitor(host); nsm_unmonitor(host);
nsm_release(host->h_nsmhandle); nsm_release(host->h_nsmhandle);
...@@ -248,6 +253,8 @@ nlm_destroy_host(struct nlm_host *host) ...@@ -248,6 +253,8 @@ nlm_destroy_host(struct nlm_host *host)
if (clnt != NULL) if (clnt != NULL)
rpc_shutdown_client(clnt); rpc_shutdown_client(clnt);
kfree(host); kfree(host);
nrhosts--;
} }
/** /**
...@@ -589,11 +596,7 @@ nlm_gc_hosts(void) ...@@ -589,11 +596,7 @@ nlm_gc_hosts(void)
host->h_inuse, host->h_expires); host->h_inuse, host->h_expires);
continue; continue;
} }
dprintk("lockd: delete host %s\n", host->h_name); nlm_destroy_host_locked(host);
hlist_del_init(&host->h_hash);
nlm_destroy_host(host);
nrhosts--;
} }
next_gc = jiffies + NLM_HOST_COLLECT; next_gc = jiffies + NLM_HOST_COLLECT;
......
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