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>
Mon, 12 Oct 2009 02:46:51 +0000 (13:46 +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 7ca589703c8c399baade1e5c0ff1a6ec5ceab1f4..b27086b579e463d168beed2aeb6c8cf9eb651b0d 100644 (file)
@@ -1943,9 +1943,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);
 }
@@ -1968,30 +1968,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) {
@@ -2002,6 +2008,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 5f1699024ef1e078fb9f7a09a48a1ccf034ffa0e..34d30805ba52dea5430a3532ed5fa2562ee5140a 100644 (file)
@@ -453,14 +453,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 da6a40632333530559fb12e147b08afb26c53ef9..774a36603061e088b3534f11d4fb524bba5063e9 100644 (file)
@@ -1172,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);
+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 997b100f49e7bdd02e38ab353544576c11ef518b..2f0b94072a04376cbeb38ea0ef34a8079fa3ce82 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 c9499c85a13c23ea0052485a582b3fbb0a72bd33..ed0bbe8d6cb64e60b1c2668ba8039d7712598264 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 6f4725f9460c1be872d1b0c63faa220b8cb2ff9c..fc1dda8643924617c0c2b553fa29b45f116e96fb 100644 (file)
@@ -2250,8 +2250,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));
        }               
@@ -2264,8 +2272,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));
        }               
@@ -2927,8 +2943,8 @@ static const struct {
        { "unban",           control_unban,             true,   false,  "unban a node from the cluster" },
        { "shutdown",        control_shutdown,          true,   false,  "shutdown ctdbd" },
        { "recover",         control_recover,           true,   false,  "force recovery" },
-       { "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>" },