From: Andrew Tridgell Date: Thu, 7 Jun 2007 08:05:25 +0000 (+1000) Subject: get all the tunables at once in recovery daemon X-Git-Tag: tevent-0.9.20~348^2~2539 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3e4d7bef239c0f83316b5a0e2dc473029e6770b9;p=thirdparty%2Fsamba.git get all the tunables at once in recovery daemon (This used to be ctdb commit 8e60be6c22aab145e68b16ede5f32f4430c2af93) --- diff --git a/ctdb/common/ctdb_client.c b/ctdb/common/ctdb_client.c index 74b79426d53..8dfd6a076d9 100644 --- a/ctdb/common/ctdb_client.c +++ b/ctdb/common/ctdb_client.c @@ -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; +} diff --git a/ctdb/common/ctdb_control.c b/ctdb/common/ctdb_control.c index fbb0662dc27..73e728937e5 100644 --- a/ctdb/common/ctdb_control.c +++ b/ctdb/common/ctdb_control.c @@ -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); diff --git a/ctdb/common/ctdb_recoverd.c b/ctdb/common/ctdb_recoverd.c index 9ddbad787f6..da9d8ae54d6 100644 --- a/ctdb/common/ctdb_recoverd.c +++ b/ctdb/common/ctdb_recoverd.c @@ -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) { diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h index 01b3170ba6d..cfa33d28aed 100644 --- a/ctdb/include/ctdb_private.h +++ b/ctdb/include/ctdb_private.h @@ -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