summaryrefslogtreecommitdiff
path: root/ctdb
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2018-09-28 10:46:17 +1000
committerStefan Metzmacher <metze@samba.org>2020-08-27 10:48:07 +0000
commit6d8271ff3b7863bf9f4bcc7ee8bb6793c241a66a (patch)
treef6e6d65d26020f27dc026f573d7c89783661a0c3 /ctdb
parent267bb7faf222cd3160f5d9451aa86b29cff9787c (diff)
downloadsamba-6d8271ff3b7863bf9f4bcc7ee8bb6793c241a66a.tar.gz
ctdb-recoverd: Flatten update_flags_on_all_nodes()
The logic currently in ctdb_ctrl_modflags() will be optimised so that it no longer matches the pattern for a control function. So, remove this function and squash its functionality into the only caller. Although there are some superficial changes, the behaviour is unchanged. Flattening the 2 functions produces some seriously weird logic for setting the new flags, to the point where using ctdb_ctrl_modflags() for this purpose now looks very strange. The weirdness will be cleaned up in a subsequent commit. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com> (cherry picked from commit 0c6a7db3ba84b8355359b0a8c52690b234bb866d)
Diffstat (limited to 'ctdb')
-rw-r--r--ctdb/server/ctdb_recoverd.c69
1 files changed, 26 insertions, 43 deletions
diff --git a/ctdb/server/ctdb_recoverd.c b/ctdb/server/ctdb_recoverd.c
index 02259382382..e24a4578a2d 100644
--- a/ctdb/server/ctdb_recoverd.c
+++ b/ctdb/server/ctdb_recoverd.c
@@ -425,22 +425,21 @@ static int set_recovery_mode(struct ctdb_context *ctdb,
}
/*
- * Set/clear flags on a remote node
+ * Update flags on all connected nodes
*/
-static int ctdb_ctrl_modflags(struct ctdb_context *ctdb,
- struct timeval timeout,
- uint32_t destnode,
- uint32_t set,
- uint32_t clear)
+static int update_flags_on_all_nodes(struct ctdb_recoverd *rec,
+ uint32_t pnn,
+ uint32_t flags)
{
- int ret;
+ struct ctdb_context *ctdb = rec->ctdb;
+ struct timeval timeout = CONTROL_TIMEOUT();
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;
-
+ int ret;
/* find the recovery master */
ret = ctdb_ctrl_getrecmaster(ctdb, tmp_ctx, timeout, CTDB_CURRENT_NODE, &recmaster);
@@ -450,25 +449,24 @@ static int ctdb_ctrl_modflags(struct ctdb_context *ctdb,
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));
+ DBG_ERR("Unable to get nodemap from node %u\n", recmaster);
talloc_free(tmp_ctx);
return -1;
}
- if (destnode >= nodemap->num) {
- DEBUG(DEBUG_ERR,(__location__ " Nodemap from recmaster does not contain node %d\n", destnode));
+ if (pnn >= nodemap->num) {
+ DBG_ERR("Nodemap from recmaster does not contain node %d\n", pnn);
talloc_free(tmp_ctx);
return -1;
}
- c.pnn = destnode;
- c.old_flags = nodemap->nodes[destnode].flags;
+ c.pnn = pnn;
+ c.old_flags = nodemap->nodes[pnn].flags;
c.new_flags = c.old_flags;
- c.new_flags |= set;
- c.new_flags &= ~clear;
+ c.new_flags |= flags;
+ c.new_flags &= flags;
data.dsize = sizeof(c);
data.dptr = (unsigned char *)&c;
@@ -476,13 +474,18 @@ static int ctdb_ctrl_modflags(struct ctdb_context *ctdb,
/* 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"));
-
+ ret = ctdb_client_async_control(ctdb,
+ CTDB_CONTROL_MODIFY_FLAGS,
+ nodes,
+ 0,
+ timeout,
+ false,
+ data,
+ NULL,
+ NULL,
+ NULL);
+ if (ret != 0) {
+ DBG_ERR("Unable to update flags on remote nodes\n");
talloc_free(tmp_ctx);
return -1;
}
@@ -491,26 +494,6 @@ static int ctdb_ctrl_modflags(struct ctdb_context *ctdb,
return 0;
}
-
-/*
- * Update flags on all connected nodes
- */
-static int update_flags_on_all_nodes(struct ctdb_recoverd *rec,
- uint32_t pnn,
- uint32_t flags)
-{
- struct ctdb_context *ctdb = rec->ctdb;
- int ret;
-
- ret = ctdb_ctrl_modflags(ctdb, CONTROL_TIMEOUT(), pnn, flags, ~flags);
- if (ret != 0) {
- DEBUG(DEBUG_ERR, (__location__ " Unable to update nodeflags on remote nodes\n"));
- return -1;
- }
-
- return 0;
-}
-
/*
called when ctdb_wait_timeout should finish
*/