1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-08 21:18:16 +03:00

ctdb-tools: Use disable and enable controls in tool

Note that there a change from broadcast to a directed control here.
This is OK because the recovery master will push flags if any nodes
disagree with the canonical flags fetched from a node.

Static function ctdb_ctrl_modflags() is no longer used to drop it.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14784
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
This commit is contained in:
Martin Schwenke 2021-07-09 14:37:19 +10:00 committed by Amitay Isaacs
parent 6fe6a54e7f
commit 5914054698

View File

@ -2573,40 +2573,6 @@ static void wait_for_flags(TALLOC_CTX *mem_ctx, struct ctdb_context *ctdb,
}
}
static int ctdb_ctrl_modflags(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
struct ctdb_client_context *client,
uint32_t destnode, struct timeval timeout,
uint32_t set, uint32_t clear)
{
struct ctdb_node_map *nodemap;
struct ctdb_node_flag_change flag_change;
struct ctdb_req_control request;
uint32_t *pnn_list;
int ret, count;
ret = ctdb_ctrl_get_nodemap(mem_ctx, ev, client, destnode,
tevent_timeval_zero(), &nodemap);
if (ret != 0) {
return ret;
}
flag_change.pnn = destnode;
flag_change.old_flags = nodemap->node[destnode].flags;
flag_change.new_flags = flag_change.old_flags | set;
flag_change.new_flags &= ~clear;
count = list_of_connected_nodes(nodemap, -1, mem_ctx, &pnn_list);
if (count == -1) {
return ENOMEM;
}
ctdb_req_control_modify_flags(&request, &flag_change);
ret = ctdb_client_control_multi(mem_ctx, ev, client, pnn_list, count,
tevent_timeval_zero(), &request,
NULL, NULL);
return ret;
}
struct ipreallocate_state {
int status;
bool done;
@ -2688,13 +2654,13 @@ static int control_disable(TALLOC_CTX *mem_ctx, struct ctdb_context *ctdb,
return 0;
}
ret = ctdb_ctrl_modflags(mem_ctx, ctdb->ev, ctdb->client,
ctdb->cmd_pnn, TIMEOUT(),
NODE_FLAGS_PERMANENTLY_DISABLED, 0);
ret = ctdb_ctrl_disable_node(mem_ctx,
ctdb->ev,
ctdb->client,
ctdb->cmd_pnn,
TIMEOUT());
if (ret != 0) {
fprintf(stderr,
"Failed to set DISABLED flag on node %u\n",
ctdb->cmd_pnn);
fprintf(stderr, "Failed to disable node %u\n", ctdb->cmd_pnn);
return ret;
}
@ -2717,12 +2683,13 @@ static int control_enable(TALLOC_CTX *mem_ctx, struct ctdb_context *ctdb,
return 0;
}
ret = ctdb_ctrl_modflags(mem_ctx, ctdb->ev, ctdb->client,
ctdb->cmd_pnn, TIMEOUT(),
0, NODE_FLAGS_PERMANENTLY_DISABLED);
ret = ctdb_ctrl_enable_node(mem_ctx,
ctdb->ev,
ctdb->client,
ctdb->cmd_pnn,
TIMEOUT());
if (ret != 0) {
fprintf(stderr, "Failed to reset DISABLED flag on node %u\n",
ctdb->cmd_pnn);
fprintf(stderr, "Failed to enable node %u\n", ctdb->cmd_pnn);
return ret;
}