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>
This commit is contained in:
parent
b113746888
commit
b10e30f655
1 changed files with 34 additions and 24 deletions
|
@ -441,6 +441,31 @@ void nlm_release_host(struct nlm_host *host)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct nlm_host *next_host_state(struct hlist_head *cache,
|
||||||
|
struct nsm_handle *nsm,
|
||||||
|
const struct nlm_reboot *info)
|
||||||
|
{
|
||||||
|
struct nlm_host *host = NULL;
|
||||||
|
struct hlist_head *chain;
|
||||||
|
struct hlist_node *pos;
|
||||||
|
|
||||||
|
mutex_lock(&nlm_host_mutex);
|
||||||
|
for_each_host(host, pos, chain, cache) {
|
||||||
|
if (host->h_nsmhandle == nsm
|
||||||
|
&& host->h_nsmstate != info->state) {
|
||||||
|
host->h_nsmstate = info->state;
|
||||||
|
host->h_state++;
|
||||||
|
|
||||||
|
nlm_get_host(host);
|
||||||
|
mutex_unlock(&nlm_host_mutex);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
out:
|
||||||
|
mutex_unlock(&nlm_host_mutex);
|
||||||
|
return host;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* nlm_host_rebooted - Release all resources held by rebooted host
|
* nlm_host_rebooted - Release all resources held by rebooted host
|
||||||
* @info: pointer to decoded results of NLM_SM_NOTIFY call
|
* @info: pointer to decoded results of NLM_SM_NOTIFY call
|
||||||
|
@ -450,8 +475,6 @@ void nlm_release_host(struct nlm_host *host)
|
||||||
*/
|
*/
|
||||||
void nlm_host_rebooted(const struct nlm_reboot *info)
|
void nlm_host_rebooted(const struct nlm_reboot *info)
|
||||||
{
|
{
|
||||||
struct hlist_head *chain;
|
|
||||||
struct hlist_node *pos;
|
|
||||||
struct nsm_handle *nsm;
|
struct nsm_handle *nsm;
|
||||||
struct nlm_host *host;
|
struct nlm_host *host;
|
||||||
|
|
||||||
|
@ -464,30 +487,17 @@ void nlm_host_rebooted(const struct nlm_reboot *info)
|
||||||
* lock for this.
|
* lock for this.
|
||||||
* To avoid processing a host several times, we match the nsmstate.
|
* To avoid processing a host several times, we match the nsmstate.
|
||||||
*/
|
*/
|
||||||
again: mutex_lock(&nlm_host_mutex);
|
while ((host = next_host_state(nlm_hosts, nsm, info)) != NULL) {
|
||||||
for_each_host(host, pos, chain, nlm_hosts) {
|
if (host->h_server) {
|
||||||
if (host->h_nsmhandle == nsm
|
/* We're server for this guy, just ditch
|
||||||
&& host->h_nsmstate != info->state) {
|
* all the locks he held. */
|
||||||
host->h_nsmstate = info->state;
|
nlmsvc_free_host_resources(host);
|
||||||
host->h_state++;
|
} else {
|
||||||
|
/* He's the server, initiate lock recovery. */
|
||||||
nlm_get_host(host);
|
nlmclnt_recovery(host);
|
||||||
mutex_unlock(&nlm_host_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;
|
|
||||||
}
|
}
|
||||||
|
nlm_release_host(host);
|
||||||
}
|
}
|
||||||
mutex_unlock(&nlm_host_mutex);
|
|
||||||
nsm_release(nsm);
|
nsm_release(nsm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue