diff options
author | J. Bruce Fields <bfields@citi.umich.edu> | 2010-12-14 10:05:13 -0500 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2010-12-16 12:37:26 -0500 |
commit | b10e30f6559978e3c8ca2a70c1cb35d6680a4021 (patch) | |
tree | b084204e36261f72da259ad8da44880623f834fc /fs | |
parent | b113746888c260a02f6ae1e92b0b9ef7e9c38993 (diff) |
lockd: reorganize nlm_host_rebooted
Minor reorganization; no change in behavior. This will save some
duplicated code after we split the client and server host caches.
Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
[ cel: Forward-ported to 2.6.37 ]
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/lockd/host.c | 58 |
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 | ||
444 | static 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 | } | ||
464 | out: | ||
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 | */ |
451 | void nlm_host_rebooted(const struct nlm_reboot *info) | 476 | void 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 | */ |
467 | again: 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 | ||