Minor reorganization; no change in behavior. This will save some duplicated code after we split apart the client and server host lists. Signed-off-by: J. Bruce Fields <bfields@xxxxxxxxxxxxxx> --- fs/lockd/host.c | 59 +++++++++++++++++++++++++++++++----------------------- 1 files changed, 34 insertions(+), 25 deletions(-) diff --git a/fs/lockd/host.c b/fs/lockd/host.c index 1b90b49..bb3bf36 100644 --- a/fs/lockd/host.c +++ b/fs/lockd/host.c @@ -482,6 +482,31 @@ void nlm_release_host(struct nlm_host *host) } } +static struct nlm_host *next_host_state(struct host_table *table, + struct nsm_handle *nsm, + u32 new_state) +{ + struct hlist_head *chain; + struct hlist_node *pos; + struct nlm_host *host = NULL; + + mutex_lock(&table->ht_mutex); + for_each_host(host, pos, chain, table) { + if (host->h_nsmhandle == nsm + && host->h_nsmstate != new_state) { + host->h_nsmstate = new_state; + host->h_state++; + + nlm_get_host(host); + mutex_unlock(&table->ht_mutex); + goto out; + } + } +out: + mutex_unlock(&table->ht_mutex); + return host; +} + /* * We were notified that the host indicated by address &sin * has rebooted. @@ -492,8 +517,6 @@ void nlm_host_rebooted(const struct sockaddr_in *sin, unsigned int hostname_len, u32 new_state) { - struct hlist_head *chain; - struct hlist_node *pos; struct nsm_handle *nsm; struct nlm_host *host; @@ -517,31 +540,17 @@ void nlm_host_rebooted(const struct sockaddr_in *sin, * lock for this. * To avoid processing a host several times, we match the nsmstate. */ -again: mutex_lock(&nlm_hosts.ht_mutex); - for_each_host(host, pos, chain, &nlm_hosts) { - if (host->h_nsmhandle == nsm - && host->h_nsmstate != new_state) { - host->h_nsmstate = new_state; - host->h_state++; - - nlm_get_host(host); - mutex_unlock(&nlm_hosts.ht_mutex); - - if (host->h_server) { - /* We're server for this guy, just ditch - * all the locks he held. */ - nlmsvc_free_host_resources(host); - } else { - /* He's the server, initiate lock recovery. */ - nlmclnt_recovery(host); - } - - nlm_release_host(host); - goto again; + while ((host = next_host_state(&nlm_hosts, nsm, new_state)) != NULL) { + if (host->h_server) { + /* We're server for this guy, just ditch + * all the locks he held. */ + nlmsvc_free_host_resources(host); + } else { + /* He's the server, initiate lock recovery. */ + nlmclnt_recovery(host); } + nlm_release_host(host); } - - mutex_unlock(&nlm_hosts.ht_mutex); } /* -- 1.5.5.rc1 -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html