buildtools: Ignore exact Python version for ABI checking
[Samba.git] / ctdb / protocol / protocol.h
blob7159071db1d260cfff37cab47b89b173b0293a76
1 /*
2 CTDB protocol marshalling
4 Copyright (C) Amitay Isaacs 2015
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 #ifndef __CTDB_PROTOCOL_H__
21 #define __CTDB_PROTOCOL_H__
23 #define CTDB_MAGIC 0x43544442 /* CTDB */
24 #define CTDB_PROTOCOL 1
26 enum ctdb_operation {
27 CTDB_REQ_CALL = 0,
28 CTDB_REPLY_CALL = 1,
29 CTDB_REQ_DMASTER = 2,
30 CTDB_REPLY_DMASTER = 3,
31 CTDB_REPLY_ERROR = 4,
32 CTDB_REQ_MESSAGE = 5,
33 /* #6 removed */
34 CTDB_REQ_CONTROL = 7,
35 CTDB_REPLY_CONTROL = 8,
36 CTDB_REQ_KEEPALIVE = 9,
39 /* used on the domain socket, send a pdu to the local daemon */
40 #define CTDB_CURRENT_NODE 0xF0000001
41 /* send a broadcast to all nodes in the cluster, active or not */
42 #define CTDB_BROADCAST_ALL 0xF0000002
43 /* send a broadcast to all nodes in the current vnn map */
44 #define CTDB_BROADCAST_VNNMAP 0xF0000003
45 /* send a broadcast to all connected nodes */
46 #define CTDB_BROADCAST_CONNECTED 0xF0000004
47 /* send a broadcast to selected connected nodes */
48 #define CTDB_MULTICAST 0xF0000005
50 #define CTDB_UNKNOWN_PNN 0xFFFFFFFF
52 /* the key used to store persistent db sequence number */
53 #define CTDB_DB_SEQNUM_KEY "__db_sequence_number__"
55 struct ctdb_req_header {
56 uint32_t length;
57 uint32_t ctdb_magic;
58 uint32_t ctdb_version;
59 uint32_t generation;
60 uint32_t operation;
61 uint32_t destnode;
62 uint32_t srcnode;
63 uint32_t reqid;
66 struct ctdb_req_call {
67 uint32_t flags;
68 uint32_t db_id;
69 uint32_t callid;
70 uint32_t hopcount;
71 TDB_DATA key;
72 TDB_DATA calldata;
75 struct ctdb_reply_call {
76 int32_t status;
77 TDB_DATA data;
80 struct ctdb_reply_error {
81 int32_t status;
82 TDB_DATA msg;
85 struct ctdb_req_dmaster {
86 uint32_t db_id;
87 uint64_t rsn;
88 uint32_t dmaster;
89 TDB_DATA key;
90 TDB_DATA data;
93 struct ctdb_reply_dmaster {
94 uint32_t db_id;
95 uint64_t rsn;
96 TDB_DATA key;
97 TDB_DATA data;
100 #define CTDB_NULL_FUNC 0xFF000001
101 #define CTDB_FETCH_FUNC 0xFF000002
102 #define CTDB_FETCH_WITH_HEADER_FUNC 0xFF000003
104 struct ctdb_call {
105 int call_id;
106 TDB_DATA key;
107 TDB_DATA call_data;
108 TDB_DATA reply_data;
109 uint32_t status;
110 #define CTDB_IMMEDIATE_MIGRATION 0x00000001
111 #define CTDB_CALL_FLAG_VACUUM_MIGRATION 0x00000002
112 #define CTDB_WANT_READONLY 0x00000004
113 uint32_t flags;
116 /* SRVID to catch all messages */
117 #define CTDB_SRVID_ALL (~(uint64_t)0)
119 /* SRVID prefix used by CTDB */
120 #define CTDB_SRVID_PREFIX 0xF000000000000000LL
122 /* SRVID to inform of election data */
123 #define CTDB_SRVID_ELECTION 0xF100000000000000LL
125 /* SRVID to inform clients that the cluster has been reconfigured */
126 #define CTDB_SRVID_RECONFIGURE 0xF200000000000000LL
128 /* SRVID to inform clients an IP address has been released */
129 #define CTDB_SRVID_RELEASE_IP 0xF300000000000000LL
131 /* SRVID to inform clients that an IP address has been taken over */
132 #define CTDB_SRVID_TAKE_IP 0xF301000000000000LL
134 /* SRVID to inform recovery daemon of the node flags */
135 #define CTDB_SRVID_SET_NODE_FLAGS 0xF400000000000000LL
137 /* SRVID to inform recovery daemon to update public ip assignment */
138 #define CTDB_SRVID_RECD_UPDATE_IP 0xF500000000000000LL
140 /* SRVID to inform recovery daemon to migrate a set of records */
141 #define CTDB_SRVID_VACUUM_FETCH 0xF700000000000000LL
143 /* SRVID to inform recovery daemon to detach a database */
144 #define CTDB_SRVID_DETACH_DATABASE 0xF701000000000000LL
146 /* SRVID to inform recovery daemon to dump talloc memdump to the log */
147 #define CTDB_SRVID_MEM_DUMP 0xF800000000000000LL
149 /* SRVID to inform recovery daemon to send logs */
150 #define CTDB_SRVID_GETLOG 0xF801000000000000LL
152 /* SRVID to inform recovery daemon to clear logs */
153 #define CTDB_SRVID_CLEARLOG 0xF802000000000000LL
155 /* SRVID to inform recovery daemon to push the node flags to other nodes */
156 #define CTDB_SRVID_PUSH_NODE_FLAGS 0xF900000000000000LL
158 /* SRVID to inform recovery daemon to reload the nodes file */
159 #define CTDB_SRVID_RELOAD_NODES 0xFA00000000000000LL
161 /* SRVID to inform recovery daemon to perform a takeover run */
162 #define CTDB_SRVID_TAKEOVER_RUN 0xFB00000000000000LL
164 /* SRVID to inform recovery daemon to rebalance ips for a node. */
165 #define CTDB_SRVID_REBALANCE_NODE 0xFB01000000000000LL
167 /* SRVID to inform recovery daemon to stop takeover runs from occurring */
168 #define CTDB_SRVID_DISABLE_TAKEOVER_RUNS 0xFB03000000000000LL
170 /* SRVID to inform recovery daemon to stop recoveries from occurring */
171 #define CTDB_SRVID_DISABLE_RECOVERIES 0xFB04000000000000LL
173 /* SRVID to inform recovery daemon to disable the public ip checks */
174 #define CTDB_SRVID_DISABLE_IP_CHECK 0xFC00000000000000LL
176 /* SRVID to inform recovery daemon of ipreallocate resposnes from ctdbd */
177 #define CTDB_SRVID_TAKEOVER_RUN_RESPONSE 0xFD00000000000000LL
179 /* A range of ports reserved for registering a PID (top 8 bits)
180 * All ports matching the 8 top bits are reserved for exclusive use by
181 * registering a SRVID that matches the process-id of the requesting process
183 #define CTDB_SRVID_PID_RANGE 0x0000000000000000LL
185 /* A range of ports reserved for samba (top 8 bits)
186 * All ports matching the 8 top bits are reserved for exclusive use by
187 * CIFS server
189 #define CTDB_SRVID_SAMBA_NOTIFY 0xFE00000000000000LL
190 #define CTDB_SRVID_SAMBA_RANGE 0xFE00000000000000LL
192 /* A range of ports reserved for a CTDB NFS server (top 8 bits)
193 * All ports matching the 8 top bits are reserved for exclusive use by
194 * NFS server
196 #define CTDB_SRVID_NFSD_RANGE 0xEE00000000000000LL
198 /* A range of ports reserved for a CTDB ISCSI server (top 8 bits)
199 * All ports matching the 8 top bits are reserved for exclusive use by
200 * ISCSI server
202 #define CTDB_SRVID_ISCSID_RANGE 0xDE00000000000000LL
204 /* A range of ports reserved for testing (top 8 bits)
205 * All ports matching the 8 top bits are reserved for exclusive use by
206 * test applications
208 #define CTDB_SRVID_TEST_RANGE 0xCE00000000000000LL
210 /* Range of ports reserved for traversals */
211 #define CTDB_SRVID_TRAVERSE_RANGE 0xBE00000000000000LL
214 enum ctdb_controls {CTDB_CONTROL_PROCESS_EXISTS = 0,
215 CTDB_CONTROL_STATISTICS = 1,
216 /* #2 removed */
217 CTDB_CONTROL_PING = 3,
218 CTDB_CONTROL_GETDBPATH = 4,
219 CTDB_CONTROL_GETVNNMAP = 5,
220 CTDB_CONTROL_SETVNNMAP = 6,
221 CTDB_CONTROL_GET_DEBUG = 7,
222 CTDB_CONTROL_SET_DEBUG = 8,
223 CTDB_CONTROL_GET_DBMAP = 9,
224 CTDB_CONTROL_GET_NODEMAPv4 = 10, /* obsolete */
225 CTDB_CONTROL_SET_DMASTER = 11, /* obsolete */
226 /* #12 removed */
227 CTDB_CONTROL_PULL_DB = 13,
228 CTDB_CONTROL_PUSH_DB = 14,
229 CTDB_CONTROL_GET_RECMODE = 15,
230 CTDB_CONTROL_SET_RECMODE = 16,
231 CTDB_CONTROL_STATISTICS_RESET = 17,
232 CTDB_CONTROL_DB_ATTACH = 18,
233 CTDB_CONTROL_SET_CALL = 19, /* obsolete */
234 CTDB_CONTROL_TRAVERSE_START = 20,
235 CTDB_CONTROL_TRAVERSE_ALL = 21,
236 CTDB_CONTROL_TRAVERSE_DATA = 22,
237 CTDB_CONTROL_REGISTER_SRVID = 23,
238 CTDB_CONTROL_DEREGISTER_SRVID = 24,
239 CTDB_CONTROL_GET_DBNAME = 25,
240 CTDB_CONTROL_ENABLE_SEQNUM = 26,
241 CTDB_CONTROL_UPDATE_SEQNUM = 27,
242 /* #28 removed */
243 CTDB_CONTROL_DUMP_MEMORY = 29,
244 CTDB_CONTROL_GET_PID = 30,
245 CTDB_CONTROL_GET_RECMASTER = 31,
246 CTDB_CONTROL_SET_RECMASTER = 32,
247 CTDB_CONTROL_FREEZE = 33,
248 CTDB_CONTROL_THAW = 34,
249 CTDB_CONTROL_GET_PNN = 35,
250 CTDB_CONTROL_SHUTDOWN = 36,
251 CTDB_CONTROL_GET_MONMODE = 37,
252 /* #38 removed */
253 /* #39 removed */
254 /* #40 removed */
255 /* #41 removed */
256 CTDB_CONTROL_TAKEOVER_IPv4 = 42, /* obsolete */
257 CTDB_CONTROL_RELEASE_IPv4 = 43, /* obsolete */
258 CTDB_CONTROL_TCP_CLIENT = 44,
259 CTDB_CONTROL_TCP_ADD = 45,
260 CTDB_CONTROL_TCP_REMOVE = 46,
261 CTDB_CONTROL_STARTUP = 47,
262 CTDB_CONTROL_SET_TUNABLE = 48,
263 CTDB_CONTROL_GET_TUNABLE = 49,
264 CTDB_CONTROL_LIST_TUNABLES = 50,
265 CTDB_CONTROL_GET_PUBLIC_IPSv4 = 51, /* obsolete */
266 CTDB_CONTROL_MODIFY_FLAGS = 52,
267 CTDB_CONTROL_GET_ALL_TUNABLES = 53,
268 CTDB_CONTROL_KILL_TCP = 54,
269 CTDB_CONTROL_GET_TCP_TICKLE_LIST = 55,
270 CTDB_CONTROL_SET_TCP_TICKLE_LIST = 56,
271 CTDB_CONTROL_REGISTER_SERVER_ID = 57,
272 CTDB_CONTROL_UNREGISTER_SERVER_ID = 58,
273 CTDB_CONTROL_CHECK_SERVER_ID = 59,
274 CTDB_CONTROL_GET_SERVER_ID_LIST = 60,
275 CTDB_CONTROL_DB_ATTACH_PERSISTENT = 61,
276 CTDB_CONTROL_PERSISTENT_STORE = 62, /* obsolete */
277 CTDB_CONTROL_UPDATE_RECORD = 63,
278 CTDB_CONTROL_SEND_GRATUITOUS_ARP = 64,
279 CTDB_CONTROL_TRANSACTION_START = 65,
280 CTDB_CONTROL_TRANSACTION_COMMIT = 66,
281 CTDB_CONTROL_WIPE_DATABASE = 67,
282 /* #68 removed */
283 CTDB_CONTROL_UPTIME = 69,
284 CTDB_CONTROL_START_RECOVERY = 70,
285 CTDB_CONTROL_END_RECOVERY = 71,
286 CTDB_CONTROL_RELOAD_NODES_FILE = 72,
287 /* #73 removed */
288 CTDB_CONTROL_TRY_DELETE_RECORDS = 74,
289 CTDB_CONTROL_ENABLE_MONITOR = 75,
290 CTDB_CONTROL_DISABLE_MONITOR = 76,
291 CTDB_CONTROL_ADD_PUBLIC_IP = 77,
292 CTDB_CONTROL_DEL_PUBLIC_IP = 78,
293 CTDB_CONTROL_RUN_EVENTSCRIPTS = 79,
294 CTDB_CONTROL_GET_CAPABILITIES = 80,
295 CTDB_CONTROL_START_PERSISTENT_UPDATE = 81, /* obsolete */
296 CTDB_CONTROL_CANCEL_PERSISTENT_UPDATE= 82, /* obsolete */
297 CTDB_CONTROL_TRANS2_COMMIT = 83, /* obsolete */
298 CTDB_CONTROL_TRANS2_FINISHED = 84, /* obsolete */
299 CTDB_CONTROL_TRANS2_ERROR = 85, /* obsolete */
300 CTDB_CONTROL_TRANS2_COMMIT_RETRY = 86, /* obsolete */
301 CTDB_CONTROL_RECD_PING = 87,
302 CTDB_CONTROL_RELEASE_IP = 88,
303 CTDB_CONTROL_TAKEOVER_IP = 89,
304 CTDB_CONTROL_GET_PUBLIC_IPS = 90,
305 CTDB_CONTROL_GET_NODEMAP = 91,
306 /* missing */
307 CTDB_CONTROL_GET_EVENT_SCRIPT_STATUS = 96,
308 CTDB_CONTROL_TRAVERSE_KILL = 97,
309 CTDB_CONTROL_RECD_RECLOCK_LATENCY = 98,
310 CTDB_CONTROL_GET_RECLOCK_FILE = 99,
311 CTDB_CONTROL_SET_RECLOCK_FILE = 100,
312 CTDB_CONTROL_STOP_NODE = 101,
313 CTDB_CONTROL_CONTINUE_NODE = 102,
314 CTDB_CONTROL_SET_NATGWSTATE = 103,
315 CTDB_CONTROL_SET_LMASTERROLE = 104,
316 CTDB_CONTROL_SET_RECMASTERROLE = 105,
317 CTDB_CONTROL_ENABLE_SCRIPT = 107,
318 CTDB_CONTROL_DISABLE_SCRIPT = 108,
319 CTDB_CONTROL_SET_BAN_STATE = 109,
320 CTDB_CONTROL_GET_BAN_STATE = 110,
321 CTDB_CONTROL_SET_DB_PRIORITY = 111,
322 CTDB_CONTROL_GET_DB_PRIORITY = 112,
323 CTDB_CONTROL_TRANSACTION_CANCEL = 113,
324 CTDB_CONTROL_REGISTER_NOTIFY = 114,
325 CTDB_CONTROL_DEREGISTER_NOTIFY = 115,
326 CTDB_CONTROL_TRANS2_ACTIVE = 116, /* obsolete */
327 CTDB_CONTROL_GET_LOG = 117, /* obsolete */
328 CTDB_CONTROL_CLEAR_LOG = 118, /* obsolete */
329 CTDB_CONTROL_TRANS3_COMMIT = 119,
330 CTDB_CONTROL_GET_DB_SEQNUM = 120,
331 CTDB_CONTROL_DB_SET_HEALTHY = 121,
332 CTDB_CONTROL_DB_GET_HEALTH = 122,
333 CTDB_CONTROL_GET_PUBLIC_IP_INFO = 123,
334 CTDB_CONTROL_GET_IFACES = 124,
335 CTDB_CONTROL_SET_IFACE_LINK_STATE = 125,
336 CTDB_CONTROL_TCP_ADD_DELAYED_UPDATE = 126,
337 CTDB_CONTROL_GET_STAT_HISTORY = 127,
338 CTDB_CONTROL_SCHEDULE_FOR_DELETION = 128,
339 CTDB_CONTROL_SET_DB_READONLY = 129,
340 CTDB_CONTROL_CHECK_SRVIDS = 130,
341 CTDB_CONTROL_TRAVERSE_START_EXT = 131,
342 CTDB_CONTROL_GET_DB_STATISTICS = 132,
343 CTDB_CONTROL_SET_DB_STICKY = 133,
344 CTDB_CONTROL_RELOAD_PUBLIC_IPS = 134,
345 CTDB_CONTROL_TRAVERSE_ALL_EXT = 135,
346 CTDB_CONTROL_RECEIVE_RECORDS = 136,
347 CTDB_CONTROL_IPREALLOCATED = 137,
348 CTDB_CONTROL_GET_RUNSTATE = 138,
349 CTDB_CONTROL_DB_DETACH = 139,
350 CTDB_CONTROL_GET_NODES_FILE = 140,
351 CTDB_CONTROL_DB_FREEZE = 141,
352 CTDB_CONTROL_DB_THAW = 142,
353 CTDB_CONTROL_DB_TRANSACTION_START = 143,
354 CTDB_CONTROL_DB_TRANSACTION_COMMIT = 144,
355 CTDB_CONTROL_DB_TRANSACTION_CANCEL = 145,
358 #define CTDB_MONITORING_ACTIVE 0
359 #define CTDB_MONITORING_DISABLED 1
361 #define MAX_COUNT_BUCKETS 16
362 #define MAX_HOT_KEYS 10
364 struct ctdb_latency_counter {
365 int num;
366 double min;
367 double max;
368 double total;
371 struct ctdb_statistics {
372 uint32_t num_clients;
373 uint32_t frozen;
374 uint32_t recovering;
375 uint32_t client_packets_sent;
376 uint32_t client_packets_recv;
377 uint32_t node_packets_sent;
378 uint32_t node_packets_recv;
379 uint32_t keepalive_packets_sent;
380 uint32_t keepalive_packets_recv;
381 struct {
382 uint32_t req_call;
383 uint32_t reply_call;
384 uint32_t req_dmaster;
385 uint32_t reply_dmaster;
386 uint32_t reply_error;
387 uint32_t req_message;
388 uint32_t req_control;
389 uint32_t reply_control;
390 } node;
391 struct {
392 uint32_t req_call;
393 uint32_t req_message;
394 uint32_t req_control;
395 } client;
396 struct {
397 uint32_t call;
398 uint32_t control;
399 uint32_t traverse;
400 } timeouts;
401 struct {
402 struct ctdb_latency_counter ctdbd;
403 struct ctdb_latency_counter recd;
404 } reclock;
405 struct {
406 uint32_t num_calls;
407 uint32_t num_current;
408 uint32_t num_pending;
409 uint32_t num_failed;
410 struct ctdb_latency_counter latency;
411 uint32_t buckets[MAX_COUNT_BUCKETS];
412 } locks;
413 uint32_t total_calls;
414 uint32_t pending_calls;
415 uint32_t childwrite_calls;
416 uint32_t pending_childwrite_calls;
417 uint32_t memory_used;
418 uint32_t __last_counter; /* hack */
419 uint32_t max_hop_count;
420 uint32_t hop_count_bucket[MAX_COUNT_BUCKETS];
421 struct ctdb_latency_counter call_latency;
422 struct ctdb_latency_counter childwrite_latency;
423 uint32_t num_recoveries;
424 struct timeval statistics_start_time;
425 struct timeval statistics_current_time;
426 uint32_t total_ro_delegations;
427 uint32_t total_ro_revokes;
430 #define INVALID_GENERATION 1
431 /* table that contains the mapping between a hash value and lmaster
433 struct ctdb_vnn_map {
434 uint32_t generation;
435 uint32_t size;
436 uint32_t *map;
439 struct ctdb_dbid {
440 uint32_t db_id;
441 #define CTDB_DB_FLAGS_PERSISTENT 0x01
442 #define CTDB_DB_FLAGS_READONLY 0x02
443 #define CTDB_DB_FLAGS_STICKY 0x04
444 uint8_t flags;
447 struct ctdb_dbid_map {
448 uint32_t num;
449 struct ctdb_dbid *dbs;
452 struct ctdb_pulldb {
453 uint32_t db_id;
454 #define CTDB_LMASTER_ANY 0xffffffff
455 uint32_t lmaster;
458 #define CTDB_RECOVERY_NORMAL 0
459 #define CTDB_RECOVERY_ACTIVE 1
461 #define CTDB_NUM_DB_PRIORITIES 3
464 the extended header for records in the ltdb
466 struct ctdb_ltdb_header {
467 uint64_t rsn;
468 uint32_t dmaster;
469 uint32_t reserved1;
470 #define CTDB_REC_FLAG_DEFAULT 0x00000000
471 #define CTDB_REC_FLAG_MIGRATED_WITH_DATA 0x00010000
472 #define CTDB_REC_FLAG_VACUUM_MIGRATED 0x00020000
473 #define CTDB_REC_FLAG_AUTOMATIC 0x00040000
474 #define CTDB_REC_RO_HAVE_DELEGATIONS 0x01000000
475 #define CTDB_REC_RO_HAVE_READONLY 0x02000000
476 #define CTDB_REC_RO_REVOKING_READONLY 0x04000000
477 #define CTDB_REC_RO_REVOKE_COMPLETE 0x08000000
478 #define CTDB_REC_RO_FLAGS (CTDB_REC_RO_HAVE_DELEGATIONS|\
479 CTDB_REC_RO_HAVE_READONLY|\
480 CTDB_REC_RO_REVOKING_READONLY|\
481 CTDB_REC_RO_REVOKE_COMPLETE)
482 uint32_t flags;
485 struct ctdb_rec_data {
486 uint32_t reqid;
487 struct ctdb_ltdb_header *header;
488 TDB_DATA key, data;
491 struct ctdb_rec_buffer {
492 uint32_t db_id;
493 uint32_t count;
494 uint8_t *buf;
495 size_t buflen;
498 typedef int (*ctdb_rec_parser_func_t)(uint32_t reqid,
499 struct ctdb_ltdb_header *header,
500 TDB_DATA key, TDB_DATA data,
501 void *private_data);
503 struct ctdb_traverse_start {
504 uint32_t db_id;
505 uint32_t reqid;
506 uint64_t srvid;
509 struct ctdb_traverse_all {
510 uint32_t db_id;
511 uint32_t reqid;
512 uint32_t pnn;
513 uint32_t client_reqid;
514 uint64_t srvid;
517 struct ctdb_traverse_start_ext {
518 uint32_t db_id;
519 uint32_t reqid;
520 uint64_t srvid;
521 bool withemptyrecords;
524 struct ctdb_traverse_all_ext {
525 uint32_t db_id;
526 uint32_t reqid;
527 uint32_t pnn;
528 uint32_t client_reqid;
529 uint64_t srvid;
530 bool withemptyrecords;
533 typedef union {
534 struct sockaddr sa;
535 struct sockaddr_in ip;
536 struct sockaddr_in6 ip6;
537 } ctdb_sock_addr;
539 struct ctdb_connection {
540 ctdb_sock_addr src;
541 ctdb_sock_addr dst;
544 struct ctdb_tunable {
545 const char *name;
546 uint32_t value;
549 struct ctdb_var_list {
550 int count;
551 const char **var;
554 struct ctdb_node_flag_change {
555 uint32_t pnn;
556 uint32_t new_flags;
557 uint32_t old_flags;
560 /* all tunable variables go in here */
561 struct ctdb_tunable_list {
562 uint32_t max_redirect_count;
563 uint32_t seqnum_interval; /* unit is ms */
564 uint32_t control_timeout;
565 uint32_t traverse_timeout;
566 uint32_t keepalive_interval;
567 uint32_t keepalive_limit;
568 uint32_t recover_timeout;
569 uint32_t recover_interval;
570 uint32_t election_timeout;
571 uint32_t takeover_timeout;
572 uint32_t monitor_interval;
573 uint32_t tickle_update_interval;
574 uint32_t script_timeout;
575 uint32_t script_timeout_count; /* allow dodgy scripts to hang this many times in a row before we mark the node unhealthy */
576 uint32_t script_unhealthy_on_timeout; /* obsolete */
577 uint32_t recovery_grace_period;
578 uint32_t recovery_ban_period;
579 uint32_t database_hash_size;
580 uint32_t database_max_dead;
581 uint32_t rerecovery_timeout;
582 uint32_t enable_bans;
583 uint32_t deterministic_public_ips;
584 uint32_t reclock_ping_period;
585 uint32_t no_ip_failback;
586 uint32_t disable_ip_failover;
587 uint32_t verbose_memory_names;
588 uint32_t recd_ping_timeout;
589 uint32_t recd_ping_failcount;
590 uint32_t log_latency_ms;
591 uint32_t reclock_latency_ms;
592 uint32_t recovery_drop_all_ips;
593 uint32_t verify_recovery_lock;
594 uint32_t vacuum_interval;
595 uint32_t vacuum_max_run_time;
596 uint32_t repack_limit;
597 uint32_t vacuum_limit;
598 uint32_t max_queue_depth_drop_msg;
599 uint32_t allow_unhealthy_db_read;
600 uint32_t stat_history_interval;
601 uint32_t deferred_attach_timeout;
602 uint32_t vacuum_fast_path_count;
603 uint32_t lcp2_public_ip_assignment;
604 uint32_t allow_client_db_attach;
605 uint32_t recover_pdb_by_seqnum;
606 uint32_t deferred_rebalance_on_node_add;
607 uint32_t fetch_collapse;
608 uint32_t hopcount_make_sticky;
609 uint32_t sticky_duration;
610 uint32_t sticky_pindown;
611 uint32_t no_ip_takeover;
612 uint32_t db_record_count_warn;
613 uint32_t db_record_size_warn;
614 uint32_t db_size_warn;
615 uint32_t pulldb_preallocation_size;
616 uint32_t no_ip_host_on_all_disabled;
617 uint32_t samba3_hack;
618 uint32_t mutex_enabled;
619 uint32_t lock_processes_per_db;
622 struct ctdb_tickle_list {
623 ctdb_sock_addr addr;
624 uint32_t num;
625 struct ctdb_connection *conn;
628 enum ctdb_client_type {
629 SERVER_TYPE_CTDB = 0,
630 SERVER_TYPE_SAMBA = 1,
631 SERVER_TYPE_NFSD = 2,
632 SERVER_TYPE_ISCSID = 3
635 struct ctdb_client_id {
636 enum ctdb_client_type type;
637 uint32_t pnn;
638 uint32_t server_id;
641 struct ctdb_client_id_list {
642 uint32_t num;
643 struct ctdb_client_id *cid;
646 struct ctdb_client_id_map {
647 int count;
648 struct ctdb_client_id_list *list;
651 struct ctdb_addr_info {
652 ctdb_sock_addr addr;
653 uint32_t mask;
654 const char *iface;
657 struct ctdb_transdb {
658 uint32_t db_id;
659 uint32_t tid;
662 struct ctdb_uptime {
663 struct timeval current_time;
664 struct timeval ctdbd_start_time;
665 struct timeval last_recovery_started;
666 struct timeval last_recovery_finished;
669 struct ctdb_public_ip {
670 uint32_t pnn;
671 ctdb_sock_addr addr;
674 struct ctdb_public_ip_list {
675 uint32_t num;
676 struct ctdb_public_ip *ip;
680 * Node flags
682 #define NODE_FLAGS_DISCONNECTED 0x00000001 /* node isn't connected */
683 #define NODE_FLAGS_UNHEALTHY 0x00000002 /* monitoring says node is unhealthy */
684 #define NODE_FLAGS_PERMANENTLY_DISABLED 0x00000004 /* administrator has disabled node */
685 #define NODE_FLAGS_BANNED 0x00000008 /* recovery daemon has banned the node */
686 #define NODE_FLAGS_DELETED 0x00000010 /* this node has been deleted */
687 #define NODE_FLAGS_STOPPED 0x00000020 /* this node has been stopped */
688 #define NODE_FLAGS_DISABLED (NODE_FLAGS_UNHEALTHY|NODE_FLAGS_PERMANENTLY_DISABLED)
689 #define NODE_FLAGS_INACTIVE (NODE_FLAGS_DELETED|NODE_FLAGS_DISCONNECTED|NODE_FLAGS_BANNED|NODE_FLAGS_STOPPED)
692 * Node capabilities
694 #define CTDB_CAP_RECMASTER 0x00000001
695 #define CTDB_CAP_LMASTER 0x00000002
696 /* This capability is set if CTDB_LVS_PUBLIC_IP is set */
697 #define CTDB_CAP_LVS 0x00000004
698 /* This capability is set if NATGW is enabled */
699 #define CTDB_CAP_NATGW 0x00000008
702 * Node features
704 #define CTDB_CAP_PARALLEL_RECOVERY 0x00010000
706 #define CTDB_CAP_FEATURES (CTDB_CAP_PARALLEL_RECOVERY)
708 #define CTDB_CAP_DEFAULT (CTDB_CAP_RECMASTER | \
709 CTDB_CAP_LMASTER | \
710 CTDB_CAP_FEATURES)
712 struct ctdb_node_and_flags {
713 uint32_t pnn;
714 uint32_t flags;
715 ctdb_sock_addr addr;
718 struct ctdb_node_map {
719 uint32_t num;
720 struct ctdb_node_and_flags *node;
723 enum ctdb_event {
724 CTDB_EVENT_INIT, /* CTDB starting up: no args */
725 CTDB_EVENT_SETUP, /* CTDB starting up after transport is readdy: no args. */
726 CTDB_EVENT_STARTUP, /* CTDB starting up after initial recovery: no args. */
727 CTDB_EVENT_START_RECOVERY, /* CTDB recovery starting: no args. */
728 CTDB_EVENT_RECOVERED, /* CTDB recovery finished: no args. */
729 CTDB_EVENT_TAKE_IP, /* IP taken: interface, IP address, netmask bits. */
730 CTDB_EVENT_RELEASE_IP, /* IP released: interface, IP address, netmask bits. */
731 CTDB_EVENT_STOPPED, /* Deprecated, do not use. */
732 CTDB_EVENT_MONITOR, /* Please check if service is healthy: no args. */
733 CTDB_EVENT_STATUS, /* Deprecated, do not use. */
734 CTDB_EVENT_SHUTDOWN, /* CTDB shutting down: no args. */
735 CTDB_EVENT_RELOAD, /* Deprecated, do not use */
736 CTDB_EVENT_UPDATE_IP, /* IP updating: old interface, new interface, IP address, netmask bits. */
737 CTDB_EVENT_IPREALLOCATED, /* when a takeover_run() completes */
738 CTDB_EVENT_MAX
741 #define MAX_SCRIPT_NAME 31
742 #define MAX_SCRIPT_OUTPUT 511
744 struct ctdb_script {
745 char name[MAX_SCRIPT_NAME+1];
746 struct timeval start;
747 struct timeval finished;
748 int32_t status;
749 char output[MAX_SCRIPT_OUTPUT+1];
752 struct ctdb_script_list {
753 uint32_t num_scripts;
754 struct ctdb_script *script;
757 struct ctdb_ban_state {
758 uint32_t pnn;
759 uint32_t time;
762 struct ctdb_db_priority {
763 uint32_t db_id;
764 uint32_t priority;
767 struct ctdb_notify_data {
768 uint64_t srvid;
769 TDB_DATA data;
772 #ifdef IFNAMSIZ
773 #define CTDB_IFACE_SIZE IFNAMSIZ
774 #else
775 #define CTDB_IFACE_SIZE 16
776 #endif
778 struct ctdb_iface {
779 char name[CTDB_IFACE_SIZE+2];
780 uint16_t link_state;
781 uint32_t references;
784 struct ctdb_iface_list {
785 uint32_t num;
786 struct ctdb_iface *iface;
789 struct ctdb_public_ip_info {
790 struct ctdb_public_ip ip;
791 uint32_t active_idx;
792 struct ctdb_iface_list *ifaces;
795 struct ctdb_statistics_list {
796 int num;
797 struct ctdb_statistics *stats;
800 struct ctdb_key_data {
801 uint32_t db_id;
802 struct ctdb_ltdb_header header;
803 TDB_DATA key;
806 struct ctdb_uint8_array {
807 int num;
808 uint8_t *val;
811 struct ctdb_uint64_array {
812 int num;
813 uint64_t *val;
816 struct ctdb_db_statistics {
817 struct {
818 uint32_t num_calls;
819 uint32_t num_current;
820 uint32_t num_pending;
821 uint32_t num_failed;
822 struct ctdb_latency_counter latency;
823 uint32_t buckets[MAX_COUNT_BUCKETS];
824 } locks;
825 struct {
826 struct ctdb_latency_counter latency;
827 } vacuum;
828 uint32_t db_ro_delegations;
829 uint32_t db_ro_revokes;
830 uint32_t hop_count_bucket[MAX_COUNT_BUCKETS];
831 uint32_t num_hot_keys;
832 struct {
833 uint32_t count;
834 TDB_DATA key;
835 } hot_keys[MAX_HOT_KEYS];
838 enum ctdb_runstate {
839 CTDB_RUNSTATE_UNKNOWN,
840 CTDB_RUNSTATE_INIT,
841 CTDB_RUNSTATE_SETUP,
842 CTDB_RUNSTATE_FIRST_RECOVERY,
843 CTDB_RUNSTATE_STARTUP,
844 CTDB_RUNSTATE_RUNNING,
845 CTDB_RUNSTATE_SHUTDOWN,
848 struct ctdb_req_control_data {
849 uint32_t opcode;
850 union {
851 pid_t pid;
852 uint32_t db_id;
853 struct ctdb_vnn_map *vnnmap;
854 uint32_t loglevel;
855 struct ctdb_pulldb *pulldb;
856 struct ctdb_rec_buffer *recbuf;
857 uint32_t recmode;
858 const char *db_name;
859 struct ctdb_traverse_start *traverse_start;
860 struct ctdb_traverse_all *traverse_all;
861 struct ctdb_rec_data *rec_data;
862 uint32_t recmaster;
863 struct ctdb_connection *conn;
864 struct ctdb_tunable *tunable;
865 const char *tun_var;
866 struct ctdb_node_flag_change *flag_change;
867 ctdb_sock_addr *addr;
868 struct ctdb_tickle_list *tickles;
869 struct ctdb_client_id *cid;
870 struct ctdb_addr_info *addr_info;
871 uint32_t tid;
872 struct ctdb_transdb *transdb;
873 const char *event_str;
874 struct ctdb_public_ip *pubip;
875 enum ctdb_event event;
876 double reclock_latency;
877 const char *reclock_file;
878 uint32_t role;
879 const char *script;
880 struct ctdb_ban_state *ban_state;
881 struct ctdb_db_priority *db_prio;
882 struct ctdb_notify_data *notify;
883 uint64_t srvid;
884 struct ctdb_iface *iface;
885 struct ctdb_key_data *key;
886 struct ctdb_uint64_array *u64_array;
887 struct ctdb_traverse_start_ext *traverse_start_ext;
888 struct ctdb_traverse_all_ext *traverse_all_ext;
889 } data;
892 struct ctdb_reply_control_data {
893 uint32_t opcode;
894 union {
895 struct ctdb_statistics *stats;
896 const char *db_path;
897 struct ctdb_vnn_map *vnnmap;
898 uint32_t loglevel;
899 struct ctdb_dbid_map *dbmap;
900 struct ctdb_rec_buffer *recbuf;
901 uint32_t db_id;
902 const char *db_name;
903 const char *mem_str;
904 uint32_t tun_value;
905 struct ctdb_var_list *tun_var_list;
906 struct ctdb_tunable_list *tun_list;
907 struct ctdb_tickle_list *tickles;
908 struct ctdb_client_id_map *cid_map;
909 struct ctdb_uptime *uptime;
910 uint32_t caps;
911 struct ctdb_public_ip_list *pubip_list;
912 struct ctdb_node_map *nodemap;
913 struct ctdb_script_list *script_list;
914 const char *reclock_file;
915 struct ctdb_ban_state *ban_state;
916 uint64_t seqnum;
917 const char *reason;
918 struct ctdb_public_ip_info *ipinfo;
919 struct ctdb_iface_list *iface_list;
920 struct ctdb_statistics_list *stats_list;
921 struct ctdb_uint8_array *u8_array;
922 struct ctdb_db_statistics *dbstats;
923 enum ctdb_runstate runstate;
924 } data;
927 struct ctdb_req_control {
928 uint32_t opcode;
929 uint32_t pad;
930 uint64_t srvid;
931 uint32_t client_id;
932 #define CTDB_CTRL_FLAG_NOREPLY 1
933 #define CTDB_CTRL_FLAG_OPCODE_SPECIFIC 0xFFFF0000
934 uint32_t flags;
935 struct ctdb_req_control_data rdata;
938 struct ctdb_reply_control {
939 int32_t status;
940 const char *errmsg;
941 struct ctdb_reply_control_data rdata;
944 struct ctdb_election_message {
945 uint32_t num_connected;
946 struct timeval priority_time;
947 uint32_t pnn;
948 uint32_t node_flags;
951 struct ctdb_srvid_message {
952 uint32_t pnn;
953 uint64_t srvid;
956 struct ctdb_disable_message {
957 uint32_t pnn;
958 uint64_t srvid;
959 uint32_t timeout;
962 union ctdb_message_data {
963 /* SRVID_ELECTION */
964 struct ctdb_election_message *election;
965 /* SRVID_RELEASE_IP, SRVID_TAKE_IP */
966 const char *ipaddr;
967 /* SRVID_SET_NODE_FLAGS, SERVID_PUSH_NODE_FLAGS */
968 struct ctdb_node_flag_change *flag_change;
969 /* SRVID_RECD_UPDATE_IP */
970 struct ctdb_public_ip *pubip;
971 /* SRVID_VACUUM_FETCH */
972 struct ctdb_rec_buffer *recbuf;
973 /* SRVID_DETACH_DATABASE */
974 uint32_t db_id;
975 /* SRVID_MEM_DUMP, SRVID_TAKEOVER_RUN */
976 struct ctdb_srvid_message *msg;
977 /* SRVID_REBALANCE_NODE */
978 uint32_t pnn;
979 /* SRVID_DISABLE_TAKEOVER_RUNS, SRVID_DISABLE_RECOVERIES */
980 struct ctdb_disable_message *disable;
981 /* SRVID_DISABLE_IP_CHECK */
982 uint32_t timeout;
985 struct ctdb_req_message {
986 uint64_t srvid;
987 union ctdb_message_data data;
990 struct ctdb_req_message_data {
991 uint64_t srvid;
992 TDB_DATA data;
995 /* This is equivalent to server_id */
996 struct ctdb_server_id {
997 uint64_t pid;
998 uint32_t task_id;
999 uint32_t vnn;
1000 uint64_t unique_id;
1003 enum ctdb_g_lock_type {
1004 G_LOCK_READ = 0,
1005 G_LOCK_WRITE = 1,
1008 struct ctdb_g_lock {
1009 enum ctdb_g_lock_type type;
1010 struct ctdb_server_id sid;
1013 struct ctdb_g_lock_list {
1014 unsigned int num;
1015 struct ctdb_g_lock *lock;
1018 #endif /* __CTDB_PROTOCOL_H__ */