From: Martin Schwenke Date: Fri, 9 Jul 2021 04:37:19 +0000 (+1000) Subject: ctdb-tools: Use disable and enable controls in tool X-Git-Tag: ldb-2.5.0~741 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5914054698dab934fd4db5efb9d211b2fdc40bb9;p=thirdparty%2Fsamba.git 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 Reviewed-by: Amitay Isaacs --- diff --git a/ctdb/tools/ctdb.c b/ctdb/tools/ctdb.c index 598ab4ff4b7..8370e11f8e6 100644 --- a/ctdb/tools/ctdb.c +++ b/ctdb/tools/ctdb.c @@ -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; }