Revert "initial attempt at freezing databases in priority order"
authorRonnie Sahlberg <ronniesahlberg@gmail.com>
Tue, 13 Oct 2009 09:55:36 +0000 (20:55 +1100)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Tue, 13 Oct 2009 09:55:36 +0000 (20:55 +1100)
This reverts commit 499e781b065f5195e021f33d428503b59b2189b8.

client/ctdb_client.c
include/ctdb_private.h
server/ctdb_control.c
server/ctdb_daemon.c
server/ctdb_freeze.c
server/ctdb_ltdb_server.c
server/ctdb_monitor.c
server/ctdb_recover.c
server/ctdb_recoverd.c

index e60a72ebb52f71e566d246b7ceb44537c6ddae94..b27086b579e463d168beed2aeb6c8cf9eb651b0d 100644 (file)
@@ -1986,14 +1986,7 @@ int ctdb_ctrl_freeze_priority(struct ctdb_context *ctdb, struct timeval timeout,
 /* Freeze all databases */
 int ctdb_ctrl_freeze(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode)
 {
-       int i;
-
-       for (i=1; i<=NUM_DB_PRIORITIES; i++) {
-               if (ctdb_ctrl_freeze_priority(ctdb, timeout, destnode, i) != 0) {
-                       return -1;
-               }
-       }
-       return 0;
+       return ctdb_ctrl_freeze_priority(ctdb, timeout, destnode, 0);
 }
 
 /*
@@ -2414,7 +2407,7 @@ int ctdb_ctrl_modflags(struct ctdb_context *ctdb, struct timeval timeout, uint32
        nodes = list_of_connected_nodes(ctdb, nodemap, tmp_ctx, true);
 
        if (ctdb_client_async_control(ctdb, CTDB_CONTROL_MODIFY_FLAGS,
-                                       nodes, 0,
+                                       nodes,
                                        timeout, false, data,
                                        NULL, NULL,
                                        NULL) != 0) {
@@ -2907,7 +2900,6 @@ int ctdb_client_async_wait(struct ctdb_context *ctdb, struct client_async_data *
 int ctdb_client_async_control(struct ctdb_context *ctdb,
                                enum ctdb_controls opcode,
                                uint32_t *nodes,
-                               uint64_t srvid,
                                struct timeval timeout,
                                bool dont_log_errors,
                                TDB_DATA data,
@@ -2933,7 +2925,7 @@ int ctdb_client_async_control(struct ctdb_context *ctdb,
        for (j=0; j<num_nodes; j++) {
                uint32_t pnn = nodes[j];
 
-               state = ctdb_control_send(ctdb, pnn, srvid, opcode, 
+               state = ctdb_control_send(ctdb, pnn, 0, opcode, 
                                          0, data, async_data, &timeout, NULL);
                if (state == NULL) {
                        DEBUG(DEBUG_ERR,(__location__ " Failed to call async control %u\n", (unsigned)opcode));
index b033949e4d73baf4a43c6d74275752d0d919b767..774a36603061e088b3534f11d4fb524bba5063e9 100644 (file)
@@ -364,7 +364,6 @@ enum ctdb_freeze_mode {CTDB_FREEZE_NONE, CTDB_FREEZE_PENDING, CTDB_FREEZE_FROZEN
 /* This capability is set if CTDB_LVS_PUBLIC_IP is set */
 #define CTDB_CAP_LVS                   0x00000004
 
-#define NUM_DB_PRIORITIES 3
 /* main state of the ctdb daemon */
 struct ctdb_context {
        struct event_context *ev;
@@ -375,10 +374,8 @@ struct ctdb_context {
        TALLOC_CTX *tickle_update_context;
        TALLOC_CTX *keepalive_ctx;
        struct ctdb_tunable tunable;
-       enum ctdb_freeze_mode freeze_mode[NUM_DB_PRIORITIES+1];
-       struct ctdb_freeze_handle *freeze_handles[NUM_DB_PRIORITIES+1];
-       bool freeze_transaction_started;
-       uint32_t freeze_transaction_id;
+       enum ctdb_freeze_mode freeze_mode;
+       struct ctdb_freeze_handle *freeze_handle;
        struct ctdb_address address;
        const char *name;
        const char *db_directory;
@@ -1175,7 +1172,7 @@ void ctdb_request_control_reply(struct ctdb_context *ctdb, struct ctdb_req_contr
                                TDB_DATA *outdata, int32_t status, const char *errormsg);
 
 int32_t ctdb_control_freeze(struct ctdb_context *ctdb, struct ctdb_req_control *c, bool *async_reply);
-int32_t ctdb_control_thaw(struct ctdb_context *ctdb, uint32_t priority);
+int32_t ctdb_control_thaw(struct ctdb_context *ctdb, struct ctdb_req_control *c);
 
 int ctdb_start_recoverd(struct ctdb_context *ctdb);
 void ctdb_stop_recoverd(struct ctdb_context *ctdb);
@@ -1314,7 +1311,7 @@ int ctdb_ctrl_get_all_tunables(struct ctdb_context *ctdb,
                               uint32_t destnode,
                               struct ctdb_tunable *tunables);
 
-int ctdb_start_freeze(struct ctdb_context *ctdb, uint32_t priority);
+void ctdb_start_freeze(struct ctdb_context *ctdb);
 
 bool parse_ip_mask(const char *s, const char *iface, ctdb_sock_addr *addr, unsigned *mask);
 bool parse_ip_port(const char *s, ctdb_sock_addr *addr);
@@ -1409,7 +1406,6 @@ int ctdb_client_async_wait(struct ctdb_context *ctdb, struct client_async_data *
 int ctdb_client_async_control(struct ctdb_context *ctdb,
                                enum ctdb_controls opcode,
                                uint32_t *nodes,
-                               uint64_t srvid,
                                struct timeval timeout,
                                bool dont_log_errors,
                                TDB_DATA data,
index 1574039d543d50987ef5b6f69a93bebafb972157..2f0b94072a04376cbeb38ea0ef34a8079fa3ce82 100644 (file)
@@ -98,15 +98,9 @@ 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.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->freeze_mode == CTDB_FREEZE_FROZEN);
                ctdb->statistics.recovering = (ctdb->recovery_mode == CTDB_RECOVERY_ACTIVE);
                outdata->dptr = (uint8_t *)&ctdb->statistics;
                outdata->dsize = sizeof(ctdb->statistics);
@@ -255,7 +249,7 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb,
 
        case CTDB_CONTROL_THAW:
                CHECK_CONTROL_DATA_SIZE(0);
-               return ctdb_control_thaw(ctdb, (uint32_t)c->srvid);
+               return ctdb_control_thaw(ctdb, c);
 
        case CTDB_CONTROL_SET_RECMODE:
                CHECK_CONTROL_DATA_SIZE(sizeof(uint32_t));              
index 5c4655d26e67fe850ec02b177afd13131bcfab1a..1a94cfc661ba60f037e5df8a65d0a146ed0177fc 100644 (file)
@@ -724,7 +724,7 @@ int ctdb_start_daemon(struct ctdb_context *ctdb, bool do_fork)
        }
 
        /* start frozen, then let the first election sort things out */
-       if (ctdb_blocking_freeze(ctdb)) {
+       if (!ctdb_blocking_freeze(ctdb)) {
                ctdb_fatal(ctdb, "Failed to get initial freeze\n");
        }
 
index 53a76f3b78b10bf26e3f3bd015e388d2428161ad..ed0bbe8d6cb64e60b1c2668ba8039d7712598264 100644 (file)
 /*
   lock all databases
  */
-static int ctdb_lock_all_databases(struct ctdb_context *ctdb, uint32_t priority)
+static int ctdb_lock_all_databases(struct ctdb_context *ctdb)
 {
        struct ctdb_db_context *ctdb_db;
        for (ctdb_db=ctdb->db_list;ctdb_db;ctdb_db=ctdb_db->next) {
-               if (ctdb_db->priority != priority) {
-                       continue;
-               }
                DEBUG(DEBUG_INFO,("locking database 0x%08x priority:%u %s\n", ctdb_db->db_id, ctdb_db->priority, ctdb_db->db_name));
                if (tdb_lockall(ctdb_db->ltdb->tdb) != 0) {
                        return -1;
@@ -53,17 +50,17 @@ struct ctdb_freeze_waiter {
        struct ctdb_freeze_waiter *next, *prev;
        struct ctdb_context *ctdb;
        struct ctdb_req_control *c;
-       uint32_t priority;
        int32_t status;
 };
 
 /* a handle to a freeze lock child process */
 struct ctdb_freeze_handle {
        struct ctdb_context *ctdb;
-       uint32_t priority;
        pid_t child;
        int fd;
        struct ctdb_freeze_waiter *waiters;
+       bool transaction_started;
+       uint32_t transaction_id;
 };
 
 /*
@@ -74,14 +71,9 @@ static int ctdb_freeze_handle_destructor(struct ctdb_freeze_handle *h)
        struct ctdb_context *ctdb = h->ctdb;
        struct ctdb_db_context *ctdb_db;
 
-       DEBUG(DEBUG_ERR,("Release freeze handler for prio %u\n", h->priority));
-
        /* cancel any pending transactions */
-       if (ctdb->freeze_transaction_started) {
+       if (ctdb->freeze_handle && ctdb->freeze_handle->transaction_started) {
                for (ctdb_db=ctdb->db_list;ctdb_db;ctdb_db=ctdb_db->next) {
-                       if (ctdb_db->priority != h->priority) {
-                               continue;
-                       }
                        tdb_add_flags(ctdb_db->ltdb->tdb, TDB_NOLOCK);
                        if (tdb_transaction_cancel(ctdb_db->ltdb->tdb) != 0) {
                                DEBUG(DEBUG_ERR,(__location__ " Failed to cancel transaction for db '%s'\n",
@@ -89,11 +81,11 @@ static int ctdb_freeze_handle_destructor(struct ctdb_freeze_handle *h)
                        }
                        tdb_remove_flags(ctdb_db->ltdb->tdb, TDB_NOLOCK);
                }
-               ctdb->freeze_transaction_started = false;
+               ctdb->freeze_handle->transaction_started = false;
        }
 
-       ctdb->freeze_mode[h->priority]    = CTDB_FREEZE_NONE;
-       ctdb->freeze_handles[h->priority] = NULL;
+       ctdb->freeze_mode = CTDB_FREEZE_NONE;
+       ctdb->freeze_handle = NULL;
 
        kill(h->child, SIGKILL);
        return 0;
@@ -109,8 +101,11 @@ static void ctdb_freeze_lock_handler(struct event_context *ev, struct fd_event *
        int32_t status;
        struct ctdb_freeze_waiter *w;
 
-       if (h->ctdb->freeze_mode[h->priority] == CTDB_FREEZE_FROZEN) {
+       if (h->ctdb->freeze_mode == CTDB_FREEZE_FROZEN) {
                DEBUG(DEBUG_INFO,("freeze child died - unfreezing\n"));
+               if (h->ctdb->freeze_handle == h) {
+                       h->ctdb->freeze_handle = NULL;
+               }
                talloc_free(h);
                return;
        }
@@ -127,12 +122,12 @@ static void ctdb_freeze_lock_handler(struct event_context *ev, struct fd_event *
                return;
        }
 
-       h->ctdb->freeze_mode[h->priority] = CTDB_FREEZE_FROZEN;
+       h->ctdb->freeze_mode = CTDB_FREEZE_FROZEN;
 
        /* notify the waiters */
-       while ((w = h->ctdb->freeze_handles[h->priority]->waiters)) {
+       while ((w = h->ctdb->freeze_handle->waiters)) {
                w->status = status;
-               DLIST_REMOVE(h->ctdb->freeze_handles[h->priority]->waiters, w);
+               DLIST_REMOVE(h->ctdb->freeze_handle->waiters, w);
                talloc_free(w);
        }
 }
@@ -141,7 +136,7 @@ static void ctdb_freeze_lock_handler(struct event_context *ev, struct fd_event *
   create a child which gets locks on all the open databases, then calls the callback telling the parent
   that it is done
  */
-static struct ctdb_freeze_handle *ctdb_freeze_lock(struct ctdb_context *ctdb, uint32_t priority)
+static struct ctdb_freeze_handle *ctdb_freeze_lock(struct ctdb_context *ctdb)
 {
        struct ctdb_freeze_handle *h;
        int fd[2];
@@ -150,8 +145,7 @@ static struct ctdb_freeze_handle *ctdb_freeze_lock(struct ctdb_context *ctdb, ui
        h = talloc_zero(ctdb, struct ctdb_freeze_handle);
        CTDB_NO_MEMORY_NULL(ctdb, h);
 
-       h->ctdb     = ctdb;
-       h->priority = priority;
+       h->ctdb = ctdb;
 
        /* use socketpair() instead of pipe() so we have bi-directional fds */
        if (socketpair(AF_UNIX, SOCK_STREAM, 0, fd) != 0) {
@@ -172,7 +166,7 @@ static struct ctdb_freeze_handle *ctdb_freeze_lock(struct ctdb_context *ctdb, ui
                int count = 0;
                /* in the child */
                close(fd[0]);
-               ret = ctdb_lock_all_databases(ctdb, priority);
+               ret = ctdb_lock_all_databases(ctdb);
                if (ret != 0) {
                        _exit(0);
                }
@@ -220,34 +214,27 @@ static struct ctdb_freeze_handle *ctdb_freeze_lock(struct ctdb_context *ctdb, ui
  */
 static int ctdb_freeze_waiter_destructor(struct ctdb_freeze_waiter *w)
 {
-       DLIST_REMOVE(w->ctdb->freeze_handles[w->priority]->waiters, w);
+       DLIST_REMOVE(w->ctdb->freeze_handle->waiters, w);
        ctdb_request_control_reply(w->ctdb, w->c, NULL, w->status, NULL);
        return 0;
 }
 
 /*
-  start the freeze process for a certain priority
+  start the freeze process
  */
-int ctdb_start_freeze(struct ctdb_context *ctdb, uint32_t priority)
+void ctdb_start_freeze(struct ctdb_context *ctdb)
 {
-       if ((priority < 1) || (priority > NUM_DB_PRIORITIES)) {
-               DEBUG(DEBUG_ERR,(__location__ " Invalid db priority : %u\n", priority));
-               return -1;
-       }
-
-       if (ctdb->freeze_mode[priority] == CTDB_FREEZE_FROZEN) {
+       if (ctdb->freeze_mode == CTDB_FREEZE_FROZEN) {
                /* we're already frozen */
-               return 0;
+               return;
        }
 
        /* if there isn't a freeze lock child then create one */
-       if (!ctdb->freeze_handles[priority]) {
-               ctdb->freeze_handles[priority] = ctdb_freeze_lock(ctdb, priority);
-               CTDB_NO_MEMORY(ctdb, ctdb->freeze_handles[priority]);
-               ctdb->freeze_mode[priority] = CTDB_FREEZE_PENDING;
+       if (!ctdb->freeze_handle) {
+               ctdb->freeze_handle = ctdb_freeze_lock(ctdb);
+               CTDB_NO_MEMORY_VOID(ctdb, ctdb->freeze_handle);
+               ctdb->freeze_mode = CTDB_FREEZE_PENDING;
        }
-
-       return 0;
 }
 
 /*
@@ -260,32 +247,21 @@ int32_t ctdb_control_freeze(struct ctdb_context *ctdb, struct ctdb_req_control *
 
        priority = (uint32_t)c->srvid;
 
-       DEBUG(DEBUG_ERR, ("Freeze priority %u\n", priority));
-
-       if ((priority < 1) || (priority > NUM_DB_PRIORITIES)) {
-               DEBUG(DEBUG_ERR,(__location__ " Invalid db priority : %u\n", priority));
-               return -1;
-       }
-
-       if (ctdb->freeze_mode[priority] == CTDB_FREEZE_FROZEN) {
+       if (ctdb->freeze_mode == CTDB_FREEZE_FROZEN) {
                /* we're already frozen */
                return 0;
        }
 
-       if (ctdb_start_freeze(ctdb, priority) != 0) {
-               DEBUG(DEBUG_ERR,(__location__ " Failed to start freezing databases with priority %u\n", priority));
-               return -1;
-       }
+       ctdb_start_freeze(ctdb);
 
        /* add ourselves to list of waiters */
-       w = talloc(ctdb->freeze_handles[priority], struct ctdb_freeze_waiter);
+       w = talloc(ctdb->freeze_handle, struct ctdb_freeze_waiter);
        CTDB_NO_MEMORY(ctdb, w);
-       w->ctdb     = ctdb;
-       w->c        = talloc_steal(w, c);
-       w->priority = priority;
-       w->status   = -1;
+       w->ctdb   = ctdb;
+       w->c      = talloc_steal(w, c);
+       w->status = -1;
        talloc_set_destructor(w, ctdb_freeze_waiter_destructor);
-       DLIST_ADD(ctdb->freeze_handles[priority]->waiters, w);
+       DLIST_ADD(ctdb->freeze_handle->waiters, w);
 
        /* we won't reply till later */
        *async_reply = True;
@@ -298,30 +274,29 @@ int32_t ctdb_control_freeze(struct ctdb_context *ctdb, struct ctdb_req_control *
  */
 bool ctdb_blocking_freeze(struct ctdb_context *ctdb)
 {
-       int i;
-
-       for (i=1; i<=NUM_DB_PRIORITIES; i++) {
-               if (ctdb_start_freeze(ctdb, i)) {
-                       DEBUG(DEBUG_ERR,(__location__ " Failed to freeze databases of prio %u\n", i));
-                       continue;
-               }
+       ctdb_start_freeze(ctdb);
 
-               /* block until frozen */
-               while (ctdb->freeze_mode[i] == CTDB_FREEZE_PENDING) {
-                       event_loop_once(ctdb->ev);
-               }
+       /* block until frozen */
+       while (ctdb->freeze_mode == CTDB_FREEZE_PENDING) {
+               event_loop_once(ctdb->ev);
        }
 
-       return 0;
+       return ctdb->freeze_mode == CTDB_FREEZE_FROZEN;
 }
 
 
-static void thaw_priority(struct ctdb_context *ctdb, uint32_t priority)
+
+/*
+  thaw the databases
+ */
+int32_t ctdb_control_thaw(struct ctdb_context *ctdb, struct ctdb_req_control *c)
 {
-       DEBUG(DEBUG_ERR,("Thawing priority %u\n", priority));
+       uint32_t priority;
+
+       priority = (uint32_t)c->srvid;
 
        /* cancel any pending transactions */
-       if (ctdb->freeze_transaction_started) {
+       if (ctdb->freeze_handle && ctdb->freeze_handle->transaction_started) {
                struct ctdb_db_context *ctdb_db;
 
                for (ctdb_db=ctdb->db_list;ctdb_db;ctdb_db=ctdb_db->next) {
@@ -333,7 +308,6 @@ static void thaw_priority(struct ctdb_context *ctdb, uint32_t priority)
                        tdb_remove_flags(ctdb_db->ltdb->tdb, TDB_NOLOCK);
                }
        }
-       ctdb->freeze_transaction_started = false;
 
 #if 0
        /* this hack can be used to get a copy of the databases at the end of a recovery */
@@ -345,30 +319,9 @@ static void thaw_priority(struct ctdb_context *ctdb, uint32_t priority)
        system("mkdir -p test.db.saved; /usr/bin/rsync --delete -a test.db/ test.db.saved/$$ 2>&1 > /dev/null");
 #endif
 
-       talloc_free(ctdb->freeze_handles[priority]);
-       ctdb->freeze_handles[priority] = NULL;
-}
-
-/*
-  thaw the databases
- */
-int32_t ctdb_control_thaw(struct ctdb_context *ctdb, uint32_t priority)
-{
-
-       if (priority > NUM_DB_PRIORITIES) {
-               DEBUG(DEBUG_ERR,(__location__ " Invalid db priority : %u\n", priority));
-               return -1;
-       }
-
-       if (priority == 0) {
-               int i;
-               for (i=1;i<=NUM_DB_PRIORITIES; i++) {
-                       thaw_priority(ctdb, i);
-               }
-       } else {
-               thaw_priority(ctdb, priority);
-       }
 
+       talloc_free(ctdb->freeze_handle);
+       ctdb->freeze_handle = NULL;
        ctdb_call_resend_all(ctdb);
        return 0;
 }
@@ -380,21 +333,19 @@ 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)
 {
        struct ctdb_db_context *ctdb_db;
-       int i;
 
-       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->freeze_mode != CTDB_FREEZE_FROZEN) {
+               DEBUG(DEBUG_ERR,(__location__ " Failed transaction_start while not frozen\n"));
+               return -1;
        }
 
+
        for (ctdb_db=ctdb->db_list;ctdb_db;ctdb_db=ctdb_db->next) {
                int ret;
 
                tdb_add_flags(ctdb_db->ltdb->tdb, TDB_NOLOCK);
 
-               if (ctdb->freeze_transaction_started) {
+               if (ctdb->freeze_handle->transaction_started) {
                        if (tdb_transaction_cancel(ctdb_db->ltdb->tdb) != 0) {
                                DEBUG(DEBUG_ERR,(__location__ " Failed to cancel transaction for db '%s'\n",
                                         ctdb_db->db_name));
@@ -415,8 +366,8 @@ int32_t ctdb_control_transaction_start(struct ctdb_context *ctdb, uint32_t id)
                }
        }
 
-       ctdb->freeze_transaction_started = true;
-       ctdb->freeze_transaction_id = id;
+       ctdb->freeze_handle->transaction_started = true;
+       ctdb->freeze_handle->transaction_id = id;
 
        return 0;
 }
@@ -427,21 +378,18 @@ int32_t ctdb_control_transaction_start(struct ctdb_context *ctdb, uint32_t id)
 int32_t ctdb_control_transaction_commit(struct ctdb_context *ctdb, uint32_t id)
 {
        struct ctdb_db_context *ctdb_db;
-       int i;
-       
-       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->freeze_mode != CTDB_FREEZE_FROZEN) {
+               DEBUG(DEBUG_ERR,(__location__ " Failed transaction_start while not frozen\n"));
+               return -1;
        }
 
-       if (!ctdb->freeze_transaction_started) {
+       if (!ctdb->freeze_handle->transaction_started) {
                DEBUG(DEBUG_ERR,(__location__ " transaction not started\n"));
                return -1;
        }
 
-       if (id != ctdb->freeze_transaction_id) {
+       if (id != ctdb->freeze_handle->transaction_id) {
                DEBUG(DEBUG_ERR,(__location__ " incorrect transaction id 0x%x in commit\n", id));
                return -1;
        }
@@ -461,15 +409,15 @@ int32_t ctdb_control_transaction_commit(struct ctdb_context *ctdb, uint32_t id)
                                }
                                tdb_remove_flags(ctdb_db->ltdb->tdb, TDB_NOLOCK);
                        }
-                       ctdb->freeze_transaction_started = false;
+                       ctdb->freeze_handle->transaction_started = false;
 
                        return -1;
                }
                tdb_remove_flags(ctdb_db->ltdb->tdb, TDB_NOLOCK);
        }
 
-       ctdb->freeze_transaction_started = false;
-       ctdb->freeze_transaction_id = 0;
+       ctdb->freeze_handle->transaction_started = false;
+       ctdb->freeze_handle->transaction_id = 0;
 
        return 0;
 }
@@ -482,27 +430,27 @@ int32_t ctdb_control_wipe_database(struct ctdb_context *ctdb, TDB_DATA indata)
        struct ctdb_control_wipe_database w = *(struct ctdb_control_wipe_database *)indata.dptr;
        struct ctdb_db_context *ctdb_db;
 
-       ctdb_db = find_ctdb_db(ctdb, w.db_id);
-       if (!ctdb_db) {
-               DEBUG(DEBUG_ERR,(__location__ " Unknown db 0x%x\n", w.db_id));
-               return -1;
-       }
-
-       if (ctdb->freeze_mode[ctdb_db->priority] != CTDB_FREEZE_FROZEN) {
+       if (ctdb->freeze_mode != CTDB_FREEZE_FROZEN) {
                DEBUG(DEBUG_ERR,(__location__ " Failed transaction_start while not frozen\n"));
                return -1;
        }
 
-       if (!ctdb->freeze_transaction_started) {
+       if (!ctdb->freeze_handle->transaction_started) {
                DEBUG(DEBUG_ERR,(__location__ " transaction not started\n"));
                return -1;
        }
 
-       if (w.transaction_id != ctdb->freeze_transaction_id) {
+       if (w.transaction_id != ctdb->freeze_handle->transaction_id) {
                DEBUG(DEBUG_ERR,(__location__ " incorrect transaction id 0x%x in commit\n", w.transaction_id));
                return -1;
        }
 
+       ctdb_db = find_ctdb_db(ctdb, w.db_id);
+       if (!ctdb_db) {
+               DEBUG(DEBUG_ERR,(__location__ " Unknown db 0x%x\n", w.db_id));
+               return -1;
+       }
+
        if (tdb_wipe_all(ctdb_db->ltdb->tdb) != 0) {
                DEBUG(DEBUG_ERR,(__location__ " Failed to wipe database for db '%s'\n",
                         ctdb_db->db_name));
index 49686eb51ae978eaf4e3d9d2554715450a33b7e9..8044c4ed2a1e064746170611c378794f9aa48e2b 100644 (file)
@@ -503,11 +503,6 @@ int32_t ctdb_control_set_db_priority(struct ctdb_context *ctdb, TDB_DATA indata)
                return -1;
        }
 
-       if ((db_prio->priority<1) || (db_prio->priority>NUM_DB_PRIORITIES)) {
-               DEBUG(DEBUG_ERR,("Trying to set invalid priority : %u\n", db_prio->priority));
-               return -1;
-       }
-
        ctdb_db->priority = db_prio->priority;
        DEBUG(DEBUG_INFO,("Setting DB priority to %u for db 0x%08x\n", db_prio->priority, db_prio->db_id));
 
index 486042346dea01908d2a46c9e6d75273c69b6a12..14da3b77e4bc2ecce4eedd3956076eb332721f32 100644 (file)
@@ -285,8 +285,7 @@ int32_t ctdb_control_modflags(struct ctdb_context *ctdb, TDB_DATA indata)
 {
        struct ctdb_node_flag_change *c = (struct ctdb_node_flag_change *)indata.dptr;
        struct ctdb_node *node;
-       int i;
-
+       
        if (c->pnn >= ctdb->num_nodes) {
                DEBUG(DEBUG_ERR,(__location__ " Node %d is invalid, num_nodes :%d\n", c->pnn, ctdb->num_nodes));
                return -1;
@@ -320,11 +319,7 @@ int32_t ctdb_control_modflags(struct ctdb_context *ctdb, TDB_DATA indata)
                */
                ctdb->vnn_map->generation = INVALID_GENERATION;
 
-               for (i=1; i<=NUM_DB_PRIORITIES; i++) {
-                       if (ctdb_start_freeze(ctdb, i) != 0) {
-                               DEBUG(DEBUG_ERR,(__location__ " Failed to freeze db priority %u\n", i));
-                       }
-               }
+               ctdb_start_freeze(ctdb);
                ctdb_release_all_ips(ctdb);
                ctdb->recovery_mode = CTDB_RECOVERY_ACTIVE;
        }
index f4e30921e7177a0bcab9a73a6b5c0a832a0257c8..b4428fa4946e9edaf6974a3081fe5ef973742fdb 100644 (file)
 /*
   lock all databases - mark only
  */
-static int ctdb_lock_all_databases_mark(struct ctdb_context *ctdb, uint32_t priority)
+static int ctdb_lock_all_databases_mark(struct ctdb_context *ctdb)
 {
        struct ctdb_db_context *ctdb_db;
-
-       if ((priority < 1) || (priority > NUM_DB_PRIORITIES)) {
-               DEBUG(DEBUG_ERR,(__location__ " Illegal priority when trying to mark all databases Prio:%u\n", priority));
-               return -1;
-       }
-
-       if (ctdb->freeze_mode[priority] != CTDB_FREEZE_FROZEN) {
+       if (ctdb->freeze_mode != CTDB_FREEZE_FROZEN) {
                DEBUG(DEBUG_ERR,("Attempt to mark all databases locked when not frozen\n"));
                return -1;
        }
        for (ctdb_db=ctdb->db_list;ctdb_db;ctdb_db=ctdb_db->next) {
-               if (ctdb_db->priority != priority) {
-                       continue;
-               }
                if (tdb_lockall_mark(ctdb_db->ltdb->tdb) != 0) {
                        return -1;
                }
@@ -58,23 +49,14 @@ static int ctdb_lock_all_databases_mark(struct ctdb_context *ctdb, uint32_t prio
 /*
   lock all databases - unmark only
  */
-static int ctdb_lock_all_databases_unmark(struct ctdb_context *ctdb, uint32_t priority)
+static int ctdb_lock_all_databases_unmark(struct ctdb_context *ctdb)
 {
        struct ctdb_db_context *ctdb_db;
-
-       if ((priority < 1) || (priority > NUM_DB_PRIORITIES)) {
-               DEBUG(DEBUG_ERR,(__location__ " Illegal priority when trying to mark all databases Prio:%u\n", priority));
-               return -1;
-       }
-
-       if (ctdb->freeze_mode[priority] != CTDB_FREEZE_FROZEN) {
+       if (ctdb->freeze_mode != CTDB_FREEZE_FROZEN) {
                DEBUG(DEBUG_ERR,("Attempt to unmark all databases locked when not frozen\n"));
                return -1;
        }
        for (ctdb_db=ctdb->db_list;ctdb_db;ctdb_db=ctdb_db->next) {
-               if (ctdb_db->priority != priority) {
-                       continue;
-               }
                if (tdb_lockall_unmark(ctdb_db->ltdb->tdb) != 0) {
                        return -1;
                }
@@ -108,13 +90,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->freeze_mode != CTDB_FREEZE_FROZEN) {
+               DEBUG(DEBUG_ERR,("Attempt to set vnnmap when not frozen\n"));
+               return -1;
        }
 
        talloc_free(ctdb->vnn_map);
@@ -336,6 +315,11 @@ int32_t ctdb_control_pull_db(struct ctdb_context *ctdb, TDB_DATA indata, TDB_DAT
        struct pulldb_data params;
        struct ctdb_marshall_buffer *reply;
 
+       if (ctdb->freeze_mode != CTDB_FREEZE_FROZEN) {
+               DEBUG(DEBUG_DEBUG,("rejecting ctdb_control_pull_db when not frozen\n"));
+               return -1;
+       }
+
        pull = (struct ctdb_control_pulldb *)indata.dptr;
        
        ctdb_db = find_ctdb_db(ctdb, pull->db_id);
@@ -344,11 +328,6 @@ 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) {
-               DEBUG(DEBUG_DEBUG,("rejecting ctdb_control_pull_db when not frozen\n"));
-               return -1;
-       }
-
        reply = talloc_zero(outdata, struct ctdb_marshall_buffer);
        CTDB_NO_MEMORY(ctdb, reply);
 
@@ -359,19 +338,19 @@ int32_t ctdb_control_pull_db(struct ctdb_context *ctdb, TDB_DATA indata, TDB_DAT
        params.len = offsetof(struct ctdb_marshall_buffer, data);
        params.failed = false;
 
-       if (ctdb_lock_all_databases_mark(ctdb, ctdb_db->priority) != 0) {
+       if (ctdb_lock_all_databases_mark(ctdb) != 0) {
                DEBUG(DEBUG_ERR,(__location__ " Failed to get lock on entired db - failing\n"));
                return -1;
        }
 
        if (tdb_traverse_read(ctdb_db->ltdb->tdb, traverse_pulldb, &params) == -1) {
                DEBUG(DEBUG_ERR,(__location__ " Failed to get traverse db '%s'\n", ctdb_db->db_name));
-               ctdb_lock_all_databases_unmark(ctdb, ctdb_db->priority);
+               ctdb_lock_all_databases_unmark(ctdb);
                talloc_free(params.pulldata);
                return -1;
        }
 
-       ctdb_lock_all_databases_unmark(ctdb, ctdb_db->priority);
+       ctdb_lock_all_databases_unmark(ctdb);
 
        outdata->dptr = (uint8_t *)params.pulldata;
        outdata->dsize = params.len;
@@ -389,6 +368,11 @@ int32_t ctdb_control_push_db(struct ctdb_context *ctdb, TDB_DATA indata)
        int i, ret;
        struct ctdb_rec_data *rec;
 
+       if (ctdb->freeze_mode != CTDB_FREEZE_FROZEN) {
+               DEBUG(DEBUG_DEBUG,("rejecting ctdb_control_push_db when not frozen\n"));
+               return -1;
+       }
+
        if (indata.dsize < offsetof(struct ctdb_marshall_buffer, data)) {
                DEBUG(DEBUG_ERR,(__location__ " invalid data in pulldb reply\n"));
                return -1;
@@ -400,12 +384,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) {
-               DEBUG(DEBUG_DEBUG,("rejecting ctdb_control_push_db when not frozen\n"));
-               return -1;
-       }
-
-       if (ctdb_lock_all_databases_mark(ctdb, ctdb_db->priority) != 0) {
+       if (ctdb_lock_all_databases_mark(ctdb) != 0) {
                DEBUG(DEBUG_ERR,(__location__ " Failed to get lock on entired db - failing\n"));
                return -1;
        }
@@ -444,11 +423,11 @@ int32_t ctdb_control_push_db(struct ctdb_context *ctdb, TDB_DATA indata)
        DEBUG(DEBUG_DEBUG,("finished push of %u records for dbid 0x%x\n",
                 reply->count, reply->db_id));
 
-       ctdb_lock_all_databases_unmark(ctdb, ctdb_db->priority);
+       ctdb_lock_all_databases_unmark(ctdb);
        return 0;
 
 failed:
-       ctdb_lock_all_databases_unmark(ctdb, ctdb_db->priority);
+       ctdb_lock_all_databases_unmark(ctdb);
        return -1;
 }
 
@@ -482,25 +461,25 @@ int32_t ctdb_control_set_dmaster(struct ctdb_context *ctdb, TDB_DATA indata)
        struct ctdb_control_set_dmaster *p = (struct ctdb_control_set_dmaster *)indata.dptr;
        struct ctdb_db_context *ctdb_db;
 
-       ctdb_db = find_ctdb_db(ctdb, p->db_id);
-       if (!ctdb_db) {
-               DEBUG(DEBUG_ERR,(__location__ " Unknown db 0x%08x\n", p->db_id));
+       if (ctdb->freeze_mode != CTDB_FREEZE_FROZEN) {
+               DEBUG(DEBUG_DEBUG,("rejecting ctdb_control_set_dmaster when not frozen\n"));
                return -1;
        }
 
-       if (ctdb->freeze_mode[ctdb_db->priority] != CTDB_FREEZE_FROZEN) {
-               DEBUG(DEBUG_DEBUG,("rejecting ctdb_control_set_dmaster when not frozen\n"));
+       ctdb_db = find_ctdb_db(ctdb, p->db_id);
+       if (!ctdb_db) {
+               DEBUG(DEBUG_ERR,(__location__ " Unknown db 0x%08x\n", p->db_id));
                return -1;
        }
 
-       if (ctdb_lock_all_databases_mark(ctdb,  ctdb_db->priority) != 0) {
+       if (ctdb_lock_all_databases_mark(ctdb) != 0) {
                DEBUG(DEBUG_ERR,(__location__ " Failed to get lock on entired db - failing\n"));
                return -1;
        }
 
        tdb_traverse(ctdb_db->ltdb->tdb, traverse_setdmaster, &p->dmaster);
 
-       ctdb_lock_all_databases_unmark(ctdb, ctdb_db->priority);
+       ctdb_lock_all_databases_unmark(ctdb);
        
        return 0;
 }
@@ -611,7 +590,7 @@ int32_t ctdb_control_set_recmode(struct ctdb_context *ctdb,
                                 const char **errormsg)
 {
        uint32_t recmode = *(uint32_t *)indata.dptr;
-       int i, ret;
+       int ret;
        struct ctdb_set_recmode_state *state;
        pid_t parent = getpid();
 
@@ -630,13 +609,11 @@ int32_t ctdb_control_set_recmode(struct ctdb_context *ctdb,
        }
 
 
-       for (i=1; i<=NUM_DB_PRIORITIES; i++) {
-               if (ctdb->freeze_mode[i] != CTDB_FREEZE_FROZEN) {
-                       DEBUG(DEBUG_ERR,("Attempt to change recovery mode to %u when not frozen\n", 
-                                recmode));
-                       (*errormsg) = "Cannot change recovery mode while not frozen";
-                       return -1;
-               }
+       if (ctdb->freeze_mode != CTDB_FREEZE_FROZEN) {
+               DEBUG(DEBUG_ERR,("Attempt to change recovery mode to %u when not frozen\n", 
+                        recmode));
+               (*errormsg) = "Cannot change recovery mode while not frozen";
+               return -1;
        }
 
        if (recmode != ctdb->recovery_mode) {
@@ -652,11 +629,9 @@ int32_t ctdb_control_set_recmode(struct ctdb_context *ctdb,
 
        /* some special handling when ending recovery mode */
 
-       /* force the databases to thaw */
-       for (i=1; i<=NUM_DB_PRIORITIES; i++) {
-               if (ctdb->freeze_handles[i] != NULL) {
-                       ctdb_control_thaw(ctdb, i);
-               }
+       /* force the databased to thaw */
+       if (ctdb->freeze_handle) {
+               ctdb_control_thaw(ctdb);
        }
 
        state = talloc(ctdb, struct ctdb_set_recmode_state);
index 512a37a55bcaf276e021d0dec1d90a0f8c455a0f..e78e1741f0df4e2257fc54c63b05a1ebe6c40bd0 100644 (file)
@@ -212,7 +212,7 @@ static int run_recovered_eventscript(struct ctdb_context *ctdb, struct ctdb_node
 
        nodes = list_of_active_nodes(ctdb, nodemap, tmp_ctx, true);
        if (ctdb_client_async_control(ctdb, CTDB_CONTROL_END_RECOVERY,
-                                       nodes, 0,
+                                       nodes,
                                        CONTROL_TIMEOUT(), false, tdb_null,
                                        NULL, NULL,
                                        NULL) != 0) {
@@ -288,7 +288,7 @@ static int run_startrecovery_eventscript(struct ctdb_recoverd *rec, struct ctdb_
 
        nodes = list_of_active_nodes(ctdb, nodemap, tmp_ctx, true);
        if (ctdb_client_async_control(ctdb, CTDB_CONTROL_START_RECOVERY,
-                                       nodes, 0,
+                                       nodes,
                                        CONTROL_TIMEOUT(), false, tdb_null,
                                        NULL,
                                        startrecovery_fail_callback,
@@ -326,8 +326,7 @@ static int update_capabilities(struct ctdb_context *ctdb, struct ctdb_node_map *
 
        nodes = list_of_active_nodes(ctdb, nodemap, tmp_ctx, true);
        if (ctdb_client_async_control(ctdb, CTDB_CONTROL_GET_CAPABILITIES,
-                                       nodes, 0,
-                                       CONTROL_TIMEOUT(),
+                                       nodes, CONTROL_TIMEOUT(),
                                        false, tdb_null,
                                        async_getcap_callback, NULL,
                                        NULL) != 0) {
@@ -363,20 +362,15 @@ static int set_recovery_mode(struct ctdb_context *ctdb, struct ctdb_recoverd *re
        /* freeze all nodes */
        nodes = list_of_active_nodes(ctdb, nodemap, tmp_ctx, true);
        if (rec_mode == CTDB_RECOVERY_ACTIVE) {
-               int i;
-
-               for (i=1; i<=NUM_DB_PRIORITIES; i++) {
-                       if (ctdb_client_async_control(ctdb, CTDB_CONTROL_FREEZE,
-                                               nodes, i,
-                                               CONTROL_TIMEOUT(),
+               if (ctdb_client_async_control(ctdb, CTDB_CONTROL_FREEZE,
+                                               nodes, CONTROL_TIMEOUT(),
                                                false, tdb_null,
                                                NULL,
                                                set_recmode_fail_callback,
                                                rec) != 0) {
-                               DEBUG(DEBUG_ERR, (__location__ " Unable to freeze nodes. Recovery failed.\n"));
-                               talloc_free(tmp_ctx);
-                               return -1;
-                       }
+                       DEBUG(DEBUG_ERR, (__location__ " Unable to freeze nodes. Recovery failed.\n"));
+                       talloc_free(tmp_ctx);
+                       return -1;
                }
        }
 
@@ -385,8 +379,7 @@ static int set_recovery_mode(struct ctdb_context *ctdb, struct ctdb_recoverd *re
        data.dptr = (unsigned char *)&rec_mode;
 
        if (ctdb_client_async_control(ctdb, CTDB_CONTROL_SET_RECMODE,
-                                       nodes, 0,
-                                       CONTROL_TIMEOUT(),
+                                       nodes, CONTROL_TIMEOUT(),
                                        false, data,
                                        NULL, NULL,
                                        NULL) != 0) {
@@ -416,7 +409,7 @@ static int set_recovery_master(struct ctdb_context *ctdb, struct ctdb_node_map *
 
        nodes = list_of_active_nodes(ctdb, nodemap, tmp_ctx, true);
        if (ctdb_client_async_control(ctdb, CTDB_CONTROL_SET_RECMASTER,
-                                       nodes, 0,
+                                       nodes,
                                        CONTROL_TIMEOUT(), false, data,
                                        NULL, NULL,
                                        NULL) != 0) {
@@ -463,7 +456,7 @@ static int update_db_priority_on_remote_nodes(struct ctdb_context *ctdb,
 
                if (ctdb_client_async_control(ctdb,
                                        CTDB_CONTROL_SET_DB_PRIORITY,
-                                       nodes, 0,
+                                       nodes,
                                        CONTROL_TIMEOUT(), false, data,
                                        NULL, NULL,
                                        NULL) != 0) {
@@ -1281,7 +1274,7 @@ static int push_recdb_database(struct ctdb_context *ctdb, uint32_t dbid,
 
        nodes = list_of_active_nodes(ctdb, nodemap, tmp_ctx, true);
        if (ctdb_client_async_control(ctdb, CTDB_CONTROL_PUSH_DB,
-                                       nodes, 0,
+                                       nodes,
                                        CONTROL_TIMEOUT(), false, outdata,
                                        NULL, NULL,
                                        NULL) != 0) {
@@ -1341,7 +1334,7 @@ static int recover_database(struct ctdb_recoverd *rec,
 
        nodes = list_of_active_nodes(ctdb, nodemap, recdb, true);
        if (ctdb_client_async_control(ctdb, CTDB_CONTROL_WIPE_DATABASE,
-                                       nodes, 0,
+                                       nodes,
                                        CONTROL_TIMEOUT(), false, data,
                                        NULL, NULL,
                                        NULL) != 0) {
@@ -1496,7 +1489,7 @@ static int do_recovery(struct ctdb_recoverd *rec,
 
        nodes = list_of_active_nodes(ctdb, nodemap, mem_ctx, true);
        if (ctdb_client_async_control(ctdb, CTDB_CONTROL_TRANSACTION_START,
-                                       nodes, 0,
+                                       nodes,
                                        CONTROL_TIMEOUT(), false, data,
                                        NULL, NULL,
                                        NULL) != 0) {
@@ -1517,7 +1510,7 @@ static int do_recovery(struct ctdb_recoverd *rec,
 
        /* commit all the changes */
        if (ctdb_client_async_control(ctdb, CTDB_CONTROL_TRANSACTION_COMMIT,
-                                       nodes, 0,
+                                       nodes,
                                        CONTROL_TIMEOUT(), false, data,
                                        NULL, NULL,
                                        NULL) != 0) {
@@ -2375,7 +2368,7 @@ static int get_remote_nodemaps(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx,
 
        nodes = list_of_active_nodes(ctdb, nodemap, mem_ctx, true);
        if (ctdb_client_async_control(ctdb, CTDB_CONTROL_GET_NODEMAP,
-                                       nodes, 0,
+                                       nodes,
                                        CONTROL_TIMEOUT(), false, tdb_null,
                                        async_getnodemap_callback,
                                        NULL,