]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
get all the tunables at once in recovery daemon
authorAndrew Tridgell <tridge@samba.org>
Thu, 7 Jun 2007 08:05:25 +0000 (18:05 +1000)
committerAndrew Tridgell <tridge@samba.org>
Thu, 7 Jun 2007 08:05:25 +0000 (18:05 +1000)
(This used to be ctdb commit 8e60be6c22aab145e68b16ede5f32f4430c2af93)

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

index 74b79426d53a1eea6782db77168b8d04ac89a942..8dfd6a076d9bfa7f0dcefc26197ca109a37ba8b0 100644 (file)
@@ -1946,3 +1946,33 @@ int ctdb_ctrl_modflags(struct ctdb_context *ctdb, struct timeval timeout, uint32
        return 0;
 }
 
+
+/*
+  get all tunables
+ */
+int ctdb_ctrl_get_all_tunables(struct ctdb_context *ctdb, 
+                              struct timeval timeout, 
+                              uint32_t destnode,
+                              struct ctdb_tunable *tunables)
+{
+       TDB_DATA outdata;
+       int ret;
+       int32_t res;
+
+       ret = ctdb_control(ctdb, destnode, 0, CTDB_CONTROL_GET_ALL_TUNABLES, 0, tdb_null, ctdb,
+                          &outdata, &res, &timeout, NULL);
+       if (ret != 0 || res != 0) {
+               DEBUG(0,(__location__ " ctdb_control for get all tunables failed\n"));
+               return -1;
+       }
+
+       if (outdata.dsize != sizeof(*tunables)) {
+               DEBUG(0,(__location__ " bad data size %u in ctdb_ctrl_get_all_tunables should be %u\n",
+                        outdata.dsize, sizeof(*tunables)));
+               return -1;              
+       }
+
+       *tunables = *(struct ctdb_tunable *)outdata.dptr;
+       talloc_free(outdata.dptr);
+       return 0;
+}
index fbb0662dc27eb6a9ebfb235802bbb1d3dd1bcee6..73e728937e51613a0bbb04fcf807d9dfa8faaa58 100644 (file)
@@ -80,6 +80,13 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb,
                return 0;
        }
 
+       case CTDB_CONTROL_GET_ALL_TUNABLES: {
+               CHECK_CONTROL_DATA_SIZE(0);
+               outdata->dptr = (uint8_t *)&ctdb->tunable;
+               outdata->dsize = sizeof(ctdb->tunable);
+               return 0;
+       }
+
        case CTDB_CONTROL_DUMP_MEMORY: {
                CHECK_CONTROL_DATA_SIZE(0);
                talloc_report_full(ctdb, stdout);
index 9ddbad787f637fed6513003ca0e47e615a963829..da9d8ae54d6ecb80fcb241447be2f407323de6d6 100644 (file)
@@ -1031,18 +1031,11 @@ again:
        ctdb_wait_timeout(ctdb, ctdb->tunable.recover_interval);
 
        /* get relevant tunables */
-       ctdb_ctrl_get_tunable(ctdb, CONTROL_TIMEOUT(), CTDB_CURRENT_NODE, 
-                             "RecoverTimeout", &ctdb->tunable.recover_timeout);
-       ctdb_ctrl_get_tunable(ctdb, CONTROL_TIMEOUT(), CTDB_CURRENT_NODE, 
-                             "RecoverInterval", &ctdb->tunable.recover_interval);
-       ctdb_ctrl_get_tunable(ctdb, CONTROL_TIMEOUT(), CTDB_CURRENT_NODE, 
-                             "ElectionTimeout", &ctdb->tunable.election_timeout);
-       ctdb_ctrl_get_tunable(ctdb, CONTROL_TIMEOUT(), CTDB_CURRENT_NODE, 
-                             "TakeoverTimeout", &ctdb->tunable.takeover_timeout);
-       ctdb_ctrl_get_tunable(ctdb, CONTROL_TIMEOUT(), CTDB_CURRENT_NODE, 
-                             "RecoveryGracePeriod", &ctdb->tunable.recovery_grace_period);
-       ctdb_ctrl_get_tunable(ctdb, CONTROL_TIMEOUT(), CTDB_CURRENT_NODE, 
-                             "RecoveryBanPeriod", &ctdb->tunable.recovery_ban_period);
+       ret = ctdb_ctrl_get_all_tunables(ctdb, CONTROL_TIMEOUT(), CTDB_CURRENT_NODE, &ctdb->tunable);
+       if (ret != 0) {
+               DEBUG(0,("Failed to get tunables - retrying\n"));
+               goto again;
+       }
 
        vnn = ctdb_ctrl_getvnn(ctdb, CONTROL_TIMEOUT(), CTDB_CURRENT_NODE);
        if (vnn == (uint32_t)-1) {
index 01b3170ba6db5841bb1ce8a19a0bba4cfde7e58e..cfa33d28aedd34cae26d227b76a1cc638a30d2a3 100644 (file)
@@ -419,6 +419,7 @@ enum ctdb_controls {CTDB_CONTROL_PROCESS_EXISTS          = 0,
                    CTDB_CONTROL_LIST_TUNABLES           = 50,
                    CTDB_CONTROL_GET_PUBLIC_IPS          = 51,
                    CTDB_CONTROL_MODIFY_FLAGS            = 52,
+                   CTDB_CONTROL_GET_ALL_TUNABLES        = 53,
 };
 
 /*
@@ -1032,4 +1033,9 @@ void ctdb_tunables_set_defaults(struct ctdb_context *ctdb);
 
 int32_t ctdb_control_modflags(struct ctdb_context *ctdb, TDB_DATA indata);
 
+int ctdb_ctrl_get_all_tunables(struct ctdb_context *ctdb, 
+                              struct timeval timeout, 
+                              uint32_t destnode,
+                              struct ctdb_tunable *tunables);
+
 #endif