Skip to content

Commit 723bb5b

Browse files
chuckleverTrond Myklebust
authored andcommitted
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: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
1 parent a7952f4 commit 723bb5b

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

‎fs/lockd/host.c‎

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -231,23 +231,30 @@ static struct nlm_host *nlm_lookup_host(struct nlm_lookup_host_info *ni)
231231
}
232232

233233
/*
234-
* Destroy a host
234+
* Destroy an nlm_host and free associated resources
235+
*
236+
* Caller must hold nlm_host_mutex.
235237
*/
236-
static void
237-
nlm_destroy_host(struct nlm_host *host)
238+
static void nlm_destroy_host_locked(struct nlm_host *host)
238239
{
239240
struct rpc_clnt *clnt;
240241

242+
dprintk("lockd: destroy host %s\n", host->h_name);
243+
241244
BUG_ON(!list_empty(&host->h_lockowners));
242245
BUG_ON(atomic_read(&host->h_count));
243246

247+
hlist_del_init(&host->h_hash);
248+
244249
nsm_unmonitor(host);
245250
nsm_release(host->h_nsmhandle);
246251

247252
clnt = host->h_rpcclnt;
248253
if (clnt != NULL)
249254
rpc_shutdown_client(clnt);
250255
kfree(host);
256+
257+
nrhosts--;
251258
}
252259

253260
/**
@@ -589,11 +596,7 @@ nlm_gc_hosts(void)
589596
host->h_inuse, host->h_expires);
590597
continue;
591598
}
592-
dprintk("lockd: delete host %s\n", host->h_name);
593-
hlist_del_init(&host->h_hash);
594-
595-
nlm_destroy_host(host);
596-
nrhosts--;
599+
nlm_destroy_host_locked(host);
597600
}
598601

599602
next_gc = jiffies + NLM_HOST_COLLECT;

0 commit comments

Comments
 (0)