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