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;
}
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();
*/
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,
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) {
/*
* 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;
}
/*
* 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;
}
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);
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;
}
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;
}