1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-03 01:18:10 +03:00

ctdb-recoverd: Simplify arguments to some election functions

The pnn and nodemap arguments to force_election() and
send_election_request() are always effectively rec->pnn and
rec->nodemap, so simplify.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
This commit is contained in:
Martin Schwenke 2021-12-08 19:27:01 +11:00 committed by Martin Schwenke
parent 9dbe7cc85e
commit 57882beb16

View File

@ -713,9 +713,7 @@ static void take_reclock_handler(char status,
s->done = true; s->done = true;
} }
static void force_election(struct ctdb_recoverd *rec, static void force_election(struct ctdb_recoverd *rec);
uint32_t pnn,
struct ctdb_node_map_old *nodemap);
static void lost_reclock_handler(void *private_data) static void lost_reclock_handler(void *private_data)
{ {
@ -725,7 +723,7 @@ static void lost_reclock_handler(void *private_data)
D_ERR("Recovery lock helper terminated, triggering an election\n"); D_ERR("Recovery lock helper terminated, triggering an election\n");
TALLOC_FREE(rec->recovery_lock_handle); TALLOC_FREE(rec->recovery_lock_handle);
force_election(rec, ctdb_get_pnn(rec->ctdb), rec->nodemap); force_election(rec);
} }
static bool ctdb_recovery_lock(struct ctdb_recoverd *rec) static bool ctdb_recovery_lock(struct ctdb_recoverd *rec)
@ -1378,7 +1376,7 @@ static bool ctdb_election_win(struct ctdb_recoverd *rec, struct election_message
/* /*
send out an election request send out an election request
*/ */
static int send_election_request(struct ctdb_recoverd *rec, uint32_t pnn) static int send_election_request(struct ctdb_recoverd *rec)
{ {
int ret; int ret;
TDB_DATA election_data; TDB_DATA election_data;
@ -1397,13 +1395,15 @@ static int send_election_request(struct ctdb_recoverd *rec, uint32_t pnn)
/* first we assume we will win the election and set /* first we assume we will win the election and set
recoverymaster to be ourself on the current node recoverymaster to be ourself on the current node
*/ */
ret = ctdb_ctrl_setrecmaster(ctdb, CONTROL_TIMEOUT(), ret = ctdb_ctrl_setrecmaster(ctdb,
CTDB_CURRENT_NODE, pnn); CONTROL_TIMEOUT(),
CTDB_CURRENT_NODE,
rec->pnn);
if (ret != 0) { if (ret != 0) {
DEBUG(DEBUG_ERR, (__location__ " failed to set recmaster\n")); DEBUG(DEBUG_ERR, (__location__ " failed to set recmaster\n"));
return -1; return -1;
} }
rec->recmaster = pnn; rec->recmaster = rec->pnn;
/* send an election message to all active nodes */ /* send an election message to all active nodes */
DEBUG(DEBUG_INFO,(__location__ " Send election request to all active nodes\n")); DEBUG(DEBUG_INFO,(__location__ " Send election request to all active nodes\n"));
@ -1420,7 +1420,7 @@ static void election_send_request(struct tevent_context *ev,
struct ctdb_recoverd *rec = talloc_get_type(p, struct ctdb_recoverd); struct ctdb_recoverd *rec = talloc_get_type(p, struct ctdb_recoverd);
int ret; int ret;
ret = send_election_request(rec, ctdb_get_pnn(rec->ctdb)); ret = send_election_request(rec);
if (ret != 0) { if (ret != 0) {
DEBUG(DEBUG_ERR,("Failed to send election request!\n")); DEBUG(DEBUG_ERR,("Failed to send election request!\n"));
} }
@ -1755,8 +1755,7 @@ static void election_handler(uint64_t srvid, TDB_DATA data, void *private_data)
/* /*
force the start of the election process force the start of the election process
*/ */
static void force_election(struct ctdb_recoverd *rec, uint32_t pnn, static void force_election(struct ctdb_recoverd *rec)
struct ctdb_node_map_old *nodemap)
{ {
int ret; int ret;
struct ctdb_context *ctdb = rec->ctdb; struct ctdb_context *ctdb = rec->ctdb;
@ -1764,7 +1763,7 @@ static void force_election(struct ctdb_recoverd *rec, uint32_t pnn,
DEBUG(DEBUG_INFO,(__location__ " Force an election\n")); DEBUG(DEBUG_INFO,(__location__ " Force an election\n"));
/* set all nodes to recovery mode to stop all internode traffic */ /* set all nodes to recovery mode to stop all internode traffic */
ret = set_recovery_mode(ctdb, rec, nodemap, CTDB_RECOVERY_ACTIVE); ret = set_recovery_mode(ctdb, rec, rec->nodemap, CTDB_RECOVERY_ACTIVE);
if (ret != 0) { if (ret != 0) {
DEBUG(DEBUG_ERR, (__location__ " Unable to set recovery mode to active on cluster\n")); DEBUG(DEBUG_ERR, (__location__ " Unable to set recovery mode to active on cluster\n"));
return; return;
@ -1778,7 +1777,7 @@ static void force_election(struct ctdb_recoverd *rec, uint32_t pnn,
timeval_current_ofs(ctdb->tunable.election_timeout, 0), timeval_current_ofs(ctdb->tunable.election_timeout, 0),
ctdb_election_timeout, rec); ctdb_election_timeout, rec);
ret = send_election_request(rec, pnn); ret = send_election_request(rec);
if (ret!=0) { if (ret!=0) {
DEBUG(DEBUG_ERR, (__location__ " failed to initiate recmaster election")); DEBUG(DEBUG_ERR, (__location__ " failed to initiate recmaster election"));
return; return;
@ -2331,7 +2330,7 @@ static bool validate_recovery_master(struct ctdb_recoverd *rec,
if (rec->recmaster == CTDB_UNKNOWN_PNN) { if (rec->recmaster == CTDB_UNKNOWN_PNN) {
DEBUG(DEBUG_NOTICE, DEBUG(DEBUG_NOTICE,
("Initial recovery master set - forcing election\n")); ("Initial recovery master set - forcing election\n"));
force_election(rec, pnn, nodemap); force_election(rec);
return false; return false;
} }
@ -2349,7 +2348,7 @@ static bool validate_recovery_master(struct ctdb_recoverd *rec,
(" Current recmaster node %u does not have CAP_RECMASTER," (" Current recmaster node %u does not have CAP_RECMASTER,"
" but we (node %u) have - force an election\n", " but we (node %u) have - force an election\n",
rec->recmaster, pnn)); rec->recmaster, pnn));
force_election(rec, pnn, nodemap); force_election(rec);
return false; return false;
} }
@ -2363,7 +2362,7 @@ static bool validate_recovery_master(struct ctdb_recoverd *rec,
DEBUG(DEBUG_ERR, DEBUG(DEBUG_ERR,
("Recmaster node %u has been deleted. Force election\n", ("Recmaster node %u has been deleted. Force election\n",
rec->recmaster)); rec->recmaster));
force_election(rec, pnn, nodemap); force_election(rec);
return false; return false;
} }
@ -2373,7 +2372,7 @@ static bool validate_recovery_master(struct ctdb_recoverd *rec,
DEBUG(DEBUG_NOTICE, DEBUG(DEBUG_NOTICE,
("Recmaster node %u is disconnected/deleted. Force election\n", ("Recmaster node %u is disconnected/deleted. Force election\n",
rec->recmaster)); rec->recmaster));
force_election(rec, pnn, nodemap); force_election(rec);
return false; return false;
} }
@ -2402,7 +2401,7 @@ static bool validate_recovery_master(struct ctdb_recoverd *rec,
*/ */
nodemap->nodes[rec->recmaster].flags = nodemap->nodes[rec->recmaster].flags =
recmaster_nodemap->nodes[rec->recmaster].flags; recmaster_nodemap->nodes[rec->recmaster].flags;
force_election(rec, pnn, nodemap); force_election(rec);
return false; return false;
} }
@ -2581,7 +2580,7 @@ static void main_loop(struct ctdb_context *ctdb, struct ctdb_recoverd *rec,
/* can not happen */ /* can not happen */
return; return;
case MONITOR_ELECTION_NEEDED: case MONITOR_ELECTION_NEEDED:
force_election(rec, pnn, nodemap); force_election(rec);
return; return;
case MONITOR_OK: case MONITOR_OK:
break; break;