ctdb-ipalloc: Move ipalloc state initialisation to ipalloc.c
authorMartin Schwenke <martin@meltin.net>
Mon, 23 May 2016 04:28:33 +0000 (14:28 +1000)
committerAmitay Isaacs <amitay@samba.org>
Mon, 4 Jul 2016 13:42:25 +0000 (15:42 +0200)
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/server/ctdb_takeover.c
ctdb/server/ipalloc.c
ctdb/server/ipalloc.h

index 209ecba..00e0671 100644 (file)
@@ -1403,49 +1403,6 @@ determine_algorithm(const struct ctdb_tunable_list *tunables)
        }
 }
 
-static struct ipalloc_state *
-ipalloc_state_init(TALLOC_CTX *mem_ctx,
-                  uint32_t num_nodes,
-                  enum ipalloc_algorithm algorithm,
-                  bool no_ip_failback,
-                  uint32_t *force_rebalance_nodes)
-{
-       struct ipalloc_state *ipalloc_state =
-               talloc_zero(mem_ctx, struct ipalloc_state);
-       if (ipalloc_state == NULL) {
-               DEBUG(DEBUG_ERR, (__location__ " Out of memory\n"));
-               return NULL;
-       }
-
-       ipalloc_state->num = num_nodes;
-
-       ipalloc_state->noiptakeover =
-               talloc_zero_array(ipalloc_state,
-                                 bool,
-                                 ipalloc_state->num);
-       if (ipalloc_state->noiptakeover == NULL) {
-               DEBUG(DEBUG_ERR, (__location__ " Out of memory\n"));
-               goto fail;
-       }
-       ipalloc_state->noiphost =
-               talloc_zero_array(ipalloc_state,
-                                 bool,
-                                 ipalloc_state->num);
-       if (ipalloc_state->noiphost == NULL) {
-               DEBUG(DEBUG_ERR, (__location__ " Out of memory\n"));
-               goto fail;
-       }
-
-       ipalloc_state->algorithm = algorithm;
-       ipalloc_state->no_ip_failback = no_ip_failback;
-       ipalloc_state->force_rebalance_nodes = force_rebalance_nodes;
-
-       return ipalloc_state;
-fail:
-       talloc_free(ipalloc_state);
-       return NULL;
-}
-
 struct takeover_callback_data {
        uint32_t num_nodes;
        unsigned int *fail_count;
index 295671a..b1a74bc 100644 (file)
 
 #include "server/ipalloc_private.h"
 
+/* Initialise main ipalloc state and sub-structures */
+struct ipalloc_state *
+ipalloc_state_init(TALLOC_CTX *mem_ctx,
+                  uint32_t num_nodes,
+                  enum ipalloc_algorithm algorithm,
+                  bool no_ip_failback,
+                  uint32_t *force_rebalance_nodes)
+{
+       struct ipalloc_state *ipalloc_state =
+               talloc_zero(mem_ctx, struct ipalloc_state);
+       if (ipalloc_state == NULL) {
+               DEBUG(DEBUG_ERR, (__location__ " Out of memory\n"));
+               return NULL;
+       }
+
+       ipalloc_state->num = num_nodes;
+
+       ipalloc_state->noiptakeover =
+               talloc_zero_array(ipalloc_state,
+                                 bool,
+                                 ipalloc_state->num);
+       if (ipalloc_state->noiptakeover == NULL) {
+               DEBUG(DEBUG_ERR, (__location__ " Out of memory\n"));
+               goto fail;
+       }
+       ipalloc_state->noiphost =
+               talloc_zero_array(ipalloc_state,
+                                 bool,
+                                 ipalloc_state->num);
+       if (ipalloc_state->noiphost == NULL) {
+               DEBUG(DEBUG_ERR, (__location__ " Out of memory\n"));
+               goto fail;
+       }
+
+       ipalloc_state->algorithm = algorithm;
+       ipalloc_state->no_ip_failback = no_ip_failback;
+       ipalloc_state->force_rebalance_nodes = force_rebalance_nodes;
+
+       return ipalloc_state;
+fail:
+       talloc_free(ipalloc_state);
+       return NULL;
+}
+
 static void *add_ip_callback(void *parm, void *data)
 {
        struct public_ip_list *this_ip = parm;
index 990fca4..bb3ef1e 100644 (file)
@@ -22,6 +22,8 @@
 #ifndef __CTDB_IPALLOC_H__
 #define __CTDB_IPALLOC_H__
 
+#include <talloc.h>
+
 #include "replace.h"
 #include "system/network.h"
 
@@ -55,6 +57,12 @@ struct ipalloc_state {
        uint32_t *force_rebalance_nodes;
 };
 
+struct ipalloc_state * ipalloc_state_init(TALLOC_CTX *mem_ctx,
+                                         uint32_t num_nodes,
+                                         enum ipalloc_algorithm algorithm,
+                                         bool no_ip_failback,
+                                         uint32_t *force_rebalance_nodes);
+
 bool ipalloc_set_public_ips(struct ipalloc_state *ipalloc_state,
                            struct ctdb_public_ip_list *known_ips,
                            struct ctdb_public_ip_list *available_ips);