aboutsummaryrefslogtreecommitdiffstats
path: root/fs/lockd/host.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/lockd/host.c')
-rw-r--r--fs/lockd/host.c29
1 files changed, 12 insertions, 17 deletions
diff --git a/fs/lockd/host.c b/fs/lockd/host.c
index 0e17090c310f..abdd75d44dd4 100644
--- a/fs/lockd/host.c
+++ b/fs/lockd/host.c
@@ -32,15 +32,15 @@
32static struct hlist_head nlm_server_hosts[NLM_HOST_NRHASH]; 32static struct hlist_head nlm_server_hosts[NLM_HOST_NRHASH];
33static struct hlist_head nlm_client_hosts[NLM_HOST_NRHASH]; 33static struct hlist_head nlm_client_hosts[NLM_HOST_NRHASH];
34 34
35#define for_each_host(host, pos, chain, table) \ 35#define for_each_host(host, chain, table) \
36 for ((chain) = (table); \ 36 for ((chain) = (table); \
37 (chain) < (table) + NLM_HOST_NRHASH; ++(chain)) \ 37 (chain) < (table) + NLM_HOST_NRHASH; ++(chain)) \
38 hlist_for_each_entry((host), (pos), (chain), h_hash) 38 hlist_for_each_entry((host), (chain), h_hash)
39 39
40#define for_each_host_safe(host, pos, next, chain, table) \ 40#define for_each_host_safe(host, next, chain, table) \
41 for ((chain) = (table); \ 41 for ((chain) = (table); \
42 (chain) < (table) + NLM_HOST_NRHASH; ++(chain)) \ 42 (chain) < (table) + NLM_HOST_NRHASH; ++(chain)) \
43 hlist_for_each_entry_safe((host), (pos), (next), \ 43 hlist_for_each_entry_safe((host), (next), \
44 (chain), h_hash) 44 (chain), h_hash)
45 45
46static unsigned long nrhosts; 46static unsigned long nrhosts;
@@ -225,7 +225,6 @@ struct nlm_host *nlmclnt_lookup_host(const struct sockaddr *sap,
225 .net = net, 225 .net = net,
226 }; 226 };
227 struct hlist_head *chain; 227 struct hlist_head *chain;
228 struct hlist_node *pos;
229 struct nlm_host *host; 228 struct nlm_host *host;
230 struct nsm_handle *nsm = NULL; 229 struct nsm_handle *nsm = NULL;
231 struct lockd_net *ln = net_generic(net, lockd_net_id); 230 struct lockd_net *ln = net_generic(net, lockd_net_id);
@@ -237,7 +236,7 @@ struct nlm_host *nlmclnt_lookup_host(const struct sockaddr *sap,
237 mutex_lock(&nlm_host_mutex); 236 mutex_lock(&nlm_host_mutex);
238 237
239 chain = &nlm_client_hosts[nlm_hash_address(sap)]; 238 chain = &nlm_client_hosts[nlm_hash_address(sap)];
240 hlist_for_each_entry(host, pos, chain, h_hash) { 239 hlist_for_each_entry(host, chain, h_hash) {
241 if (host->net != net) 240 if (host->net != net)
242 continue; 241 continue;
243 if (!rpc_cmp_addr(nlm_addr(host), sap)) 242 if (!rpc_cmp_addr(nlm_addr(host), sap))
@@ -322,7 +321,6 @@ struct nlm_host *nlmsvc_lookup_host(const struct svc_rqst *rqstp,
322 const size_t hostname_len) 321 const size_t hostname_len)
323{ 322{
324 struct hlist_head *chain; 323 struct hlist_head *chain;
325 struct hlist_node *pos;
326 struct nlm_host *host = NULL; 324 struct nlm_host *host = NULL;
327 struct nsm_handle *nsm = NULL; 325 struct nsm_handle *nsm = NULL;
328 struct sockaddr *src_sap = svc_daddr(rqstp); 326 struct sockaddr *src_sap = svc_daddr(rqstp);
@@ -350,7 +348,7 @@ struct nlm_host *nlmsvc_lookup_host(const struct svc_rqst *rqstp,
350 nlm_gc_hosts(net); 348 nlm_gc_hosts(net);
351 349
352 chain = &nlm_server_hosts[nlm_hash_address(ni.sap)]; 350 chain = &nlm_server_hosts[nlm_hash_address(ni.sap)];
353 hlist_for_each_entry(host, pos, chain, h_hash) { 351 hlist_for_each_entry(host, chain, h_hash) {
354 if (host->net != net) 352 if (host->net != net)
355 continue; 353 continue;
356 if (!rpc_cmp_addr(nlm_addr(host), ni.sap)) 354 if (!rpc_cmp_addr(nlm_addr(host), ni.sap))
@@ -515,10 +513,9 @@ static struct nlm_host *next_host_state(struct hlist_head *cache,
515{ 513{
516 struct nlm_host *host; 514 struct nlm_host *host;
517 struct hlist_head *chain; 515 struct hlist_head *chain;
518 struct hlist_node *pos;
519 516
520 mutex_lock(&nlm_host_mutex); 517 mutex_lock(&nlm_host_mutex);
521 for_each_host(host, pos, chain, cache) { 518 for_each_host(host, chain, cache) {
522 if (host->h_nsmhandle == nsm 519 if (host->h_nsmhandle == nsm
523 && host->h_nsmstate != info->state) { 520 && host->h_nsmstate != info->state) {
524 host->h_nsmstate = info->state; 521 host->h_nsmstate = info->state;
@@ -570,7 +567,6 @@ void nlm_host_rebooted(const struct nlm_reboot *info)
570static void nlm_complain_hosts(struct net *net) 567static void nlm_complain_hosts(struct net *net)
571{ 568{
572 struct hlist_head *chain; 569 struct hlist_head *chain;
573 struct hlist_node *pos;
574 struct nlm_host *host; 570 struct nlm_host *host;
575 571
576 if (net) { 572 if (net) {
@@ -587,7 +583,7 @@ static void nlm_complain_hosts(struct net *net)
587 dprintk("lockd: %lu hosts left:\n", nrhosts); 583 dprintk("lockd: %lu hosts left:\n", nrhosts);
588 } 584 }
589 585
590 for_each_host(host, pos, chain, nlm_server_hosts) { 586 for_each_host(host, chain, nlm_server_hosts) {
591 if (net && host->net != net) 587 if (net && host->net != net)
592 continue; 588 continue;
593 dprintk(" %s (cnt %d use %d exp %ld net %p)\n", 589 dprintk(" %s (cnt %d use %d exp %ld net %p)\n",
@@ -600,14 +596,13 @@ void
600nlm_shutdown_hosts_net(struct net *net) 596nlm_shutdown_hosts_net(struct net *net)
601{ 597{
602 struct hlist_head *chain; 598 struct hlist_head *chain;
603 struct hlist_node *pos;
604 struct nlm_host *host; 599 struct nlm_host *host;
605 600
606 mutex_lock(&nlm_host_mutex); 601 mutex_lock(&nlm_host_mutex);
607 602
608 /* First, make all hosts eligible for gc */ 603 /* First, make all hosts eligible for gc */
609 dprintk("lockd: nuking all hosts in net %p...\n", net); 604 dprintk("lockd: nuking all hosts in net %p...\n", net);
610 for_each_host(host, pos, chain, nlm_server_hosts) { 605 for_each_host(host, chain, nlm_server_hosts) {
611 if (net && host->net != net) 606 if (net && host->net != net)
612 continue; 607 continue;
613 host->h_expires = jiffies - 1; 608 host->h_expires = jiffies - 1;
@@ -644,11 +639,11 @@ static void
644nlm_gc_hosts(struct net *net) 639nlm_gc_hosts(struct net *net)
645{ 640{
646 struct hlist_head *chain; 641 struct hlist_head *chain;
647 struct hlist_node *pos, *next; 642 struct hlist_node *next;
648 struct nlm_host *host; 643 struct nlm_host *host;
649 644
650 dprintk("lockd: host garbage collection for net %p\n", net); 645 dprintk("lockd: host garbage collection for net %p\n", net);
651 for_each_host(host, pos, chain, nlm_server_hosts) { 646 for_each_host(host, chain, nlm_server_hosts) {
652 if (net && host->net != net) 647 if (net && host->net != net)
653 continue; 648 continue;
654 host->h_inuse = 0; 649 host->h_inuse = 0;
@@ -657,7 +652,7 @@ nlm_gc_hosts(struct net *net)
657 /* Mark all hosts that hold locks, blocks or shares */ 652 /* Mark all hosts that hold locks, blocks or shares */
658 nlmsvc_mark_resources(net); 653 nlmsvc_mark_resources(net);
659 654
660 for_each_host_safe(host, pos, next, chain, nlm_server_hosts) { 655 for_each_host_safe(host, next, chain, nlm_server_hosts) {
661 if (net && host->net != net) 656 if (net && host->net != net)
662 continue; 657 continue;
663 if (atomic_read(&host->h_count) || host->h_inuse 658 if (atomic_read(&host->h_count) || host->h_inuse