diff options
author | Martin Schwenke <martin@meltin.net> | 2020-07-29 17:57:53 +1000 |
---|---|---|
committer | Amitay Isaacs <amitay@samba.org> | 2022-07-22 16:09:31 +0000 |
commit | 0b5dd076046f254bb8d60c1b4377c32a3dc59a10 (patch) | |
tree | 09efb22468788bf0c12300470cadba9c9c6072ae /ctdb | |
parent | e396eb9fbc7b843181cf095051221305ff3578ed (diff) | |
download | samba-0b5dd076046f254bb8d60c1b4377c32a3dc59a10.tar.gz |
ctdb-recoverd: Add function node_flags() and use it in elections
Indexing a node map by PNN is suboptimal.
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Diffstat (limited to 'ctdb')
-rw-r--r-- | ctdb/server/ctdb_recoverd.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/ctdb/server/ctdb_recoverd.c b/ctdb/server/ctdb_recoverd.c index c293aa7f037..9c52fdf6029 100644 --- a/ctdb/server/ctdb_recoverd.c +++ b/ctdb/server/ctdb_recoverd.c @@ -290,6 +290,23 @@ static bool this_node_can_be_leader(struct ctdb_recoverd *rec) (rec->ctdb->capabilities & CTDB_CAP_RECMASTER) != 0; } +static bool node_flags(struct ctdb_recoverd *rec, uint32_t pnn, uint32_t *flags) +{ + size_t i; + + for (i = 0; i < rec->nodemap->num; i++) { + struct ctdb_node_and_flags *node = &rec->nodemap->nodes[i]; + if (node->pnn == pnn) { + if (flags != NULL) { + *flags = node->flags; + } + return true; + } + } + + return false; +} + /* ban a node for a period of time */ @@ -1398,6 +1415,7 @@ static void ctdb_election_data(struct ctdb_recoverd *rec, struct election_messag int ret; struct ctdb_node_map_old *nodemap; struct ctdb_context *ctdb = rec->ctdb; + bool ok; ZERO_STRUCTP(em); @@ -1410,7 +1428,11 @@ static void ctdb_election_data(struct ctdb_recoverd *rec, struct election_messag return; } - rec->node_flags = nodemap->nodes[rec->pnn].flags; + ok = node_flags(rec, rec->pnn, &rec->node_flags); + if (!ok) { + DBG_ERR("Unable to get node flags for this node\n"); + return; + } em->node_flags = rec->node_flags; for (i=0;i<nodemap->num;i++) { |