mirror of
https://github.com/samba-team/samba.git
synced 2025-01-10 01:18:15 +03:00
ctdb-daemon: Avoid the use of ctdb->freeze_mode variable
Use ctdb->freeze_mode only in ctdb_freeze.c and use the functions to check if databases are frozen everywhere else. Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
This commit is contained in:
parent
056c44fda3
commit
8c58c7392f
@ -31,17 +31,9 @@ ctdb_ban_node_event(struct event_context *ev, struct timed_event *te,
|
||||
struct timeval t, void *private_data)
|
||||
{
|
||||
struct ctdb_context *ctdb = talloc_get_type(private_data, struct ctdb_context);
|
||||
bool freeze_failed = false;
|
||||
int i;
|
||||
|
||||
/* Make sure we were able to freeze databases during banning */
|
||||
for (i=1; i<=NUM_DB_PRIORITIES; i++) {
|
||||
if (ctdb->freeze_mode[i] != CTDB_FREEZE_FROZEN) {
|
||||
freeze_failed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (freeze_failed) {
|
||||
if (!ctdb_db_all_frozen(ctdb)) {
|
||||
DEBUG(DEBUG_ERR, ("Banning timedout, but still unable to freeze databases\n"));
|
||||
ctdb_ban_self(ctdb);
|
||||
return;
|
||||
|
@ -110,16 +110,10 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb,
|
||||
}
|
||||
|
||||
case CTDB_CONTROL_STATISTICS: {
|
||||
int i;
|
||||
CHECK_CONTROL_DATA_SIZE(0);
|
||||
ctdb->statistics.memory_used = talloc_total_size(NULL);
|
||||
ctdb->statistics.num_clients = ctdb->num_clients;
|
||||
ctdb->statistics.frozen = 0;
|
||||
for (i=1; i<= NUM_DB_PRIORITIES; i++) {
|
||||
if (ctdb->freeze_mode[i] == CTDB_FREEZE_FROZEN) {
|
||||
ctdb->statistics.frozen = 1;
|
||||
}
|
||||
}
|
||||
ctdb->statistics.frozen = (ctdb_db_all_frozen(ctdb) ? 1 : 0);
|
||||
ctdb->statistics.recovering = (ctdb->recovery_mode == CTDB_RECOVERY_ACTIVE);
|
||||
ctdb->statistics.statistics_current_time = timeval_current();
|
||||
|
||||
|
@ -351,13 +351,12 @@ int32_t ctdb_control_thaw(struct ctdb_context *ctdb, uint32_t priority,
|
||||
*/
|
||||
int32_t ctdb_control_transaction_start(struct ctdb_context *ctdb, uint32_t id)
|
||||
{
|
||||
int i, ret;
|
||||
int ret;
|
||||
|
||||
for (i=1;i<=NUM_DB_PRIORITIES; i++) {
|
||||
if (ctdb->freeze_mode[i] != CTDB_FREEZE_FROZEN) {
|
||||
DEBUG(DEBUG_ERR,(__location__ " Failed transaction_start while not frozen\n"));
|
||||
return -1;
|
||||
}
|
||||
if (!ctdb_db_all_frozen(ctdb)) {
|
||||
DEBUG(DEBUG_ERR, (__location__
|
||||
" failing transaction start while not frozen\n"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = ctdb_db_iterator(ctdb, db_transaction_start_handler,
|
||||
@ -394,11 +393,10 @@ int32_t ctdb_control_transaction_commit(struct ctdb_context *ctdb, uint32_t id)
|
||||
int healthy_nodes = 0;
|
||||
int ret;
|
||||
|
||||
for (i=1;i<=NUM_DB_PRIORITIES; i++) {
|
||||
if (ctdb->freeze_mode[i] != CTDB_FREEZE_FROZEN) {
|
||||
DEBUG(DEBUG_ERR,(__location__ " Failed transaction_start while not frozen\n"));
|
||||
return -1;
|
||||
}
|
||||
if (!ctdb_db_all_frozen(ctdb)) {
|
||||
DEBUG(DEBUG_ERR, (__location__
|
||||
" failing transaction commit while not frozen\n"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!ctdb->freeze_transaction_started) {
|
||||
|
@ -196,11 +196,10 @@ int ctdb_lockall_mark_prio(struct ctdb_context *ctdb, uint32_t priority)
|
||||
/*
|
||||
* This function is only used by the main dameon during recovery.
|
||||
* At this stage, the databases have already been locked, by a
|
||||
* dedicated child process. The freeze_mode variable is used to track
|
||||
* whether the actual locks are held by the child process or not.
|
||||
* dedicated child process.
|
||||
*/
|
||||
|
||||
if (ctdb->freeze_mode[priority] != CTDB_FREEZE_FROZEN) {
|
||||
if (!ctdb_db_prio_frozen(ctdb, priority)) {
|
||||
DEBUG(DEBUG_ERR, ("Attempt to mark all databases locked when not frozen\n"));
|
||||
return -1;
|
||||
}
|
||||
@ -256,11 +255,10 @@ int ctdb_lockall_unmark_prio(struct ctdb_context *ctdb, uint32_t priority)
|
||||
/*
|
||||
* This function is only used by the main daemon during recovery.
|
||||
* At this stage, the databases have already been locked, by a
|
||||
* dedicated child process. The freeze_mode variable is used to track
|
||||
* whether the actual locks are held by the child process or not.
|
||||
* dedicated child process.
|
||||
*/
|
||||
|
||||
if (ctdb->freeze_mode[priority] != CTDB_FREEZE_FROZEN) {
|
||||
if (!ctdb_db_prio_frozen(ctdb, priority)) {
|
||||
DEBUG(DEBUG_ERR, ("Attempt to unmark all databases locked when not frozen\n"));
|
||||
return -1;
|
||||
}
|
||||
|
@ -54,13 +54,10 @@ int
|
||||
ctdb_control_setvnnmap(struct ctdb_context *ctdb, uint32_t opcode, TDB_DATA indata, TDB_DATA *outdata)
|
||||
{
|
||||
struct ctdb_vnn_map_wire *map = (struct ctdb_vnn_map_wire *)indata.dptr;
|
||||
int i;
|
||||
|
||||
for(i=1; i<=NUM_DB_PRIORITIES; i++) {
|
||||
if (ctdb->freeze_mode[i] != CTDB_FREEZE_FROZEN) {
|
||||
DEBUG(DEBUG_ERR,("Attempt to set vnnmap when not frozen\n"));
|
||||
return -1;
|
||||
}
|
||||
if (!ctdb_db_all_frozen(ctdb)) {
|
||||
DEBUG(DEBUG_ERR,("Attempt to set vnnmap when not frozen\n"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
talloc_free(ctdb->vnn_map);
|
||||
@ -252,7 +249,7 @@ int32_t ctdb_control_pull_db(struct ctdb_context *ctdb, TDB_DATA indata, TDB_DAT
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (ctdb->freeze_mode[ctdb_db->priority] != CTDB_FREEZE_FROZEN) {
|
||||
if (!ctdb_db_prio_frozen(ctdb, ctdb_db->priority)) {
|
||||
DEBUG(DEBUG_DEBUG,("rejecting ctdb_control_pull_db when not frozen\n"));
|
||||
return -1;
|
||||
}
|
||||
@ -324,7 +321,7 @@ int32_t ctdb_control_push_db(struct ctdb_context *ctdb, TDB_DATA indata)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (ctdb->freeze_mode[ctdb_db->priority] != CTDB_FREEZE_FROZEN) {
|
||||
if (!ctdb_db_prio_frozen(ctdb, ctdb_db->priority)) {
|
||||
DEBUG(DEBUG_DEBUG,("rejecting ctdb_control_push_db when not frozen\n"));
|
||||
return -1;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user