uptade the freeze/thaw commands to be able to send the requested database priority...
authorRonnie Sahlberg <ronniesahlberg@gmail.com>
Sun, 11 Oct 2009 22:22:17 +0000 (09:22 +1100)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Sun, 11 Oct 2009 22:22:17 +0000 (09:22 +1100)
this is encoded in the srvid field of the request header

client/ctdb_client.c
include/ctdb.h
include/ctdb_private.h
server/ctdb_control.c
server/ctdb_freeze.c
tools/ctdb.c

index 3134f629b006a9cd38c29607091c298d1df677e4..c7f0162cac262434b0d69ad1d49b6bdf5db8cc46 100644 (file)
@@ -1910,9 +1910,9 @@ int ctdb_ctrl_getpid(struct ctdb_context *ctdb, struct timeval timeout, uint32_t
   async freeze send control
  */
 struct ctdb_client_control_state *
-ctdb_ctrl_freeze_send(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, struct timeval timeout, uint32_t destnode)
+ctdb_ctrl_freeze_send(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, struct timeval timeout, uint32_t destnode, uint32_t priority)
 {
-       return ctdb_control_send(ctdb, destnode, 0
+       return ctdb_control_send(ctdb, destnode, priority
                           CTDB_CONTROL_FREEZE, 0, tdb_null, 
                           mem_ctx, &timeout, NULL);
 }
@@ -1935,30 +1935,36 @@ int ctdb_ctrl_freeze_recv(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, struct
 }
 
 /*
-  freeze a node
+  freeze databases of a certain priority
  */
-int ctdb_ctrl_freeze(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode)
+int ctdb_ctrl_freeze_priority(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t priority)
 {
        TALLOC_CTX *tmp_ctx = talloc_new(ctdb);
        struct ctdb_client_control_state *state;
        int ret;
 
-       state = ctdb_ctrl_freeze_send(ctdb, tmp_ctx, timeout, destnode);
+       state = ctdb_ctrl_freeze_send(ctdb, tmp_ctx, timeout, destnode, priority);
        ret = ctdb_ctrl_freeze_recv(ctdb, tmp_ctx, state);
        talloc_free(tmp_ctx);
 
        return ret;
 }
 
+/* Freeze all databases */
+int ctdb_ctrl_freeze(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode)
+{
+       return ctdb_ctrl_freeze_priority(ctdb, timeout, destnode, 0);
+}
+
 /*
-  thaw a node
+  thaw databases of a certain priority
  */
-int ctdb_ctrl_thaw(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode)
+int ctdb_ctrl_thaw_priority(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t priority)
 {
        int ret;
        int32_t res;
 
-       ret = ctdb_control(ctdb, destnode, 0
+       ret = ctdb_control(ctdb, destnode, priority
                           CTDB_CONTROL_THAW, 0, tdb_null, 
                           NULL, NULL, &res, &timeout, NULL);
        if (ret != 0 || res != 0) {
@@ -1969,6 +1975,12 @@ int ctdb_ctrl_thaw(struct ctdb_context *ctdb, struct timeval timeout, uint32_t d
        return 0;
 }
 
+/* thaw all databases */
+int ctdb_ctrl_thaw(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode)
+{
+       return ctdb_ctrl_thaw_priority(ctdb, timeout, destnode, 0);
+}
+
 /*
   get pnn of a node, or -1
  */
index 839d58132721656a1fc7c37d6a534a792370120b..b9a7685f523b66e71d7fd5ff6ef46779b67e2809 100644 (file)
@@ -456,14 +456,18 @@ int ctdb_ctrl_getpid(struct ctdb_context *ctdb, struct timeval timeout, uint32_t
 
 int ctdb_ctrl_freeze(struct ctdb_context *ctdb, struct timeval timeout, 
                        uint32_t destnode);
+int ctdb_ctrl_freeze_priority(struct ctdb_context *ctdb, struct timeval timeout, 
+                             uint32_t destnode, uint32_t priority);
 
 struct ctdb_client_control_state *
 ctdb_ctrl_freeze_send(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, 
-                       struct timeval timeout, uint32_t destnode);
+                     struct timeval timeout, uint32_t destnode,
+                     uint32_t priority);
 
 int ctdb_ctrl_freeze_recv(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, 
                        struct ctdb_client_control_state *state);
 
+int ctdb_ctrl_thaw_priority(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t priority);
 int ctdb_ctrl_thaw(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode);
 
 int ctdb_ctrl_getpnn(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode);
index d5f44995de2314a875b83f3a03c23b08142c0b60..c54a8d21859106d6d5b3985eee4b02a4350b73ef 100644 (file)
@@ -1192,7 +1192,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);
+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);
index b962e41837154eea78f19cc6a8c6e638bb37ae0b..dbb828d7834ecba19dcf6ec10d45bc0885d09455 100644 (file)
@@ -249,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);
+               return ctdb_control_thaw(ctdb, c);
 
        case CTDB_CONTROL_SET_RECMODE:
                CHECK_CONTROL_DATA_SIZE(sizeof(uint32_t));              
index 1caefc201aa6439cd9817ad95f28777f9ec81555..5a775ce681f5c51a127dddcf6fb2f73a25471aa8 100644 (file)
@@ -243,6 +243,9 @@ void ctdb_start_freeze(struct ctdb_context *ctdb)
 int32_t ctdb_control_freeze(struct ctdb_context *ctdb, struct ctdb_req_control *c, bool *async_reply)
 {
        struct ctdb_freeze_waiter *w;
+       uint32_t priority;
+
+       priority = (uint32_t)c->srvid;
 
        if (ctdb->freeze_mode == CTDB_FREEZE_FROZEN) {
                /* we're already frozen */
@@ -286,8 +289,12 @@ bool ctdb_blocking_freeze(struct ctdb_context *ctdb)
 /*
   thaw the databases
  */
-int32_t ctdb_control_thaw(struct ctdb_context *ctdb)
+int32_t ctdb_control_thaw(struct ctdb_context *ctdb, struct ctdb_req_control *c)
 {
+       uint32_t priority;
+
+       priority = (uint32_t)c->srvid;
+
        /* cancel any pending transactions */
        if (ctdb->freeze_handle && ctdb->freeze_handle->transaction_started) {
                struct ctdb_db_context *ctdb_db;
index 599a882a14e64d36c30eee2550226ca6cb01ae42..97a02e14fbe23dcb7df72557c9ffd8a23a37afe7 100644 (file)
@@ -2707,8 +2707,16 @@ static int control_setdebug(struct ctdb_context *ctdb, int argc, const char **ar
 static int control_freeze(struct ctdb_context *ctdb, int argc, const char **argv)
 {
        int ret;
+       uint32_t priority;
+       
+       if (argc == 1) {
+               priority = strtol(argv[0], NULL, 0);
+       } else {
+               priority = 0;
+       }
+       DEBUG(DEBUG_ERR,("Freeze by priority %u\n", priority));
 
-       ret = ctdb_ctrl_freeze(ctdb, TIMELIMIT(), options.pnn);
+       ret = ctdb_ctrl_freeze_priority(ctdb, TIMELIMIT(), options.pnn, priority);
        if (ret != 0) {
                DEBUG(DEBUG_ERR, ("Unable to freeze node %u\n", options.pnn));
        }               
@@ -2721,8 +2729,16 @@ static int control_freeze(struct ctdb_context *ctdb, int argc, const char **argv
 static int control_thaw(struct ctdb_context *ctdb, int argc, const char **argv)
 {
        int ret;
+       uint32_t priority;
+       
+       if (argc == 1) {
+               priority = strtol(argv[0], NULL, 0);
+       } else {
+               priority = 0;
+       }
+       DEBUG(DEBUG_ERR,("Thaw by priority %u\n", priority));
 
-       ret = ctdb_ctrl_thaw(ctdb, TIMELIMIT(), options.pnn);
+       ret = ctdb_ctrl_thaw_priority(ctdb, TIMELIMIT(), options.pnn, priority);
        if (ret != 0) {
                DEBUG(DEBUG_ERR, ("Unable to thaw node %u\n", options.pnn));
        }               
@@ -3443,8 +3459,8 @@ static const struct {
        { "shutdown",        control_shutdown,          true,   false,  "shutdown ctdbd" },
        { "recover",         control_recover,           true,   false,  "force recovery" },
        { "ipreallocate",    control_ipreallocate,      true,   false,  "force the recovery daemon to perform a ip reallocation procedure" },
-       { "freeze",          control_freeze,            true,   false,  "freeze all databases" },
-       { "thaw",            control_thaw,              true,   false,  "thaw all databases" },
+       { "freeze",          control_freeze,            true,   false,  "freeze databases", "[priority:1-3]" },
+       { "thaw",            control_thaw,              true,   false,  "thaw databases", "[priority:1-3]" },
        { "isnotrecmaster",  control_isnotrecmaster,    false,  false,  "check if the local node is recmaster or not" },
        { "killtcp",         kill_tcp,                  false,  false, "kill a tcp connection.", "<srcip:port> <dstip:port>" },
        { "gratiousarp",     control_gratious_arp,      false,  false, "send a gratious arp", "<ip> <interface>" },