ctdb-ipalloc: Add no_ip_failback to ipalloc_state
authorMartin Schwenke <martin@meltin.net>
Thu, 29 Oct 2015 08:53:25 +0000 (19:53 +1100)
committerAmitay Isaacs <amitay@samba.org>
Fri, 20 Nov 2015 00:36:31 +0000 (01:36 +0100)
The IP allocation algorithms need the value of this tunable, so copy
it to avoid needing the CTDB context.

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

index c49e05ceac64778ce83331d5c6b3c8b01d22355b..26303855e7329c27ed37fcf7ab7f28e095e6fb0c 100644 (file)
@@ -67,6 +67,7 @@ struct ipalloc_state {
        struct ctdb_public_ip_list_old **available_public_ips;
 
        enum ipalloc_algorithm algorithm;
+       uint32_t no_ip_failback;
 };
 
 struct ctdb_interface {
@@ -2107,7 +2108,7 @@ static void ip_alloc_deterministic_ips(struct ctdb_context *ctdb,
         * IPs, since the modulo step above implicitly fails
         * back IPs to their "home" node.
         */
-       if (1 == ctdb->tunable.no_ip_failback) {
+       if (1 == ctdb->ipalloc_state->no_ip_failback) {
                DEBUG(DEBUG_WARNING, ("WARNING: 'NoIPFailback' set but ignored - incompatible with 'DeterministicIPs\n"));
        }
 
@@ -2134,7 +2135,7 @@ static void ip_alloc_nondeterministic_ips(struct ctdb_context *ctdb,
        basic_allocate_unassigned(ctdb, ipflags, all_ips);
 
        /* If we don't want IPs to fail back then don't rebalance IPs. */
-       if (1 == ctdb->tunable.no_ip_failback) {
+       if (1 == ctdb->ipalloc_state->no_ip_failback) {
                return;
        }
 
@@ -2163,7 +2164,7 @@ static void ip_alloc_lcp2(struct ctdb_context *ctdb,
        lcp2_allocate_unassigned(ctdb, ipflags, all_ips, lcp2_imbalances);
 
        /* If we don't want IPs to fail back then don't rebalance IPs. */
-       if (1 == ctdb->tunable.no_ip_failback) {
+       if (1 == ctdb->ipalloc_state->no_ip_failback) {
                goto finished;
        }
 
@@ -2482,6 +2483,8 @@ static struct ipalloc_state * ipalloc_state_init(struct ctdb_context *ctdb,
                ipalloc_state->algorithm = IPALLOC_NONDETERMINISTIC;
        }
 
+       ipalloc_state->no_ip_failback = ctdb->tunable.no_ip_failback;
+
        return ipalloc_state;
 }