ctdb-takeover: Count takeover run failures
authorMartin Schwenke <martin@meltin.net>
Thu, 5 May 2016 05:36:12 +0000 (15:36 +1000)
committerAmitay Isaacs <amitay@samba.org>
Fri, 13 May 2016 11:47:17 +0000 (13:47 +0200)
This will allow banning credits assignments to be limited according to
some criteria.

Note that this only matters when multiple controls are sent to each
node: RELEASE_IP and TAKEOVER_IP.  This doesn't change the behaviour
for IPREALLOCATED.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/server/ctdb_takeover.c

index 97b2c64e3026ef42c709f44657fdf1225d840d54..996808f3b5bc74ded2731783c8f24e07c8f4e26b 100644 (file)
@@ -1554,7 +1554,7 @@ fail:
 
 struct takeover_callback_data {
        uint32_t num_nodes;
-       bool *node_failed;
+       unsigned int *fail_count;
 };
 
 static struct takeover_callback_data *
@@ -1569,9 +1569,9 @@ takeover_callback_data_init(TALLOC_CTX *mem_ctx,
                return NULL;
        }
 
-       takeover_data->node_failed = talloc_zero_array(takeover_data,
-                                                      bool, num_nodes);
-       if (takeover_data->node_failed == NULL) {
+       takeover_data->fail_count = talloc_zero_array(takeover_data,
+                                                     unsigned int, num_nodes);
+       if (takeover_data->fail_count == NULL) {
                DEBUG(DEBUG_ERR, (__location__ " out of memory\n"));
                talloc_free(takeover_data);
                return NULL;
@@ -1595,13 +1595,12 @@ static void takeover_run_fail_callback(struct ctdb_context *ctdb,
                return;
        }
 
-       if (!cd->node_failed[node_pnn]) {
+       if (cd->fail_count[node_pnn] == 0) {
                int ret;
                TDB_DATA data;
 
                DEBUG(DEBUG_ERR,
                      ("Node %u failed the takeover run\n", node_pnn));
-               cd->node_failed[node_pnn] = true;
 
                data.dptr = (uint8_t *)&node_pnn;
                data.dsize = sizeof(uint32_t);
@@ -1615,6 +1614,8 @@ static void takeover_run_fail_callback(struct ctdb_context *ctdb,
                               node_pnn));
                }
        }
+
+       cd->fail_count[node_pnn]++;
 }
 
 /*