Commit b10e30f6559978e3c8ca2a70c1cb35d6680a4021

Authored by J. Bruce Fields
Committed by Trond Myklebust
1 parent b113746888

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>

Showing 1 changed file with 34 additions and 24 deletions Side-by-side Diff

... ... @@ -441,6 +441,31 @@
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 470 * nlm_host_rebooted - Release all resources held by rebooted host
446 471 * @info: pointer to decoded results of NLM_SM_NOTIFY call
... ... @@ -450,8 +475,6 @@
450 475 */
451 476 void nlm_host_rebooted(const struct nlm_reboot *info)
452 477 {
453   - struct hlist_head *chain;
454   - struct hlist_node *pos;
455 478 struct nsm_handle *nsm;
456 479 struct nlm_host *host;
457 480  
458 481  
459 482  
... ... @@ -464,30 +487,17 @@
464 487 * lock for this.
465 488 * To avoid processing a host several times, we match the nsmstate.
466 489 */
467   -again: mutex_lock(&nlm_host_mutex);
468   - for_each_host(host, pos, chain, nlm_hosts) {
469   - if (host->h_nsmhandle == nsm
470   - && host->h_nsmstate != info->state) {
471   - host->h_nsmstate = info->state;
472   - host->h_state++;
473   -
474   - nlm_get_host(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;
  490 + while ((host = next_host_state(nlm_hosts, nsm, info)) != NULL) {
  491 + if (host->h_server) {
  492 + /* We're server for this guy, just ditch
  493 + * all the locks he held. */
  494 + nlmsvc_free_host_resources(host);
  495 + } else {
  496 + /* He's the server, initiate lock recovery. */
  497 + nlmclnt_recovery(host);
488 498 }
  499 + nlm_release_host(host);
489 500 }
490   - mutex_unlock(&nlm_host_mutex);
491 501 nsm_release(nsm);
492 502 }
493 503