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

[Cluster-devel] cluster/cman/daemon commands.c



CVSROOT:	/cvs/cluster
Module name:	cluster
Changes by:	pcaulfield sourceware org	2007-09-07 12:17:45

Modified files:
	cman/daemon    : commands.c 

Log message:
	Correctly reduce quorum when a node leaves using "cman_tool leave remove"
	bz#271701

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/cman/daemon/commands.c.diff?cvsroot=cluster&r1=1.69&r2=1.70

--- cluster/cman/daemon/commands.c	2007/08/28 16:51:39	1.69
+++ cluster/cman/daemon/commands.c	2007/09/07 12:17:45	1.70
@@ -96,7 +96,7 @@
 static int send_port_open_msg(unsigned char port);
 static int send_port_enquire(int nodeid);
 static void process_internal_message(char *data, int len, int nodeid, int byteswap);
-static void recalculate_quorum(int allow_decrease);
+static void recalculate_quorum(int allow_decrease, int by_current_nodes);
 static void send_kill(int nodeid, uint16_t reason);
 static char *killmsg_reason(int reason);
 
@@ -327,11 +327,11 @@
 }
 
 /* Recalculate cluster quorum, set quorate and notify changes */
-static void recalculate_quorum(int allow_decrease)
+static void recalculate_quorum(int allow_decrease, int by_current_nodes)
 {
 	unsigned int total_votes;
 
-	quorum = calculate_quorum(allow_decrease, 0, &total_votes);
+	quorum = calculate_quorum(allow_decrease, by_current_nodes?cluster_members:0, &total_votes);
 	set_quorate(total_votes);
 	notify_listeners(NULL, EVENT_REASON_STATECHANGE, 0);
 }
@@ -791,7 +791,7 @@
 		return -EINVAL;
 	}
 
-	recalculate_quorum(1);
+	recalculate_quorum(1, 0);
 
 	send_reconfigure(arg.nodeid, RECONFIG_PARAM_NODE_VOTES, arg.newvotes);
 
@@ -1034,7 +1034,7 @@
 	else {
 		log_msg(LOG_ERR, "Now got CCS information version %d, continuing\n", config_version);
 		config_error = 0;
-		recalculate_quorum(0);
+		recalculate_quorum(0, 0);
 	}
 }
 
@@ -1049,7 +1049,7 @@
 	if (quorum_device->last_hello.tv_sec + quorumdev_poll/1000 < now.tv_sec) {
 		quorum_device->state = NODESTATE_DEAD;
 		log_msg(LOG_INFO, "lost contact with quorum device\n");
-		recalculate_quorum(0);
+		recalculate_quorum(0, 0);
 	}
 	else {
 		openais_timer_add_duration((unsigned long long)quorumdev_poll*1000000, quorum_device,
@@ -1070,7 +1070,7 @@
 		gettimeofday(&quorum_device->last_hello, NULL);
                 if (quorum_device->state == NODESTATE_DEAD) {
                         quorum_device->state = NODESTATE_MEMBER;
-                        recalculate_quorum(0);
+                        recalculate_quorum(0, 0);
 
 			openais_timer_add_duration((unsigned long long)quorumdev_poll*1000000, quorum_device,
 						   quorum_device_timer_fn, &quorum_device_timer);
@@ -1079,7 +1079,7 @@
         else {
                 if (quorum_device->state == NODESTATE_MEMBER) {
                         quorum_device->state = NODESTATE_DEAD;
-                        recalculate_quorum(0);
+                        recalculate_quorum(0, 0);
 			openais_timer_delete(quorum_device_timer);
                 }
         }
@@ -1513,7 +1513,7 @@
 		if (config_version > msg->config_version) {
 			// TODO tell everyone else to update...
 		}
-		recalculate_quorum(0);
+		recalculate_quorum(0, 0);
 	}
 
 
@@ -1650,12 +1650,12 @@
 				node->expected_votes = msg->value;
 			}
 		}
-		recalculate_quorum(1);  /* Allow decrease */
+		recalculate_quorum(1, 0);  /* Allow decrease */
 		break;
 
 	case RECONFIG_PARAM_NODE_VOTES:
 		node->votes = msg->value;
-		recalculate_quorum(1);  /* Allow decrease */
+		recalculate_quorum(1, 0);  /* Allow decrease */
 		break;
 
 	case RECONFIG_PARAM_CONFIG_VERSION:
@@ -1664,7 +1664,7 @@
 				msg->value);
 
 			config_error = 1;
-			recalculate_quorum(0);
+			recalculate_quorum(0, 0);
 
 			wanted_config_version = config_version;
 			openais_timer_add_duration((unsigned long long)ccsd_poll_interval*1000000, NULL,
@@ -1977,7 +1977,7 @@
 		node->incarnation = incarnation;
 		node->state = NODESTATE_MEMBER;
 		cluster_members++;
-		recalculate_quorum(0);
+		recalculate_quorum(0, 0);
 	}
 }
 
@@ -2007,7 +2007,7 @@
 	case NODESTATE_MEMBER:
 		node->state = NODESTATE_DEAD;
 		cluster_members--;
-		recalculate_quorum(0);
+		recalculate_quorum(0, 0);
 		break;
 
 	case NODESTATE_AISONLY:
@@ -2018,10 +2018,10 @@
 		node->state = NODESTATE_DEAD;
 		cluster_members--;
 
-		if ((node->leave_reason & 0xF) == CLUSTER_LEAVEFLAG_REMOVED)
-			recalculate_quorum(1);
-		else
-			recalculate_quorum(0);
+		if ((node->leave_reason & 0xF) & CLUSTER_LEAVEFLAG_REMOVED) 
+			recalculate_quorum(1, 1);
+		else 
+			recalculate_quorum(0, 0);
 		break;
 
 	case NODESTATE_JOINING:


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