mirror of
https://github.com/samba-team/samba.git
synced 2024-12-23 17:34:34 +03:00
ctdb-recoverd: Move ctdb_reload_remote_public_ips() to ctdb_takeover.c
This will help to untangle known and available public IP lists from the CTDB context. verify_remote_ip_allocation() needs a forward declaration. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
This commit is contained in:
parent
c37e3c05b0
commit
8cdae3ade6
@ -961,6 +961,8 @@ int ctdb_set_public_addresses(struct ctdb_context *ctdb, bool check_addresses);
|
||||
int ctdb_set_single_public_ip(struct ctdb_context *ctdb, const char *iface,
|
||||
const char *ip);
|
||||
|
||||
int ctdb_reload_remote_public_ips(struct ctdb_context *ctdb,
|
||||
struct ctdb_node_map_old *nodemap);
|
||||
int ctdb_takeover_run(struct ctdb_context *ctdb, struct ctdb_node_map_old *nodemap,
|
||||
uint32_t *force_rebalance_nodes,
|
||||
client_async_callback fail_callback, void *callback_data);
|
||||
@ -1007,9 +1009,6 @@ int32_t ctdb_control_del_public_address(struct ctdb_context *ctdb,
|
||||
struct ctdb_req_control_old *c,
|
||||
TDB_DATA recdata, bool *async_reply);
|
||||
|
||||
int verify_remote_ip_allocation(struct ctdb_context *ctdb,
|
||||
struct ctdb_public_ip_list_old *ips,
|
||||
uint32_t pnn);
|
||||
int update_ip_assignment_tree(struct ctdb_context *ctdb,
|
||||
struct ctdb_public_ip *ip);
|
||||
void clear_ip_assignment_tree(struct ctdb_context *ctdb);
|
||||
|
@ -1564,68 +1564,6 @@ static int recover_database(struct ctdb_recoverd *rec,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ctdb_reload_remote_public_ips(struct ctdb_context *ctdb,
|
||||
struct ctdb_node_map_old *nodemap)
|
||||
{
|
||||
int j;
|
||||
int ret;
|
||||
|
||||
if (ctdb->num_nodes != nodemap->num) {
|
||||
DEBUG(DEBUG_ERR, (__location__ " ctdb->num_nodes (%d) != nodemap->num (%d) invalid param\n",
|
||||
ctdb->num_nodes, nodemap->num));
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (j=0; j<nodemap->num; j++) {
|
||||
/* For readability */
|
||||
struct ctdb_node *node = ctdb->nodes[j];
|
||||
|
||||
/* release any existing data */
|
||||
TALLOC_FREE(node->known_public_ips);
|
||||
TALLOC_FREE(node->available_public_ips);
|
||||
|
||||
if (nodemap->nodes[j].flags & NODE_FLAGS_INACTIVE) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Retrieve the list of known public IPs from the node */
|
||||
ret = ctdb_ctrl_get_public_ips_flags(ctdb,
|
||||
CONTROL_TIMEOUT(),
|
||||
node->pnn,
|
||||
ctdb->nodes,
|
||||
0,
|
||||
&node->known_public_ips);
|
||||
if (ret != 0) {
|
||||
DEBUG(DEBUG_ERR,
|
||||
("Failed to read known public IPs from node: %u\n",
|
||||
node->pnn));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (ctdb->do_checkpublicip) {
|
||||
verify_remote_ip_allocation(ctdb,
|
||||
node->known_public_ips,
|
||||
node->pnn);
|
||||
}
|
||||
|
||||
/* Retrieve the list of available public IPs from the node */
|
||||
ret = ctdb_ctrl_get_public_ips_flags(ctdb,
|
||||
CONTROL_TIMEOUT(),
|
||||
node->pnn,
|
||||
ctdb->nodes,
|
||||
CTDB_PUBLIC_IP_FLAGS_ONLY_AVAILABLE,
|
||||
&node->available_public_ips);
|
||||
if (ret != 0) {
|
||||
DEBUG(DEBUG_ERR,
|
||||
("Failed to read available public IPs from node: %u\n",
|
||||
node->pnn));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* when we start a recovery, make sure all nodes use the same reclock file
|
||||
setting
|
||||
*/
|
||||
|
@ -1388,6 +1388,72 @@ static int getips_count_callback(void *param, void *data)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int verify_remote_ip_allocation(struct ctdb_context *ctdb,
|
||||
struct ctdb_public_ip_list_old *ips,
|
||||
uint32_t pnn);
|
||||
|
||||
int ctdb_reload_remote_public_ips(struct ctdb_context *ctdb,
|
||||
struct ctdb_node_map_old *nodemap)
|
||||
{
|
||||
int j;
|
||||
int ret;
|
||||
|
||||
if (ctdb->num_nodes != nodemap->num) {
|
||||
DEBUG(DEBUG_ERR, (__location__ " ctdb->num_nodes (%d) != nodemap->num (%d) invalid param\n",
|
||||
ctdb->num_nodes, nodemap->num));
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (j=0; j<nodemap->num; j++) {
|
||||
/* For readability */
|
||||
struct ctdb_node *node = ctdb->nodes[j];
|
||||
|
||||
/* release any existing data */
|
||||
TALLOC_FREE(node->known_public_ips);
|
||||
TALLOC_FREE(node->available_public_ips);
|
||||
|
||||
if (nodemap->nodes[j].flags & NODE_FLAGS_INACTIVE) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Retrieve the list of known public IPs from the node */
|
||||
ret = ctdb_ctrl_get_public_ips_flags(ctdb,
|
||||
TAKEOVER_TIMEOUT(),
|
||||
node->pnn,
|
||||
ctdb->nodes,
|
||||
0,
|
||||
&node->known_public_ips);
|
||||
if (ret != 0) {
|
||||
DEBUG(DEBUG_ERR,
|
||||
("Failed to read known public IPs from node: %u\n",
|
||||
node->pnn));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (ctdb->do_checkpublicip) {
|
||||
verify_remote_ip_allocation(ctdb,
|
||||
node->known_public_ips,
|
||||
node->pnn);
|
||||
}
|
||||
|
||||
/* Retrieve the list of available public IPs from the node */
|
||||
ret = ctdb_ctrl_get_public_ips_flags(ctdb,
|
||||
TAKEOVER_TIMEOUT(),
|
||||
node->pnn,
|
||||
ctdb->nodes,
|
||||
CTDB_PUBLIC_IP_FLAGS_ONLY_AVAILABLE,
|
||||
&node->available_public_ips);
|
||||
if (ret != 0) {
|
||||
DEBUG(DEBUG_ERR,
|
||||
("Failed to read available public IPs from node: %u\n",
|
||||
node->pnn));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct public_ip_list *
|
||||
create_merged_ip_list(struct ctdb_context *ctdb)
|
||||
{
|
||||
@ -4219,7 +4285,7 @@ int32_t ctdb_control_ipreallocated(struct ctdb_context *ctdb,
|
||||
node has the expected ip allocation.
|
||||
This is verified against ctdb->ip_tree
|
||||
*/
|
||||
int verify_remote_ip_allocation(struct ctdb_context *ctdb,
|
||||
static int verify_remote_ip_allocation(struct ctdb_context *ctdb,
|
||||
struct ctdb_public_ip_list_old *ips,
|
||||
uint32_t pnn)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user