From 5bb6ec6af2359a5b463349df54c168741cb1aca3 Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Fri, 3 Feb 2017 12:28:44 +1100 Subject: ctdb-ipalloc: Switch noiphost to struct bitmap Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs --- ctdb/server/ipalloc.c | 10 ++++------ ctdb/server/ipalloc_common.c | 2 +- ctdb/server/ipalloc_private.h | 2 +- 3 files changed, 6 insertions(+), 8 deletions(-) (limited to 'ctdb') diff --git a/ctdb/server/ipalloc.c b/ctdb/server/ipalloc.c index df638f01daa..a0e497eaca8 100644 --- a/ctdb/server/ipalloc.c +++ b/ctdb/server/ipalloc.c @@ -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;inum;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); } } } diff --git a/ctdb/server/ipalloc_common.c b/ctdb/server/ipalloc_common.c index d961b871739..50bb59a5937 100644 --- a/ctdb/server/ipalloc_common.c +++ b/ctdb/server/ipalloc_common.c @@ -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; } diff --git a/ctdb/server/ipalloc_private.h b/ctdb/server/ipalloc_private.h index cd74d9cc3f6..1f7385e4c47 100644 --- a/ctdb/server/ipalloc_private.h +++ b/ctdb/server/ipalloc_private.h @@ -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; -- cgit v1.2.1