]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
add new controls to get and set the recovery master node of a daemon
authorRonnie Sahlberg <sahlberg@ronnie>
Sun, 6 May 2007 19:02:48 +0000 (05:02 +1000)
committerRonnie Sahlberg <sahlberg@ronnie>
Sun, 6 May 2007 19:02:48 +0000 (05:02 +1000)
i.e. which node is "elected" to check for and drive recovery

(This used to be ctdb commit d577093eb4b619392c71ab5ce81e8c02565d93f0)

ctdb/common/ctdb.c
ctdb/common/ctdb_client.c
ctdb/common/ctdb_control.c
ctdb/include/ctdb.h
ctdb/include/ctdb_private.h

index 4699e8f2d70e380fd0421bc1620d3fc80bed6e06..f2eb42ff716fc93523dfb1838c9065d3ecb8096c 100644 (file)
@@ -541,11 +541,12 @@ struct ctdb_context *ctdb_init(struct event_context *ev)
        struct ctdb_context *ctdb;
 
        ctdb = talloc_zero(ev, struct ctdb_context);
-       ctdb->ev = ev;
-       ctdb->recovery_mode = CTDB_RECOVERY_NORMAL;
-       ctdb->upcalls = &ctdb_upcalls;
-       ctdb->idr = idr_init(ctdb);
-       ctdb->max_lacount = CTDB_DEFAULT_MAX_LACOUNT;
+       ctdb->ev               = ev;
+       ctdb->recovery_mode    = CTDB_RECOVERY_NORMAL;
+       ctdb->recovery_master  = 0;
+       ctdb->upcalls          = &ctdb_upcalls;
+       ctdb->idr              = idr_init(ctdb);
+       ctdb->max_lacount      = CTDB_DEFAULT_MAX_LACOUNT;
        ctdb->seqnum_frequency = CTDB_DEFAULT_SEQNUM_FREQUENCY;
 
        return ctdb;
index a5a07f7ff38553a6be2a934be2b7ca19f79fcb49..ccfe6234a686abecffeb4cc0fc60036d9eef07a5 100644 (file)
@@ -877,6 +877,54 @@ int ctdb_ctrl_setrecmode(struct ctdb_context *ctdb, struct timeval timeout, uint
        return 0;
 }
 
+/*
+  get the recovery master of a remote node
+ */
+int ctdb_ctrl_getrecmaster(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t *recmaster)
+{
+       int ret;
+       TDB_DATA data, outdata;
+       int32_t res;
+
+       ZERO_STRUCT(data);
+       ret = ctdb_control(ctdb, destnode, 0, 
+                          CTDB_CONTROL_GET_RECMASTER, 0, data, 
+                          ctdb, &outdata, &res, &timeout);
+       if (ret != 0) {
+               DEBUG(0,(__location__ " ctdb_control for getrecmaster failed\n"));
+               return -1;
+       }
+
+       *recmaster = res;
+
+       return 0;
+}
+
+/*
+  set the recovery master of a remote node
+ */
+int ctdb_ctrl_setrecmaster(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t recmaster)
+{
+       int ret;
+       TDB_DATA data, outdata;
+       int32_t res;
+
+       ZERO_STRUCT(data);
+       data.dsize = sizeof(uint32_t);
+       data.dptr = (unsigned char *)&recmaster;
+
+       ret = ctdb_control(ctdb, destnode, 0, 
+                          CTDB_CONTROL_SET_RECMASTER, 0, data, 
+                          ctdb, &outdata, &res, &timeout);
+       if (ret != 0 || res != 0) {
+               DEBUG(0,(__location__ " ctdb_control for getrecmode failed\n"));
+               return -1;
+       }
+
+       return 0;
+}
+
+
 /*
   get a list of databases off a remote node
  */
index dfbfc32383e154aeece040740f199cf451431da7..f79aaf0ce8d0b65c41658ea1eadbf3a33bf3159b 100644 (file)
@@ -344,6 +344,16 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb,
                return ctdb->recovery_mode;
        }
 
+       case CTDB_CONTROL_SET_RECMASTER: {
+               ctdb->recovery_master = ((uint32_t *)(&indata.dptr[0]))[0];
+
+               return 0;
+       }
+
+       case CTDB_CONTROL_GET_RECMASTER: {
+               return ctdb->recovery_master;
+       }
+
        case CTDB_CONTROL_GET_PID: {
                return getpid();
        }
index 964872d44751c05c69df495546b3c6f7f53db1b5..856fcd68463d2ae664c5a7f562624bb227a9c2ac 100644 (file)
@@ -289,6 +289,15 @@ int ctdb_ctrl_getrecmode(struct ctdb_context *ctdb, struct timeval timeout, uint
  */
 int ctdb_ctrl_setrecmode(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t recmode);
 
+/*
+  get the recovery master of a remote node
+ */
+int ctdb_ctrl_getrecmaster(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t *recmaster);
+/*
+  set the recovery master of a remote node
+ */
+int ctdb_ctrl_setrecmaster(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t recmaster);
+
 uint32_t *ctdb_get_connected_nodes(struct ctdb_context *ctdb, 
                                   struct timeval timeout, 
                                   TALLOC_CTX *mem_ctx,
index 73767b292aed4c5397932a2690319fbafd820758..208b896211d54f7fcb7bbcf56cbc707e0dbe260a 100644 (file)
@@ -234,6 +234,7 @@ struct ctdb_context {
        struct ctdb_vnn_map *vnn_map;
        uint32_t num_clients;
        uint32_t seqnum_frequency;
+       uint32_t recovery_master;
 };
 
 struct ctdb_db_context {
@@ -313,6 +314,8 @@ enum ctdb_controls {CTDB_CONTROL_PROCESS_EXISTS,
                    CTDB_CONTROL_SET_SEQNUM_FREQUENCY,
                    CTDB_CONTROL_DUMP_MEMORY,
                    CTDB_CONTROL_GET_PID,
+                   CTDB_CONTROL_GET_RECMASTER,
+                   CTDB_CONTROL_SET_RECMASTER,
 };