From: Andrew Tridgell Date: Mon, 4 Jun 2007 10:22:44 +0000 (+1000) Subject: make recovery daemon values tunable X-Git-Tag: tevent-0.9.20~348^2~2572 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=39ced972ae67714ad83b98d84652da65ee35c3ab;p=thirdparty%2Fsamba.git make recovery daemon values tunable (This used to be ctdb commit ec29dbf2f5110428df8b97801443ba7addf61353) --- diff --git a/ctdb/common/ctdb.c b/ctdb/common/ctdb.c index 8fafc45369b..3fc2d7d53da 100644 --- a/ctdb/common/ctdb.c +++ b/ctdb/common/ctdb.c @@ -523,14 +523,7 @@ struct ctdb_context *ctdb_init(struct event_context *ev) ctdb->recovery_lock_fd = -1; ctdb->monitoring_mode = CTDB_MONITORING_ACTIVE; - /* set default values for tunables */ - ctdb->tunable.max_redirect_count = 3; - ctdb->tunable.seqnum_frequency = 1; - ctdb->tunable.control_timeout = 60; - ctdb->tunable.traverse_timeout = 20; - ctdb->tunable.monitoring_timeout = 2; - ctdb->tunable.monitoring_limit = 3; - ctdb->tunable.max_lacount = 7; + ctdb_tunables_set_defaults(ctdb); return ctdb; } diff --git a/ctdb/common/ctdb_recoverd.c b/ctdb/common/ctdb_recoverd.c index 70b980ca063..a2d845de63d 100644 --- a/ctdb/common/ctdb_recoverd.c +++ b/ctdb/common/ctdb_recoverd.c @@ -35,8 +35,8 @@ static void timeout_func(struct event_context *ev, struct timed_event *te, timed_out = 1; } -#define CONTROL_TIMEOUT() timeval_current_ofs(5, 0) -#define MONITOR_TIMEOUT() timeval_current_ofs(1, 0) +#define CONTROL_TIMEOUT() timeval_current_ofs(ctdb->tunable.recover_timeout, 0) +#define MONITOR_TIMEOUT() timeval_current_ofs(ctdb->tunable.monitor_frequency, 0) static int set_recovery_mode(struct ctdb_context *ctdb, struct ctdb_node_map *nodemap, uint32_t rec_mode) { @@ -50,7 +50,7 @@ static int set_recovery_mode(struct ctdb_context *ctdb, struct ctdb_node_map *no } if (rec_mode == CTDB_RECOVERY_ACTIVE) { - ret = ctdb_ctrl_freeze(ctdb, timeval_current_ofs(5, 0), nodemap->nodes[j].vnn); + ret = ctdb_ctrl_freeze(ctdb, CONTROL_TIMEOUT(), nodemap->nodes[j].vnn); if (ret != 0) { DEBUG(0, (__location__ " Unable to freeze node %u\n", nodemap->nodes[j].vnn)); return -1; @@ -64,7 +64,7 @@ static int set_recovery_mode(struct ctdb_context *ctdb, struct ctdb_node_map *no } if (rec_mode == CTDB_RECOVERY_NORMAL) { - ret = ctdb_ctrl_thaw(ctdb, timeval_current_ofs(5, 0), nodemap->nodes[j].vnn); + ret = ctdb_ctrl_thaw(ctdb, CONTROL_TIMEOUT(), nodemap->nodes[j].vnn); if (ret != 0) { DEBUG(0, (__location__ " Unable to thaw node %u\n", nodemap->nodes[j].vnn)); return -1; @@ -652,14 +652,16 @@ static void force_election(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, uint3 /* wait for a few seconds to collect all responses */ timed_out = 0; - event_add_timed(ctdb->ev, mem_ctx, timeval_current_ofs(3, 0), + event_add_timed(ctdb->ev, mem_ctx, timeval_current_ofs(ctdb->tunable.election_timeout, 0), timeout_func, ctdb); while (!timed_out) { event_loop_once(ctdb->ev); } } - +/* + the main monitoring loop + */ void monitor_cluster(struct ctdb_context *ctdb) { uint32_t vnn, num_active, recmode, recmaster; @@ -688,6 +690,14 @@ again: event_loop_once(ctdb->ev); } + /* 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, + "MonitorFrequency", &ctdb->tunable.monitor_frequency); + ctdb_ctrl_get_tunable(ctdb, CONTROL_TIMEOUT(), CTDB_CURRENT_NODE, + "ElectionTimeout", &ctdb->tunable.election_timeout); + vnn = ctdb_ctrl_getvnn(ctdb, CONTROL_TIMEOUT(), CTDB_CURRENT_NODE); if (vnn == (uint32_t)-1) { DEBUG(0,("Failed to get local vnn - retrying\n")); diff --git a/ctdb/common/ctdb_tunables.c b/ctdb/common/ctdb_tunables.c index 912d12a4a44..85794432b30 100644 --- a/ctdb/common/ctdb_tunables.c +++ b/ctdb/common/ctdb_tunables.c @@ -22,17 +22,32 @@ static const struct { const char *name; - size_t offset; + uint32_t default_v; + size_t offset; } tunable_map[] = { - { "MaxRedirectCount", offsetof(struct ctdb_tunable, max_redirect_count) }, - { "SeqnumFrequency", offsetof(struct ctdb_tunable, seqnum_frequency) }, - { "ControlTimeout", offsetof(struct ctdb_tunable, control_timeout) }, - { "TraverseTimeout", offsetof(struct ctdb_tunable, traverse_timeout) }, - { "MonitoringTimeout", offsetof(struct ctdb_tunable, monitoring_timeout) }, - { "MonitoringLimit", offsetof(struct ctdb_tunable, monitoring_limit) }, - { "MaxLACount", offsetof(struct ctdb_tunable, max_lacount) }, + { "MaxRedirectCount", 3, offsetof(struct ctdb_tunable, max_redirect_count) }, + { "SeqnumFrequency", 1, offsetof(struct ctdb_tunable, seqnum_frequency) }, + { "ControlTimeout", 60, offsetof(struct ctdb_tunable, control_timeout) }, + { "TraverseTimeout", 20, offsetof(struct ctdb_tunable, traverse_timeout) }, + { "MonitoringTimeout", 2, offsetof(struct ctdb_tunable, monitoring_timeout) }, + { "MonitoringLimit", 3, offsetof(struct ctdb_tunable, monitoring_limit) }, + { "MaxLACount", 7, offsetof(struct ctdb_tunable, max_lacount) }, + { "RecoverTimeout", 5, offsetof(struct ctdb_tunable, recover_timeout) }, + { "MonitorFrequency", 1, offsetof(struct ctdb_tunable, monitor_frequency) }, + { "ElectionTimeout", 3, offsetof(struct ctdb_tunable, election_timeout) }, }; +/* + set all tunables to defaults + */ +void ctdb_tunables_set_defaults(struct ctdb_context *ctdb) +{ + int i; + for (i=0;itunable) = tunable_map[i].default_v; + } +} + /* get a tunable diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h index 75126b21153..ac36bed3938 100644 --- a/ctdb/include/ctdb_private.h +++ b/ctdb/include/ctdb_private.h @@ -47,6 +47,9 @@ struct ctdb_tunable { uint32_t monitoring_timeout; uint32_t monitoring_limit; uint32_t max_lacount; + uint32_t recover_timeout; + uint32_t monitor_frequency; + uint32_t election_timeout; }; /* @@ -971,4 +974,6 @@ int32_t ctdb_control_get_tunable(struct ctdb_context *ctdb, TDB_DATA indata, int32_t ctdb_control_set_tunable(struct ctdb_context *ctdb, TDB_DATA indata); int32_t ctdb_control_list_tunables(struct ctdb_context *ctdb, TDB_DATA *outdata); +void ctdb_tunables_set_defaults(struct ctdb_context *ctdb); + #endif