Skip to contentSkip to conversation

cluster/cman-kernel/src sm_joinleave.c sm_mess ...

Cluster-devel [email protected] 1 participant 1 message Sep 21, 2006

lore
Share & tools
lore
#0 lore raw

CVSROOT: /cvs/cluster
Module name: cluster
Branch: RHEL4
Changes by: teigland at sourceware.org 2006-09-21 15:09:26

Modified files:
cman-kernel/src: sm_joinleave.c sm_message.c

Log message:
Before choosing a new global id for a new group, a node discovers what the current max group id seen by any node in the cluster is and picks new=max+1. The problem is when two nodes do this in parallel for two different new groups (that are at the same level) and end up assigning the same global id to the two different groups. To fix this, we have a node take this max group id and add its own nodeid to it, so new=max+our_nodeid. This is similar to designating some of the id bits to be the nodeid of the node creating the group, but that method would break backward compatibility. bz 206193

Also, if we reach the max value of the global id counter (0xFFFFFF), then print a message and refuse to go ahead forming the group.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/cman-kernel/src/sm_joinleave.c.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.2&r2=1.2.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/cman-kernel/src/sm_message.c.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.4.2.1&r2=1.4.2.2

cman-kernel/src/Attic/sm_joinleave.c +2 -0
@@ -247,6 +247,8 @@
 	} else if (!pos && !wait && !restart && neg) {
 		/* we're the first in the cluster to join this sg */
 		sev->se_sg->global_id = sm_new_global_id(sev->se_sg->level);
+		if (sev->se_sg->global_id == 0)
+			error = -EOVERFLOW;
 	} else
 		error = -1;
 
cman-kernel/src/Attic/sm_message.c +4 -2
@@ -41,14 +41,16 @@
 
 uint32_t sm_new_global_id(int level)
 {
-	uint32_t id = global_last_id++;
+	uint32_t id = global_last_id + sm_our_nodeid;
 	uint8_t l = (uint8_t) level;
 
 	if (level > 255)
 		return 0;
 
-	if (id > 0x00FFFFFF)
+	if (id > 0x00FFFFFF) {
+		log_print("ERROR: max global group id");
 		return 0;
+	}
 
 	id |= (l << 24);
 	return id;