Rev 492: get all the tunables at once in recovery daemon in http://samba.org/~tridge/ctdb

tridge at samba.org tridge at samba.org
Thu Jun 7 08:05:26 GMT 2007


------------------------------------------------------------
revno: 492
revision-id: tridge at samba.org-20070607080525-14g625qx3h5rvs40
parent: tridge at samba.org-20070607064831-cs6ed30jggx07qp9
committer: Andrew Tridgell <tridge at samba.org>
branch nick: tridge
timestamp: Thu 2007-06-07 18:05:25 +1000
message:
  get all the tunables at once in recovery daemon
modified:
  common/ctdb_client.c           ctdb_client.c-20070411010216-3kd8v37k61steeya-1
  common/ctdb_control.c          ctdb_control.c-20070426122724-j6gkpiofhbwdin63-1
  common/ctdb_recoverd.c         recoverd.c-20070503213540-bvxuyd9jm1f7ig90-1
  include/ctdb_private.h         ctdb_private.h-20061117234101-o3qt14umlg9en8z0-13
=== modified file 'common/ctdb_client.c'
--- a/common/ctdb_client.c	2007-06-07 05:18:55 +0000
+++ b/common/ctdb_client.c	2007-06-07 08:05:25 +0000
@@ -1946,3 +1946,33 @@
 	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;
+}

=== modified file 'common/ctdb_control.c'
--- a/common/ctdb_control.c	2007-06-07 05:18:55 +0000
+++ b/common/ctdb_control.c	2007-06-07 08:05:25 +0000
@@ -80,6 +80,13 @@
 		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);

=== modified file 'common/ctdb_recoverd.c'
--- a/common/ctdb_recoverd.c	2007-06-07 06:48:31 +0000
+++ b/common/ctdb_recoverd.c	2007-06-07 08:05:25 +0000
@@ -1031,18 +1031,11 @@
 	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) {

=== modified file 'include/ctdb_private.h'
--- a/include/ctdb_private.h	2007-06-07 06:34:33 +0000
+++ b/include/ctdb_private.h	2007-06-07 08:05:25 +0000
@@ -419,6 +419,7 @@
 		    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 @@
 
 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



More information about the samba-cvs mailing list