diff options
Diffstat (limited to 'ctdb/server/ctdb_recoverd.c')
-rw-r--r-- | ctdb/server/ctdb_recoverd.c | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/ctdb/server/ctdb_recoverd.c b/ctdb/server/ctdb_recoverd.c index acb6a7f401a..02259382382 100644 --- a/ctdb/server/ctdb_recoverd.c +++ b/ctdb/server/ctdb_recoverd.c @@ -425,6 +425,74 @@ static int set_recovery_mode(struct ctdb_context *ctdb, } /* + * 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 */ static int update_flags_on_all_nodes(struct ctdb_recoverd *rec, |