4 Copyright (C) Andrew Tridgell 2007
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, see <http://www.gnu.org/licenses/>.
20 #include "../include/ctdb_private.h"
27 { "MaxRedirectCount", 3, offsetof(struct ctdb_tunable, max_redirect_count) },
28 { "SeqnumInterval", 1000, offsetof(struct ctdb_tunable, seqnum_interval) },
29 { "ControlTimeout", 60, offsetof(struct ctdb_tunable, control_timeout) },
30 { "TraverseTimeout", 20, offsetof(struct ctdb_tunable, traverse_timeout) },
31 { "KeepaliveInterval", 5, offsetof(struct ctdb_tunable, keepalive_interval) },
32 { "KeepaliveLimit", 5, offsetof(struct ctdb_tunable, keepalive_limit) },
33 { "MaxLACount", 7, offsetof(struct ctdb_tunable, max_lacount) },
34 { "RecoverTimeout", 20, offsetof(struct ctdb_tunable, recover_timeout) },
35 { "RecoverInterval", 1, offsetof(struct ctdb_tunable, recover_interval) },
36 { "ElectionTimeout", 3, offsetof(struct ctdb_tunable, election_timeout) },
37 { "TakeoverTimeout", 5, offsetof(struct ctdb_tunable, takeover_timeout) },
38 { "MonitorInterval", 15, offsetof(struct ctdb_tunable, monitor_interval) },
39 { "TickleUpdateInterval",20, offsetof(struct ctdb_tunable, tickle_update_interval) },
40 { "EventScriptTimeout", 30, offsetof(struct ctdb_tunable, script_timeout) },
41 { "EventScriptBanCount", 10, offsetof(struct ctdb_tunable, script_ban_count) },
42 { "EventScriptUnhealthyOnTimeout", 0, offsetof(struct ctdb_tunable, script_unhealthy_on_timeout) },
43 { "RecoveryGracePeriod", 120, offsetof(struct ctdb_tunable, recovery_grace_period) },
44 { "RecoveryBanPeriod", 300, offsetof(struct ctdb_tunable, recovery_ban_period) },
45 { "DatabaseHashSize", 10000, offsetof(struct ctdb_tunable, database_hash_size) },
46 { "DatabaseMaxDead", 5, offsetof(struct ctdb_tunable, database_max_dead) },
47 { "RerecoveryTimeout", 10, offsetof(struct ctdb_tunable, rerecovery_timeout) },
48 { "EnableBans", 1, offsetof(struct ctdb_tunable, enable_bans) },
49 { "DeterministicIPs", 1, offsetof(struct ctdb_tunable, deterministic_public_ips) },
50 { "DisableWhenUnhealthy", 0, offsetof(struct ctdb_tunable, disable_when_unhealthy) },
51 { "ReclockPingPeriod", 60, offsetof(struct ctdb_tunable, reclock_ping_period) },
52 { "NoIPFailback", 0, offsetof(struct ctdb_tunable, no_ip_failback) },
53 { "VerboseMemoryNames", 0, offsetof(struct ctdb_tunable, verbose_memory_names) },
54 { "RecdPingTimeout", 60, offsetof(struct ctdb_tunable, recd_ping_timeout) },
55 { "RecdFailCount", 10, offsetof(struct ctdb_tunable, recd_ping_failcount) },
56 { "LogLatencyMs", 0, offsetof(struct ctdb_tunable, log_latency_ms) },
57 { "RecLockLatencyMs", 1000, offsetof(struct ctdb_tunable, reclock_latency_ms) },
58 { "RecoveryDropAllIPs", 60, offsetof(struct ctdb_tunable, recovery_drop_all_ips) },
59 { "VerifyRecoveryLock", 1, offsetof(struct ctdb_tunable, verify_recovery_lock) },
60 { "VacuumDefaultInterval", 300, offsetof(struct ctdb_tunable, vacuum_default_interval) },
61 { "VacuumMaxRunTime", 30, offsetof(struct ctdb_tunable, vacuum_max_run_time) },
62 { "RepackLimit", 10000, offsetof(struct ctdb_tunable, repack_limit) },
63 { "VacuumLimit", 5000, offsetof(struct ctdb_tunable, vacuum_limit) },
64 { "VacuumMinInterval", 60, offsetof(struct ctdb_tunable, vacuum_min_interval) },
65 { "VacuumMaxInterval", 600, offsetof(struct ctdb_tunable, vacuum_max_interval) },
66 { "MaxQueueDropMsg", 1000, offsetof(struct ctdb_tunable, max_queue_depth_drop_msg) }
70 set all tunables to defaults
72 void ctdb_tunables_set_defaults(struct ctdb_context *ctdb)
75 for (i=0;i<ARRAY_SIZE(tunable_map);i++) {
76 *(uint32_t *)(tunable_map[i].offset + (uint8_t*)&ctdb->tunable) = tunable_map[i].default_v;
84 int32_t ctdb_control_get_tunable(struct ctdb_context *ctdb, TDB_DATA indata,
87 struct ctdb_control_get_tunable *t =
88 (struct ctdb_control_get_tunable *)indata.dptr;
93 if (indata.dsize < sizeof(*t) ||
94 t->length > indata.dsize - offsetof(struct ctdb_control_get_tunable, name)) {
95 DEBUG(DEBUG_ERR,("Bad indata in ctdb_control_get_tunable\n"));
99 name = talloc_strndup(ctdb, (char*)t->name, t->length);
100 CTDB_NO_MEMORY(ctdb, name);
102 for (i=0;i<ARRAY_SIZE(tunable_map);i++) {
103 if (strcasecmp(name, tunable_map[i].name) == 0) break;
107 if (i == ARRAY_SIZE(tunable_map)) {
111 val = *(uint32_t *)(tunable_map[i].offset + (uint8_t*)&ctdb->tunable);
113 outdata->dptr = (uint8_t *)talloc(outdata, uint32_t);
114 CTDB_NO_MEMORY(ctdb, outdata->dptr);
116 *(uint32_t *)outdata->dptr = val;
117 outdata->dsize = sizeof(uint32_t);
126 int32_t ctdb_control_set_tunable(struct ctdb_context *ctdb, TDB_DATA indata)
128 struct ctdb_control_set_tunable *t =
129 (struct ctdb_control_set_tunable *)indata.dptr;
133 if (indata.dsize < sizeof(*t) ||
134 t->length > indata.dsize - offsetof(struct ctdb_control_set_tunable, name)) {
135 DEBUG(DEBUG_ERR,("Bad indata in ctdb_control_set_tunable\n"));
139 name = talloc_strndup(ctdb, (char *)t->name, t->length);
140 CTDB_NO_MEMORY(ctdb, name);
142 for (i=0;i<ARRAY_SIZE(tunable_map);i++) {
143 if (strcasecmp(name, tunable_map[i].name) == 0) break;
146 if (!strcmp(name, "VerifyRecoveryLock") && t->value != 0
147 && ctdb->recovery_lock_file == NULL) {
148 DEBUG(DEBUG_ERR,("Can not activate tunable \"VerifyRecoveryLock\" since there is no recovery lock file set.\n"));
155 if (i == ARRAY_SIZE(tunable_map)) {
159 *(uint32_t *)(tunable_map[i].offset + (uint8_t*)&ctdb->tunable) = t->value;
167 int32_t ctdb_control_list_tunables(struct ctdb_context *ctdb, TDB_DATA *outdata)
171 struct ctdb_control_list_tunable *t;
173 list = talloc_strdup(outdata, tunable_map[0].name);
174 CTDB_NO_MEMORY(ctdb, list);
176 for (i=1;i<ARRAY_SIZE(tunable_map);i++) {
177 list = talloc_asprintf_append(list, ":%s", tunable_map[i].name);
178 CTDB_NO_MEMORY(ctdb, list);
181 outdata->dsize = offsetof(struct ctdb_control_list_tunable, data) +
183 outdata->dptr = talloc_size(outdata, outdata->dsize);
184 CTDB_NO_MEMORY(ctdb, outdata->dptr);
186 t = (struct ctdb_control_list_tunable *)outdata->dptr;
187 t->length = strlen(list)+1;
189 memcpy(t->data, list, t->length);