[Cluster-devel] [DLM][PATCH] lowcomms init fixes

Josef Bacik jwhiter at redhat.com
Fri Apr 20 20:25:52 UTC 2007


Hello,

This patch resolves 2 problems.  First, if we tear everything down, the
connection cache and everything, and then go to create it again because we've
registered a new lockspace, we will get a garbage connection for the first
connection, because we never destroy the idr, which will still be holding
references to memory.  So this patch init's the connections_idr everytime
lowcomms starts so we can make sure we don't have this problem.  The second
problem is that when we go to destroy all of the connections and remove the
dlm_conn kmem cache, it will complain because there are still things allocated.
This is because we generally do this

for (i = 0; i < max_nodeid; i++)

where max_nodeid is set to whatever the highest nodeid is requested, which
starts at 0, so we will always leave 1 thing allocated.  This patch makes us set
max_nodid appropriately, and fixes an inconsistent for loop in the code.  Thank
you,

Josef

diff --git a/fs/dlm/lowcomms.c b/fs/dlm/lowcomms.c
index 2b32f3c..66986be 100644
--- a/fs/dlm/lowcomms.c
+++ b/fs/dlm/lowcomms.c
@@ -196,7 +196,7 @@ static struct connection *__nodeid2con(i
 	}
 
 	if (nodeid > max_nodeid)
-		max_nodeid = nodeid;
+		max_nodeid = nodeid + 1;
 
 	return con;
 }
@@ -380,7 +380,7 @@ static void sctp_init_failed(void)
 	struct connection *con;
 
 	down(&connections_lock);
-	for (i=1; i<=max_nodeid; i++) {
+	for (i=1; i<max_nodeid; i++) {
 		con = __nodeid2con(i, 0);
 		if (!con)
 			continue;
@@ -1424,6 +1424,7 @@ int dlm_lowcomms_start(void)
 	int error = -EINVAL;
 	struct connection *con;
 
+	idr_init(&connections_idr);
 	init_local();
 	if (!dlm_local_count) {
 		log_print("no local IP address has been set");
@@ -1437,6 +1438,9 @@ int dlm_lowcomms_start(void)
 	if (!con_cache)
 		goto out;
 
+	/* set a default max_nodeid, it will be reset if we need more */
+	max_nodeid = 0;
+
 	/* Set some sysctl minima */
 	if (sysctl_rmem_max < NEEDED_RMEM)
 		sysctl_rmem_max = NEEDED_RMEM;




More information about the Cluster-devel mailing list