Sfoglia il codice sorgente

votequorum: Don't update expected_votes display if value is too high

If expected_votes was set via the library but the calculation
decides it's too high, then an error is correctly returned but
the value is still set in the nodes' expected_votes field and
turns up in the corosync-quorumtool display.

This patch separates out the quorum calculation from the updating
of expected_votes per node to prevent this from happening.

Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
Christine Caulfield 9 anni fa
parent
commit
bd2e6b5d9d
1 ha cambiato i file con 20 aggiunte e 5 eliminazioni
  1. 20 5
      exec/votequorum.c

+ 20 - 5
exec/votequorum.c

@@ -931,11 +931,7 @@ static int calculate_quorum(int allow_decrease, unsigned int max_expected, unsig
 			   node->node_id, node->state, node->votes, node->expected_votes);
 
 		if (node->state == NODESTATE_MEMBER) {
-			if (max_expected) {
-				node->expected_votes = max_expected;
-			} else {
-				highest_expected = max(highest_expected, node->expected_votes);
-			}
+			highest_expected = max(highest_expected, node->expected_votes);
 			total_votes += node->votes;
 			total_nodes++;
 		}
@@ -986,6 +982,22 @@ static int calculate_quorum(int allow_decrease, unsigned int max_expected, unsig
 	return newquorum;
 }
 
+static void update_node_expected_votes(int new_expected_votes)
+{
+	struct list_head *nodelist;
+	struct cluster_node *node;
+
+	if (new_expected_votes) {
+		list_iterate(nodelist, &cluster_members_list) {
+			node = list_entry(nodelist, struct cluster_node, list);
+
+			if (node->state == NODESTATE_MEMBER) {
+				node->expected_votes = new_expected_votes;
+			}
+		}
+	}
+}
+
 static void are_we_quorate(unsigned int total_votes)
 {
 	int quorate;
@@ -1126,6 +1138,8 @@ static void recalculate_quorum(int allow_decrease, int by_current_nodes)
 	}
 
 	quorum = calculate_quorum(allow_decrease, cluster_members, &total_votes);
+	update_node_expected_votes(cluster_members);
+
 	are_we_quorate(total_votes);
 
 	LEAVE();
@@ -2651,6 +2665,7 @@ static void message_handler_req_lib_votequorum_setexpected (void *conn, const vo
 		error = CS_ERR_INVALID_PARAM;
 		goto error_exit;
 	}
+	update_node_expected_votes(req_lib_votequorum_setexpected->expected_votes);
 
 	votequorum_exec_send_reconfigure(VOTEQUORUM_RECONFIG_PARAM_EXPECTED_VOTES, us->node_id,
 					 req_lib_votequorum_setexpected->expected_votes);