All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chuck Lever <chuck.lever@oracle.com>
To: linux-nfs@vger.kernel.org
Subject: [PATCH 02/11] lockd: reorganize nlm_host_rebooted
Date: Thu, 09 Dec 2010 11:48:28 -0500	[thread overview]
Message-ID: <20101209164828.4513.47494.stgit@matisse.1015granger.net> (raw)
In-Reply-To: <20101209163555.4513.94435.stgit@matisse.1015granger.net>

From: J. Bruce Fields <bfields@citi.umich.edu>

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>
---

 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 cada3a1..2dbf139 100644
--- a/fs/lockd/host.c
+++ b/fs/lockd/host.c
@@ -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
  * @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)
 {
-	struct hlist_head *chain;
-	struct hlist_node *pos;
 	struct nsm_handle *nsm;
 	struct nlm_host	*host;
 
@@ -464,30 +487,17 @@ void nlm_host_rebooted(const struct nlm_reboot *info)
 	 * lock for this.
 	 * To avoid processing a host several times, we match the nsmstate.
 	 */
-again:	mutex_lock(&nlm_host_mutex);
-	for_each_host(host, pos, chain, nlm_hosts) {
-		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);
-
-			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, info)) != 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_host_mutex);
 	nsm_release(nsm);
 }
 


  parent reply	other threads:[~2010-12-09 16:48 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-09 16:48 [PATCH 00/11] RFC: Split nlm_host cache Chuck Lever
2010-12-09 16:48 ` [PATCH 01/11] lockd: define host_for_each{_safe} macros Chuck Lever
2010-12-09 16:48 ` Chuck Lever [this message]
2010-12-09 16:48 ` [PATCH 03/11] lockd: Add nlm_alloc_host() Chuck Lever
2010-12-09 16:58   ` Trond Myklebust
2010-12-09 17:06     ` Chuck Lever
2010-12-09 16:48 ` [PATCH 04/11] lockd: Add nlm_destroy_host_locked() Chuck Lever
2010-12-09 16:48 ` [PATCH 05/11] lockd: Split nlm_release_call() Chuck Lever
2010-12-09 16:49 ` [PATCH 06/11] lockd: Create client-side nlm_host cache Chuck Lever
2010-12-09 16:49 ` [PATCH 07/11] lockd: Clean up nlmsvc_lookup_host() Chuck Lever
2010-12-09 16:49 ` [PATCH 08/11] lockd: Rename nlm_hosts Chuck Lever
2010-12-09 16:50 ` [PATCH 09/11] lockd: Make nrhosts an unsigned long Chuck Lever
2010-12-09 16:50 ` [PATCH 10/11] lockd: Remove nlm_lookup_host() Chuck Lever
2010-12-09 16:50 ` [PATCH 11/11] lockd: Remove src_sap and src_len from nlm_lookup_host_info struct Chuck Lever
2010-12-14 15:04 [PATCH 00/11] nlm_host cache split for 2.6.38 Chuck Lever
2010-12-14 15:05 ` [PATCH 02/11] lockd: reorganize nlm_host_rebooted Chuck Lever

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20101209164828.4513.47494.stgit@matisse.1015granger.net \
    --to=chuck.lever@oracle.com \
    --cc=linux-nfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.