aboutsummaryrefslogtreecommitdiffstats
path: root/fs/lockd
diff options
context:
space:
mode:
Diffstat (limited to 'fs/lockd')
-rw-r--r--fs/lockd/host.c58
1 files changed, 34 insertions, 24 deletions
diff --git a/fs/lockd/host.c b/fs/lockd/host.c
index cada3a12d557..2dbf1392acfc 100644
--- a/fs/lockd/host.c
+++ b/fs/lockd/host.c
@@ -441,6 +441,31 @@ void nlm_release_host(struct nlm_host *host)
441 } 441 }
442} 442}
443 443
444static struct nlm_host *next_host_state(struct hlist_head *cache,
445 struct nsm_handle *nsm,
446 const struct nlm_reboot *info)
447{
448 struct nlm_host *host = NULL;
449 struct hlist_head *chain;
450 struct hlist_node *pos;
451
452 mutex_lock(&nlm_host_mutex);
453 for_each_host(host, pos, chain, cache) {
454 if (host->h_nsmhandle == nsm
455 && host->h_nsmstate != info->state) {
456 host->h_nsmstate = info->state;
457 host->h_state++;
458
459 nlm_get_host(host);
460 mutex_unlock(&nlm_host_mutex);
461 goto out;
462 }
463 }
464out:
465 mutex_unlock(&nlm_host_mutex);
466 return host;
467}
468
444/** 469/**
445 * nlm_host_rebooted - Release all resources held by rebooted host 470 * nlm_host_rebooted - Release all resources held by rebooted host
446 * @info: pointer to decoded results of NLM_SM_NOTIFY call 471 * @info: pointer to decoded results of NLM_SM_NOTIFY call
@@ -450,8 +475,6 @@ void nlm_release_host(struct nlm_host *host)
450 */ 475 */
451void nlm_host_rebooted(const struct nlm_reboot *info) 476void nlm_host_rebooted(const struct nlm_reboot *info)
452{ 477{
453 struct hlist_head *chain;
454 struct hlist_node *pos;
455 struct nsm_handle *nsm; 478 struct nsm_handle *nsm;
456 struct nlm_host *host; 479 struct nlm_host *host;
457 480
@@ -464,30 +487,17 @@ void nlm_host_rebooted(const struct nlm_reboot *info)
464 * lock for this. 487 * lock for this.
465 * To avoid processing a host several times, we match the nsmstate. 488 * To avoid processing a host several times, we match the nsmstate.
466 */ 489 */
467again: mutex_lock(&nlm_host_mutex); 490 while ((host = next_host_state(nlm_hosts, nsm, info)) != NULL) {
468 for_each_host(host, pos, chain, nlm_hosts) { 491 if (host->h_server) {
469 if (host->h_nsmhandle == nsm 492 /* We're server for this guy, just ditch
470 && host->h_nsmstate != info->state) { 493 * all the locks he held. */
471 host->h_nsmstate = info->state; 494 nlmsvc_free_host_resources(host);
472 host->h_state++; 495 } else {
473 496 /* He's the server, initiate lock recovery. */
474 nlm_get_host(host); 497 nlmclnt_recovery(host);
475 mutex_unlock(&nlm_host_mutex);
476
477 if (host->h_server) {
478 /* We're server for this guy, just ditch
479 * all the locks he held. */
480 nlmsvc_free_host_resources(host);
481 } else {
482 /* He's the server, initiate lock recovery. */
483 nlmclnt_recovery(host);
484 }
485
486 nlm_release_host(host);
487 goto again;
488 } 498 }
499 nlm_release_host(host);
489 } 500 }
490 mutex_unlock(&nlm_host_mutex);
491 nsm_release(nsm); 501 nsm_release(nsm);
492} 502}
493 503