This code will later be shared. Signed-off-by: J. Bruce Fields <bfields@xxxxxxxxxxxxxx> --- fs/lockd/host.c | 46 +++++++++++++++++++++++++++------------------- 1 files changed, 27 insertions(+), 19 deletions(-) diff --git a/fs/lockd/host.c b/fs/lockd/host.c index 3fd7573..fa006af 100644 --- a/fs/lockd/host.c +++ b/fs/lockd/host.c @@ -553,6 +553,31 @@ void nlm_host_rebooted(const struct sockaddr_in *sin, } } +static void nlm_gc_table(struct host_table *table) +{ + struct hlist_head *chain; + struct hlist_node *pos, *next; + struct nlm_host *host; + + for_each_host_safe(host, pos, next, chain, table) { + if (atomic_read(&host->h_count) || host->h_inuse + || time_before(jiffies, host->h_expires)) { + dprintk("nlm_gc_hosts skipping %s" + " (cnt %d use %d exp %ld)\n", + host->h_name, atomic_read(&host->h_count), + host->h_inuse, host->h_expires); + continue; + } + dprintk("lockd: delete host %s\n", host->h_name); + hlist_del_init(&host->h_hash); + + nlm_destroy_host(host); + table->ht_num--; + } + + next_gc = jiffies + NLM_HOST_COLLECT; +} + static void warn_host_leak(struct host_table *table) { struct hlist_head *chain; @@ -610,7 +635,7 @@ static void nlm_gc_hosts(void) { struct hlist_head *chain; - struct hlist_node *pos, *next; + struct hlist_node *pos; struct nlm_host *host; dprintk("lockd: host garbage collection\n"); @@ -620,26 +645,9 @@ nlm_gc_hosts(void) /* Mark all hosts that hold locks, blocks or shares */ nlmsvc_mark_resources(); - for_each_host_safe(host, pos, next, chain, &nlm_hosts) { - if (atomic_read(&host->h_count) || host->h_inuse - || time_before(jiffies, host->h_expires)) { - dprintk("nlm_gc_hosts skipping %s" - " (cnt %d use %d exp %ld)\n", - host->h_name, atomic_read(&host->h_count), - host->h_inuse, host->h_expires); - continue; - } - dprintk("lockd: delete host %s\n", host->h_name); - hlist_del_init(&host->h_hash); - - nlm_destroy_host(host); - nlm_hosts.ht_num--; - } - - next_gc = jiffies + NLM_HOST_COLLECT; + nlm_gc_table(&nlm_hosts); } - /* * Manage NSM handles */ -- 1.5.5.rc1 -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html