[PATCH 1/6] NLM: Always set host->h_rpcclnt to NULL after shutting down RPC client

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



We're about to introduce an nlm_host SLAB.  We can initialize the
h_rpcclnt field in an init_once callback if we always make sure to set
h_rpcclnt to NULL after invoking rpc_shutdown_client().

Signed-off-by: Chuck Lever <chuck.lever@xxxxxxxxxx>
---

 fs/lockd/host.c |   19 ++++++++++---------
 1 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/fs/lockd/host.c b/fs/lockd/host.c
index bda5f9e..45a6d01 100644
--- a/fs/lockd/host.c
+++ b/fs/lockd/host.c
@@ -98,6 +98,14 @@ static void nlm_clear_port(struct sockaddr *sap)
 	}
 }
 
+static void nlm_host_rpc_shutdown(struct nlm_host *host)
+{
+	if (host->h_rpcclnt) {
+		rpc_shutdown_client(host->h_rpcclnt);
+		host->h_rpcclnt = NULL;
+	}
+}
+
 static void nlm_display_ipv4_address(const struct sockaddr *sap, char *buf,
 				     const size_t len)
 {
@@ -264,8 +272,6 @@ out:
 static void
 nlm_destroy_host(struct nlm_host *host)
 {
-	struct rpc_clnt	*clnt;
-
 	BUG_ON(!list_empty(&host->h_lockowners));
 	BUG_ON(atomic_read(&host->h_count));
 
@@ -274,9 +280,7 @@ nlm_destroy_host(struct nlm_host *host)
 	 */
 	nsm_unmonitor(host);
 
-	clnt = host->h_rpcclnt;
-	if (clnt != NULL)
-		rpc_shutdown_client(clnt);
+	nlm_host_rpc_shutdown(host);
 	kfree(host);
 }
 
@@ -569,10 +573,7 @@ nlm_shutdown_hosts(void)
 	for (chain = nlm_hosts; chain < nlm_hosts + NLM_HOST_NRHASH; ++chain) {
 		hlist_for_each_entry(host, pos, chain, h_hash) {
 			host->h_expires = jiffies - 1;
-			if (host->h_rpcclnt) {
-				rpc_shutdown_client(host->h_rpcclnt);
-				host->h_rpcclnt = NULL;
-			}
+			nlm_host_rpc_shutdown(host);
 		}
 	}
 

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

[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux