ctdb-ipalloc: Switch noiphost to struct bitmap
authorMartin Schwenke <martin@meltin.net>
Fri, 3 Feb 2017 01:28:44 +0000 (12:28 +1100)
committerMartin Schwenke <martins@samba.org>
Fri, 24 Feb 2017 06:47:11 +0000 (07:47 +0100)
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/server/ipalloc.c
ctdb/server/ipalloc_common.c
ctdb/server/ipalloc_private.h

index df638f01daa06f3319d5483db09d76422389df41..a0e497eaca8b28d1629f0411889c49f49c5e4b08 100644 (file)
@@ -52,10 +52,8 @@ ipalloc_state_init(TALLOC_CTX *mem_ctx,
 
        ipalloc_state->num = num_nodes;
 
-       ipalloc_state->noiphost =
-               talloc_zero_array(ipalloc_state,
-                                 bool,
-                                 ipalloc_state->num);
+       ipalloc_state->noiphost = bitmap_talloc(ipalloc_state,
+                                               ipalloc_state->num);
        if (ipalloc_state->noiphost == NULL) {
                DEBUG(DEBUG_ERR, (__location__ " Out of memory\n"));
                goto fail;
@@ -220,7 +218,7 @@ void ipalloc_set_node_flags(struct ipalloc_state *ipalloc_state,
        for (i=0;i<nodemap->num;i++) {
                /* Can not host IPs on INACTIVE node */
                if (nodemap->node[i].flags & NODE_FLAGS_INACTIVE) {
-                       ipalloc_state->noiphost[i] = true;
+                       bitmap_set(ipalloc_state->noiphost, i);
                }
 
                /* If node is disabled then it can only host IPs if
@@ -231,7 +229,7 @@ void ipalloc_set_node_flags(struct ipalloc_state *ipalloc_state,
                        if (!(all_disabled &&
                              ipalloc_state->no_ip_host_on_all_disabled == 0)) {
 
-                               ipalloc_state->noiphost[i] = true;
+                               bitmap_set(ipalloc_state->noiphost, i);
                        }
                }
        }
index d961b871739555996b362e1e062f2eafe257dc68..50bb59a593706221a7f2570a17f58bf2b3a41fbe 100644 (file)
@@ -61,7 +61,7 @@ static bool can_node_host_ip(struct ipalloc_state *ipalloc_state,
                             int32_t pnn,
                             struct public_ip_list *ip)
 {
-       if (ipalloc_state->noiphost[pnn]) {
+       if (bitmap_query(ipalloc_state->noiphost, pnn)) {
                return false;
        }
 
index cd74d9cc3f6fa4dbd96e17e51748c14ff527a73c..1f7385e4c476270899cb01f66fea49fc19c10674 100644 (file)
@@ -32,7 +32,7 @@ struct ipalloc_state {
        /* Arrays with data for each node */
        struct ctdb_public_ip_list *available_public_ips;
        struct ctdb_public_ip_list *known_public_ips;
-       bool *noiphost;
+       struct bitmap *noiphost;
 
        struct public_ip_list *all_ips;
        enum ipalloc_algorithm algorithm;