mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
ctdb-ipalloc: Move ipalloc state initialisation to ipalloc.c
Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
This commit is contained in:
parent
38f4616bdd
commit
ee7fc252c8
@ -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;
|
||||
|
@ -31,6 +31,50 @@
|
||||
|
||||
#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;
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user