ctdb-tools: Use disable and enable controls in tool
authorMartin Schwenke <martin@meltin.net>
Fri, 9 Jul 2021 04:37:19 +0000 (14:37 +1000)
committerAmitay Isaacs <amitay@samba.org>
Thu, 9 Sep 2021 01:46:49 +0000 (01:46 +0000)
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>
ctdb/tools/ctdb.c

index 598ab4ff4b7e84b63d9a602e555d3fd01458b7b7..8370e11f8e6829312a521337a676f727be9ded71 100644 (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;
        }