ctdb-recoverd: Move ctdb_ctrl_modflags() to ctdb_recoverd.c
authorMartin Schwenke <martin@meltin.net>
Tue, 5 May 2020 13:37:57 +0000 (23:37 +1000)
committerStefan Metzmacher <metze@samba.org>
Thu, 27 Aug 2020 10:48:07 +0000 (10:48 +0000)
This file is the only user of this function.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(cherry picked from commit a88c10c5a9afcf0a3dcadef07dd95af498bfa47a)

ctdb/include/ctdb_client.h
ctdb/server/ctdb_client.c
ctdb/server/ctdb_recoverd.c

index 198a8a38dbb2565decd67ac39bb6d0cc8d937346..b89c4e49b2f815694b841a6c5e662ab445d30662 100644 (file)
@@ -195,11 +195,6 @@ int ctdb_ctrl_get_ifaces(struct ctdb_context *ctdb,
                         TALLOC_CTX *mem_ctx,
                         struct ctdb_iface_list_old **ifaces);
 
-int ctdb_ctrl_modflags(struct ctdb_context *ctdb,
-                      struct timeval timeout,
-                      uint32_t destnode,
-                      uint32_t set, uint32_t clear);
-
 int ctdb_ctrl_get_all_tunables(struct ctdb_context *ctdb,
                               struct timeval timeout, uint32_t destnode,
                               struct ctdb_tunable_list *tunables);
index 453e7b2847773b5261c5061edfecabdb6481eb23..5d1a30d03dadcdd77e795ff4d698701c06ca2a1f 100644 (file)
@@ -1243,71 +1243,6 @@ int ctdb_ctrl_get_ifaces(struct ctdb_context *ctdb,
        return 0;
 }
 
-/*
-  set/clear the permanent disabled bit on a remote node
- */
-int ctdb_ctrl_modflags(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode,
-                      uint32_t set, uint32_t clear)
-{
-       int ret;
-       TDB_DATA data;
-       struct ctdb_node_map_old *nodemap=NULL;
-       struct ctdb_node_flag_change c;
-       TALLOC_CTX *tmp_ctx = talloc_new(ctdb);
-       uint32_t recmaster;
-       uint32_t *nodes;
-
-
-       /* find the recovery master */
-       ret = ctdb_ctrl_getrecmaster(ctdb, tmp_ctx, timeout, CTDB_CURRENT_NODE, &recmaster);
-       if (ret != 0) {
-               DEBUG(DEBUG_ERR, (__location__ " Unable to get recmaster from local node\n"));
-               talloc_free(tmp_ctx);
-               return ret;
-       }
-
-
-       /* read the node flags from the recmaster */
-       ret = ctdb_ctrl_getnodemap(ctdb, timeout, recmaster, tmp_ctx, &nodemap);
-       if (ret != 0) {
-               DEBUG(DEBUG_ERR, (__location__ " Unable to get nodemap from node %u\n", destnode));
-               talloc_free(tmp_ctx);
-               return -1;
-       }
-       if (destnode >= nodemap->num) {
-               DEBUG(DEBUG_ERR,(__location__ " Nodemap from recmaster does not contain node %d\n", destnode));
-               talloc_free(tmp_ctx);
-               return -1;
-       }
-
-       c.pnn       = destnode;
-       c.old_flags = nodemap->nodes[destnode].flags;
-       c.new_flags = c.old_flags;
-       c.new_flags |= set;
-       c.new_flags &= ~clear;
-
-       data.dsize = sizeof(c);
-       data.dptr = (unsigned char *)&c;
-
-       /* send the flags update to all connected nodes */
-       nodes = list_of_connected_nodes(ctdb, nodemap, tmp_ctx, true);
-
-       if (ctdb_client_async_control(ctdb, CTDB_CONTROL_MODIFY_FLAGS,
-                                       nodes, 0,
-                                       timeout, false, data,
-                                       NULL, NULL,
-                                       NULL) != 0) {
-               DEBUG(DEBUG_ERR, (__location__ " Unable to update nodeflags on remote nodes\n"));
-
-               talloc_free(tmp_ctx);
-               return -1;
-       }
-
-       talloc_free(tmp_ctx);
-       return 0;
-}
-
-
 /*
   get all tunables
  */
index acb6a7f401a673ccf90e030244b4695a6ee215f6..022593823828117deaf030b6e2b8307bc9122a7e 100644 (file)
@@ -424,6 +424,74 @@ static int set_recovery_mode(struct ctdb_context *ctdb,
        return 0;
 }
 
+/*
+ * Set/clear flags on a remote node
+ */
+static int ctdb_ctrl_modflags(struct ctdb_context *ctdb,
+                             struct timeval timeout,
+                             uint32_t destnode,
+                             uint32_t set,
+                             uint32_t clear)
+{
+       int ret;
+       TDB_DATA data;
+       struct ctdb_node_map_old *nodemap=NULL;
+       struct ctdb_node_flag_change c;
+       TALLOC_CTX *tmp_ctx = talloc_new(ctdb);
+       uint32_t recmaster;
+       uint32_t *nodes;
+
+
+       /* find the recovery master */
+       ret = ctdb_ctrl_getrecmaster(ctdb, tmp_ctx, timeout, CTDB_CURRENT_NODE, &recmaster);
+       if (ret != 0) {
+               DEBUG(DEBUG_ERR, (__location__ " Unable to get recmaster from local node\n"));
+               talloc_free(tmp_ctx);
+               return ret;
+       }
+
+
+       /* read the node flags from the recmaster */
+       ret = ctdb_ctrl_getnodemap(ctdb, timeout, recmaster, tmp_ctx, &nodemap);
+       if (ret != 0) {
+               DEBUG(DEBUG_ERR, (__location__ " Unable to get nodemap from node %u\n", destnode));
+               talloc_free(tmp_ctx);
+               return -1;
+       }
+       if (destnode >= nodemap->num) {
+               DEBUG(DEBUG_ERR,(__location__ " Nodemap from recmaster does not contain node %d\n", destnode));
+               talloc_free(tmp_ctx);
+               return -1;
+       }
+
+       c.pnn       = destnode;
+       c.old_flags = nodemap->nodes[destnode].flags;
+       c.new_flags = c.old_flags;
+       c.new_flags |= set;
+       c.new_flags &= ~clear;
+
+       data.dsize = sizeof(c);
+       data.dptr = (unsigned char *)&c;
+
+       /* send the flags update to all connected nodes */
+       nodes = list_of_connected_nodes(ctdb, nodemap, tmp_ctx, true);
+
+       if (ctdb_client_async_control(ctdb, CTDB_CONTROL_MODIFY_FLAGS,
+                                       nodes, 0,
+                                       timeout, false, data,
+                                       NULL, NULL,
+                                       NULL) != 0) {
+               DEBUG(DEBUG_ERR, (__location__ " Unable to update nodeflags on remote nodes\n"));
+
+               talloc_free(tmp_ctx);
+               return -1;
+       }
+
+       talloc_free(tmp_ctx);
+       return 0;
+}
+
+
 /*
  * Update flags on all connected nodes
  */