From: Martin Schwenke Date: Thu, 29 Oct 2015 08:41:10 +0000 (+1100) Subject: ctdb-ipalloc: New enum ipalloc_algorithm in ipalloc_state X-Git-Url: http://git.samba.org/?a=commitdiff_plain;h=47ddd623581477bf0a40bd8330dfaf4d8f551752;p=obnox%2Fsamba%2Fsamba-obnox.git ctdb-ipalloc: New enum ipalloc_algorithm in ipalloc_state Algorithm-related tunables from the CTDB context no longer need to be accessed in the allocation logic. Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs --- diff --git a/ctdb/server/ctdb_takeover.c b/ctdb/server/ctdb_takeover.c index 1e30daf82b6..c49e05ceac6 100644 --- a/ctdb/server/ctdb_takeover.c +++ b/ctdb/server/ctdb_takeover.c @@ -53,12 +53,20 @@ struct ctdb_ipflags { bool noiphost; }; +enum ipalloc_algorithm { + IPALLOC_DETERMINISTIC, + IPALLOC_NONDETERMINISTIC, + IPALLOC_LCP2, +}; + struct ipalloc_state { uint32_t num; /* Arrays with data for each node */ struct ctdb_public_ip_list_old **known_public_ips; struct ctdb_public_ip_list_old **available_public_ips; + + enum ipalloc_algorithm algorithm; }; struct ctdb_interface { @@ -2214,12 +2222,16 @@ static void ctdb_takeover_run_core(struct ctdb_context *ctdb, */ *all_ips_p = create_merged_ip_list(ctdb); - if (1 == ctdb->tunable.lcp2_public_ip_assignment) { + switch (ctdb->ipalloc_state->algorithm) { + case IPALLOC_LCP2: ip_alloc_lcp2(ctdb, ipflags, *all_ips_p, force_rebalance_nodes); - } else if (1 == ctdb->tunable.deterministic_public_ips) { + break; + case IPALLOC_DETERMINISTIC: ip_alloc_deterministic_ips(ctdb, ipflags, *all_ips_p); - } else { + break; + case IPALLOC_NONDETERMINISTIC: ip_alloc_nondeterministic_ips(ctdb, ipflags, *all_ips_p); + break; } /* at this point ->pnn is the node which will own each IP @@ -2462,6 +2474,14 @@ static struct ipalloc_state * ipalloc_state_init(struct ctdb_context *ctdb, return NULL; } + if (1 == ctdb->tunable.lcp2_public_ip_assignment) { + ipalloc_state->algorithm = IPALLOC_LCP2; + } else if (1 == ctdb->tunable.deterministic_public_ips) { + ipalloc_state->algorithm = IPALLOC_DETERMINISTIC; + } else { + ipalloc_state->algorithm = IPALLOC_NONDETERMINISTIC; + } + return ipalloc_state; }