lib: Fix a comment in idmap_cache.c
[Samba.git] / ctdb / protocol / protocol.h
blob7b5a5983be11229ba1f84ec7dc6fa132dafa3a16
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 #include <tdb.h>
25 #define CTDB_MAGIC 0x43544442 /* CTDB */
26 #define CTDB_PROTOCOL 1
28 enum ctdb_operation {
29 CTDB_REQ_CALL = 0,
30 CTDB_REPLY_CALL = 1,
31 CTDB_REQ_DMASTER = 2,
32 CTDB_REPLY_DMASTER = 3,
33 CTDB_REPLY_ERROR = 4,
34 CTDB_REQ_MESSAGE = 5,
35 /* #6 removed */
36 CTDB_REQ_CONTROL = 7,
37 CTDB_REPLY_CONTROL = 8,
38 CTDB_REQ_KEEPALIVE = 9,
41 /* used on the domain socket, send a pdu to the local daemon */
42 #define CTDB_CURRENT_NODE 0xF0000001
43 /* send a broadcast to all nodes in the cluster, active or not */
44 #define CTDB_BROADCAST_ALL 0xF0000002
45 /* send a broadcast to all nodes in the current vnn map */
46 #define CTDB_BROADCAST_VNNMAP 0xF0000003
47 /* send a broadcast to all connected nodes */
48 #define CTDB_BROADCAST_CONNECTED 0xF0000004
49 /* send a broadcast to selected connected nodes */
50 #define CTDB_MULTICAST 0xF0000005
52 #define CTDB_UNKNOWN_PNN 0xFFFFFFFF
54 /* the key used to store persistent db sequence number */
55 #define CTDB_DB_SEQNUM_KEY "__db_sequence_number__"
57 struct ctdb_req_header {
58 uint32_t length;
59 uint32_t ctdb_magic;
60 uint32_t ctdb_version;
61 uint32_t generation;
62 uint32_t operation;
63 uint32_t destnode;
64 uint32_t srcnode;
65 uint32_t reqid;
68 struct ctdb_req_call {
69 uint32_t flags;
70 uint32_t db_id;
71 uint32_t callid;
72 uint32_t hopcount;
73 TDB_DATA key;
74 TDB_DATA calldata;
77 struct ctdb_reply_call {
78 int32_t status;
79 TDB_DATA data;
82 struct ctdb_reply_error {
83 int32_t status;
84 TDB_DATA msg;
87 struct ctdb_req_dmaster {
88 uint32_t db_id;
89 uint64_t rsn;
90 uint32_t dmaster;
91 TDB_DATA key;
92 TDB_DATA data;
95 struct ctdb_reply_dmaster {
96 uint32_t db_id;
97 uint64_t rsn;
98 TDB_DATA key;
99 TDB_DATA data;
102 #define CTDB_NULL_FUNC 0xFF000001
103 #define CTDB_FETCH_FUNC 0xFF000002
104 #define CTDB_FETCH_WITH_HEADER_FUNC 0xFF000003
106 struct ctdb_call {
107 int call_id;
108 TDB_DATA key;
109 TDB_DATA call_data;
110 TDB_DATA reply_data;
111 uint32_t status;
112 #define CTDB_IMMEDIATE_MIGRATION 0x00000001
113 #define CTDB_CALL_FLAG_VACUUM_MIGRATION 0x00000002
114 #define CTDB_WANT_READONLY 0x00000004
115 uint32_t flags;
118 /* SRVID to catch all messages */
119 #define CTDB_SRVID_ALL (~(uint64_t)0)
121 /* SRVID prefix used during recovery for pulling and pushing databases */
122 #define CTDB_SRVID_RECOVERY 0xF001000000000000LL
124 /* SRVID to assign of banning credits */
125 #define CTDB_SRVID_BANNING 0xF002000000000000LL
127 /* SRVID to inform of election data */
128 #define CTDB_SRVID_ELECTION 0xF100000000000000LL
130 /* SRVID to inform clients that the cluster has been reconfigured */
131 #define CTDB_SRVID_RECONFIGURE 0xF200000000000000LL
133 /* SRVID to inform clients an IP address has been released */
134 #define CTDB_SRVID_RELEASE_IP 0xF300000000000000LL
136 /* SRVID to inform clients that an IP address has been taken over */
137 #define CTDB_SRVID_TAKE_IP 0xF301000000000000LL
139 /* SRVID to inform recovery daemon of the node flags */
140 #define CTDB_SRVID_SET_NODE_FLAGS 0xF400000000000000LL
142 /* SRVID to inform recovery daemon to update public ip assignment */
143 #define CTDB_SRVID_RECD_UPDATE_IP 0xF500000000000000LL
145 /* SRVID to inform recovery daemon to migrate a set of records */
146 #define CTDB_SRVID_VACUUM_FETCH 0xF700000000000000LL
148 /* SRVID to inform recovery daemon to detach a database */
149 #define CTDB_SRVID_DETACH_DATABASE 0xF701000000000000LL
151 /* SRVID to inform recovery daemon to dump talloc memdump to the log */
152 #define CTDB_SRVID_MEM_DUMP 0xF800000000000000LL
154 /* SRVID to inform recovery daemon to send logs */
155 #define CTDB_SRVID_GETLOG 0xF801000000000000LL
157 /* SRVID to inform recovery daemon to clear logs */
158 #define CTDB_SRVID_CLEARLOG 0xF802000000000000LL
160 /* SRVID to inform recovery daemon to push the node flags to other nodes */
161 #define CTDB_SRVID_PUSH_NODE_FLAGS 0xF900000000000000LL
163 /* SRVID to inform recovery daemon to reload the nodes file */
164 #define CTDB_SRVID_RELOAD_NODES 0xFA00000000000000LL
166 /* SRVID to inform recovery daemon to perform a takeover run */
167 #define CTDB_SRVID_TAKEOVER_RUN 0xFB00000000000000LL
169 /* SRVID to inform recovery daemon to rebalance ips for a node. */
170 #define CTDB_SRVID_REBALANCE_NODE 0xFB01000000000000LL
172 /* SRVID to inform recovery daemon to stop takeover runs from occurring */
173 #define CTDB_SRVID_DISABLE_TAKEOVER_RUNS 0xFB03000000000000LL
175 /* SRVID to inform recovery daemon to stop recoveries from occurring */
176 #define CTDB_SRVID_DISABLE_RECOVERIES 0xFB04000000000000LL
178 /* SRVID to inform recovery daemon to disable the public ip checks */
179 #define CTDB_SRVID_DISABLE_IP_CHECK 0xFC00000000000000LL
181 /* A range of ports reserved for registering a PID (top 8 bits)
182 * All ports matching the 8 top bits are reserved for exclusive use by
183 * registering a SRVID that matches the process-id of the requesting process
185 #define CTDB_SRVID_PID_RANGE 0x0000000000000000LL
187 /* A range of ports reserved for samba (top 8 bits)
188 * All ports matching the 8 top bits are reserved for exclusive use by
189 * CIFS server
191 #define CTDB_SRVID_SAMBA_NOTIFY 0xFE00000000000000LL
192 #define CTDB_SRVID_SAMBA_RANGE 0xFE00000000000000LL
194 /* A range of ports reserved for a CTDB NFS server (top 8 bits)
195 * All ports matching the 8 top bits are reserved for exclusive use by
196 * NFS server
198 #define CTDB_SRVID_NFSD_RANGE 0xEE00000000000000LL
200 /* A range of ports reserved for a CTDB ISCSI server (top 8 bits)
201 * All ports matching the 8 top bits are reserved for exclusive use by
202 * ISCSI server
204 #define CTDB_SRVID_ISCSID_RANGE 0xDE00000000000000LL
206 /* A range of ports reserved for CTDB tool (top 8 bits)
207 * All ports matching the 8 top bits are reserved for exclusive use by
208 * CTDB tool
210 #define CTDB_SRVID_TOOL_RANGE 0xCE00000000000000LL
212 /* Range of ports reserved for test applications (top 8 bits)
213 * All ports matching the 8 top bits are reserved for exclusive use by
214 * test applications
216 #define CTDB_SRVID_TEST_RANGE 0xBE00000000000000LL
219 enum ctdb_controls {CTDB_CONTROL_PROCESS_EXISTS = 0,
220 CTDB_CONTROL_STATISTICS = 1,
221 /* #2 removed */
222 CTDB_CONTROL_PING = 3,
223 CTDB_CONTROL_GETDBPATH = 4,
224 CTDB_CONTROL_GETVNNMAP = 5,
225 CTDB_CONTROL_SETVNNMAP = 6,
226 CTDB_CONTROL_GET_DEBUG = 7,
227 CTDB_CONTROL_SET_DEBUG = 8,
228 CTDB_CONTROL_GET_DBMAP = 9,
229 CTDB_CONTROL_GET_NODEMAPv4 = 10, /* obsolete */
230 CTDB_CONTROL_SET_DMASTER = 11, /* obsolete */
231 /* #12 removed */
232 CTDB_CONTROL_PULL_DB = 13,
233 CTDB_CONTROL_PUSH_DB = 14,
234 CTDB_CONTROL_GET_RECMODE = 15,
235 CTDB_CONTROL_SET_RECMODE = 16,
236 CTDB_CONTROL_STATISTICS_RESET = 17,
237 CTDB_CONTROL_DB_ATTACH = 18,
238 CTDB_CONTROL_SET_CALL = 19, /* obsolete */
239 CTDB_CONTROL_TRAVERSE_START = 20,
240 CTDB_CONTROL_TRAVERSE_ALL = 21,
241 CTDB_CONTROL_TRAVERSE_DATA = 22,
242 CTDB_CONTROL_REGISTER_SRVID = 23,
243 CTDB_CONTROL_DEREGISTER_SRVID = 24,
244 CTDB_CONTROL_GET_DBNAME = 25,
245 CTDB_CONTROL_ENABLE_SEQNUM = 26,
246 CTDB_CONTROL_UPDATE_SEQNUM = 27,
247 /* #28 removed */
248 CTDB_CONTROL_DUMP_MEMORY = 29,
249 CTDB_CONTROL_GET_PID = 30,
250 CTDB_CONTROL_GET_RECMASTER = 31,
251 CTDB_CONTROL_SET_RECMASTER = 32,
252 CTDB_CONTROL_FREEZE = 33,
253 CTDB_CONTROL_THAW = 34, /* obsolete */
254 CTDB_CONTROL_GET_PNN = 35,
255 CTDB_CONTROL_SHUTDOWN = 36,
256 CTDB_CONTROL_GET_MONMODE = 37,
257 /* #38 removed */
258 /* #39 removed */
259 /* #40 removed */
260 /* #41 removed */
261 CTDB_CONTROL_TAKEOVER_IPv4 = 42, /* obsolete */
262 CTDB_CONTROL_RELEASE_IPv4 = 43, /* obsolete */
263 CTDB_CONTROL_TCP_CLIENT = 44,
264 CTDB_CONTROL_TCP_ADD = 45,
265 CTDB_CONTROL_TCP_REMOVE = 46,
266 CTDB_CONTROL_STARTUP = 47,
267 CTDB_CONTROL_SET_TUNABLE = 48,
268 CTDB_CONTROL_GET_TUNABLE = 49,
269 CTDB_CONTROL_LIST_TUNABLES = 50,
270 CTDB_CONTROL_GET_PUBLIC_IPSv4 = 51, /* obsolete */
271 CTDB_CONTROL_MODIFY_FLAGS = 52,
272 CTDB_CONTROL_GET_ALL_TUNABLES = 53,
273 CTDB_CONTROL_KILL_TCP = 54, /* obsolete */
274 CTDB_CONTROL_GET_TCP_TICKLE_LIST = 55,
275 CTDB_CONTROL_SET_TCP_TICKLE_LIST = 56,
276 CTDB_CONTROL_REGISTER_SERVER_ID = 57, /* obsolete */
277 CTDB_CONTROL_UNREGISTER_SERVER_ID = 58, /* obsolete */
278 CTDB_CONTROL_CHECK_SERVER_ID = 59, /* obsolete */
279 CTDB_CONTROL_GET_SERVER_ID_LIST = 60, /* obsolete */
280 CTDB_CONTROL_DB_ATTACH_PERSISTENT = 61,
281 CTDB_CONTROL_PERSISTENT_STORE = 62, /* obsolete */
282 CTDB_CONTROL_UPDATE_RECORD = 63,
283 CTDB_CONTROL_SEND_GRATUITOUS_ARP = 64,
284 CTDB_CONTROL_TRANSACTION_START = 65, /* obsolete */
285 CTDB_CONTROL_TRANSACTION_COMMIT = 66, /* obsolete */
286 CTDB_CONTROL_WIPE_DATABASE = 67,
287 /* #68 removed */
288 CTDB_CONTROL_UPTIME = 69,
289 CTDB_CONTROL_START_RECOVERY = 70,
290 CTDB_CONTROL_END_RECOVERY = 71,
291 CTDB_CONTROL_RELOAD_NODES_FILE = 72,
292 /* #73 removed */
293 CTDB_CONTROL_TRY_DELETE_RECORDS = 74,
294 CTDB_CONTROL_ENABLE_MONITOR = 75,
295 CTDB_CONTROL_DISABLE_MONITOR = 76,
296 CTDB_CONTROL_ADD_PUBLIC_IP = 77,
297 CTDB_CONTROL_DEL_PUBLIC_IP = 78,
298 CTDB_CONTROL_RUN_EVENTSCRIPTS = 79, /* obsolete */
299 CTDB_CONTROL_GET_CAPABILITIES = 80,
300 CTDB_CONTROL_START_PERSISTENT_UPDATE = 81, /* obsolete */
301 CTDB_CONTROL_CANCEL_PERSISTENT_UPDATE= 82, /* obsolete */
302 CTDB_CONTROL_TRANS2_COMMIT = 83, /* obsolete */
303 CTDB_CONTROL_TRANS2_FINISHED = 84, /* obsolete */
304 CTDB_CONTROL_TRANS2_ERROR = 85, /* obsolete */
305 CTDB_CONTROL_TRANS2_COMMIT_RETRY = 86, /* obsolete */
306 CTDB_CONTROL_RECD_PING = 87,
307 CTDB_CONTROL_RELEASE_IP = 88,
308 CTDB_CONTROL_TAKEOVER_IP = 89,
309 CTDB_CONTROL_GET_PUBLIC_IPS = 90,
310 CTDB_CONTROL_GET_NODEMAP = 91,
311 /* missing */
312 CTDB_CONTROL_GET_EVENT_SCRIPT_STATUS = 96, /* obsolete */
313 CTDB_CONTROL_TRAVERSE_KILL = 97,
314 CTDB_CONTROL_RECD_RECLOCK_LATENCY = 98,
315 CTDB_CONTROL_GET_RECLOCK_FILE = 99,
316 CTDB_CONTROL_SET_RECLOCK_FILE = 100, /* obsolete */
317 CTDB_CONTROL_STOP_NODE = 101,
318 CTDB_CONTROL_CONTINUE_NODE = 102,
319 CTDB_CONTROL_SET_NATGWSTATE = 103, /* obsolete */
320 CTDB_CONTROL_SET_LMASTERROLE = 104,
321 CTDB_CONTROL_SET_RECMASTERROLE = 105,
322 CTDB_CONTROL_ENABLE_SCRIPT = 107, /* obsolete */
323 CTDB_CONTROL_DISABLE_SCRIPT = 108, /* obsolete */
324 CTDB_CONTROL_SET_BAN_STATE = 109,
325 CTDB_CONTROL_GET_BAN_STATE = 110,
326 CTDB_CONTROL_SET_DB_PRIORITY = 111, /* obsolete */
327 CTDB_CONTROL_GET_DB_PRIORITY = 112, /* obsolete */
328 CTDB_CONTROL_TRANSACTION_CANCEL = 113, /* obsolete */
329 CTDB_CONTROL_REGISTER_NOTIFY = 114,
330 CTDB_CONTROL_DEREGISTER_NOTIFY = 115,
331 CTDB_CONTROL_TRANS2_ACTIVE = 116, /* obsolete */
332 CTDB_CONTROL_GET_LOG = 117, /* obsolete */
333 CTDB_CONTROL_CLEAR_LOG = 118, /* obsolete */
334 CTDB_CONTROL_TRANS3_COMMIT = 119,
335 CTDB_CONTROL_GET_DB_SEQNUM = 120,
336 CTDB_CONTROL_DB_SET_HEALTHY = 121,
337 CTDB_CONTROL_DB_GET_HEALTH = 122,
338 CTDB_CONTROL_GET_PUBLIC_IP_INFO = 123,
339 CTDB_CONTROL_GET_IFACES = 124,
340 CTDB_CONTROL_SET_IFACE_LINK_STATE = 125,
341 CTDB_CONTROL_TCP_ADD_DELAYED_UPDATE = 126,
342 CTDB_CONTROL_GET_STAT_HISTORY = 127,
343 CTDB_CONTROL_SCHEDULE_FOR_DELETION = 128,
344 CTDB_CONTROL_SET_DB_READONLY = 129,
345 CTDB_CONTROL_CHECK_SRVIDS = 130,
346 CTDB_CONTROL_TRAVERSE_START_EXT = 131,
347 CTDB_CONTROL_GET_DB_STATISTICS = 132,
348 CTDB_CONTROL_SET_DB_STICKY = 133,
349 CTDB_CONTROL_RELOAD_PUBLIC_IPS = 134,
350 CTDB_CONTROL_TRAVERSE_ALL_EXT = 135,
351 CTDB_CONTROL_RECEIVE_RECORDS = 136,
352 CTDB_CONTROL_IPREALLOCATED = 137,
353 CTDB_CONTROL_GET_RUNSTATE = 138,
354 CTDB_CONTROL_DB_DETACH = 139,
355 CTDB_CONTROL_GET_NODES_FILE = 140,
356 CTDB_CONTROL_DB_FREEZE = 141,
357 CTDB_CONTROL_DB_THAW = 142,
358 CTDB_CONTROL_DB_TRANSACTION_START = 143,
359 CTDB_CONTROL_DB_TRANSACTION_COMMIT = 144,
360 CTDB_CONTROL_DB_TRANSACTION_CANCEL = 145,
361 CTDB_CONTROL_DB_PULL = 146,
362 CTDB_CONTROL_DB_PUSH_START = 147,
363 CTDB_CONTROL_DB_PUSH_CONFIRM = 148,
366 #define CTDB_MONITORING_ENABLED 0
367 #define CTDB_MONITORING_DISABLED 1
369 #define MAX_COUNT_BUCKETS 16
370 #define MAX_HOT_KEYS 10
372 struct ctdb_latency_counter {
373 int num;
374 double min;
375 double max;
376 double total;
379 struct ctdb_statistics {
380 uint32_t num_clients;
381 uint32_t frozen;
382 uint32_t recovering;
383 uint32_t client_packets_sent;
384 uint32_t client_packets_recv;
385 uint32_t node_packets_sent;
386 uint32_t node_packets_recv;
387 uint32_t keepalive_packets_sent;
388 uint32_t keepalive_packets_recv;
389 struct {
390 uint32_t req_call;
391 uint32_t reply_call;
392 uint32_t req_dmaster;
393 uint32_t reply_dmaster;
394 uint32_t reply_error;
395 uint32_t req_message;
396 uint32_t req_control;
397 uint32_t reply_control;
398 } node;
399 struct {
400 uint32_t req_call;
401 uint32_t req_message;
402 uint32_t req_control;
403 } client;
404 struct {
405 uint32_t call;
406 uint32_t control;
407 uint32_t traverse;
408 } timeouts;
409 struct {
410 struct ctdb_latency_counter ctdbd;
411 struct ctdb_latency_counter recd;
412 } reclock;
413 struct {
414 uint32_t num_calls;
415 uint32_t num_current;
416 uint32_t num_pending;
417 uint32_t num_failed;
418 struct ctdb_latency_counter latency;
419 uint32_t buckets[MAX_COUNT_BUCKETS];
420 } locks;
421 uint32_t total_calls;
422 uint32_t pending_calls;
423 uint32_t childwrite_calls;
424 uint32_t pending_childwrite_calls;
425 uint32_t memory_used;
426 uint32_t __last_counter; /* hack */
427 uint32_t max_hop_count;
428 uint32_t hop_count_bucket[MAX_COUNT_BUCKETS];
429 struct ctdb_latency_counter call_latency;
430 struct ctdb_latency_counter childwrite_latency;
431 uint32_t num_recoveries;
432 struct timeval statistics_start_time;
433 struct timeval statistics_current_time;
434 uint32_t total_ro_delegations;
435 uint32_t total_ro_revokes;
438 #define INVALID_GENERATION 1
439 /* table that contains the mapping between a hash value and lmaster
441 struct ctdb_vnn_map {
442 uint32_t generation;
443 uint32_t size;
444 uint32_t *map;
447 struct ctdb_dbid {
448 uint32_t db_id;
449 #define CTDB_DB_FLAGS_PERSISTENT 0x01
450 #define CTDB_DB_FLAGS_READONLY 0x02
451 #define CTDB_DB_FLAGS_STICKY 0x04
452 uint8_t flags;
455 struct ctdb_dbid_map {
456 uint32_t num;
457 struct ctdb_dbid *dbs;
460 struct ctdb_pulldb {
461 uint32_t db_id;
462 #define CTDB_LMASTER_ANY 0xffffffff
463 uint32_t lmaster;
466 struct ctdb_pulldb_ext {
467 uint32_t db_id;
468 uint32_t lmaster;
469 uint64_t srvid;
472 #define CTDB_RECOVERY_NORMAL 0
473 #define CTDB_RECOVERY_ACTIVE 1
476 the extended header for records in the ltdb
478 struct ctdb_ltdb_header {
479 uint64_t rsn;
480 uint32_t dmaster;
481 uint32_t reserved1;
482 #define CTDB_REC_FLAG_DEFAULT 0x00000000
483 #define CTDB_REC_FLAG_MIGRATED_WITH_DATA 0x00010000
484 #define CTDB_REC_FLAG_VACUUM_MIGRATED 0x00020000
485 #define CTDB_REC_FLAG_AUTOMATIC 0x00040000
486 #define CTDB_REC_RO_HAVE_DELEGATIONS 0x01000000
487 #define CTDB_REC_RO_HAVE_READONLY 0x02000000
488 #define CTDB_REC_RO_REVOKING_READONLY 0x04000000
489 #define CTDB_REC_RO_REVOKE_COMPLETE 0x08000000
490 #define CTDB_REC_RO_FLAGS (CTDB_REC_RO_HAVE_DELEGATIONS|\
491 CTDB_REC_RO_HAVE_READONLY|\
492 CTDB_REC_RO_REVOKING_READONLY|\
493 CTDB_REC_RO_REVOKE_COMPLETE)
494 uint32_t flags;
497 struct ctdb_rec_data {
498 uint32_t reqid;
499 struct ctdb_ltdb_header *header;
500 TDB_DATA key, data;
503 struct ctdb_rec_buffer {
504 uint32_t db_id;
505 uint32_t count;
506 uint8_t *buf;
507 size_t buflen;
510 typedef int (*ctdb_rec_parser_func_t)(uint32_t reqid,
511 struct ctdb_ltdb_header *header,
512 TDB_DATA key, TDB_DATA data,
513 void *private_data);
515 struct ctdb_traverse_start {
516 uint32_t db_id;
517 uint32_t reqid;
518 uint64_t srvid;
521 struct ctdb_traverse_all {
522 uint32_t db_id;
523 uint32_t reqid;
524 uint32_t pnn;
525 uint32_t client_reqid;
526 uint64_t srvid;
529 struct ctdb_traverse_start_ext {
530 uint32_t db_id;
531 uint32_t reqid;
532 uint64_t srvid;
533 bool withemptyrecords;
536 struct ctdb_traverse_all_ext {
537 uint32_t db_id;
538 uint32_t reqid;
539 uint32_t pnn;
540 uint32_t client_reqid;
541 uint64_t srvid;
542 bool withemptyrecords;
545 typedef union {
546 struct sockaddr sa;
547 struct sockaddr_in ip;
548 struct sockaddr_in6 ip6;
549 } ctdb_sock_addr;
551 struct ctdb_connection {
552 ctdb_sock_addr src;
553 ctdb_sock_addr dst;
556 struct ctdb_tunable {
557 const char *name;
558 uint32_t value;
561 struct ctdb_var_list {
562 int count;
563 const char **var;
566 struct ctdb_node_flag_change {
567 uint32_t pnn;
568 uint32_t new_flags;
569 uint32_t old_flags;
572 /* all tunable variables go in here */
573 struct ctdb_tunable_list {
574 uint32_t max_redirect_count;
575 uint32_t seqnum_interval; /* unit is ms */
576 uint32_t control_timeout;
577 uint32_t traverse_timeout;
578 uint32_t keepalive_interval;
579 uint32_t keepalive_limit;
580 uint32_t recover_timeout;
581 uint32_t recover_interval;
582 uint32_t election_timeout;
583 uint32_t takeover_timeout;
584 uint32_t monitor_interval;
585 uint32_t tickle_update_interval;
586 uint32_t script_timeout;
587 uint32_t monitor_timeout_count; /* allow dodgy scripts to hang this many times in a row before we mark the node unhealthy */
588 uint32_t script_unhealthy_on_timeout; /* obsolete */
589 uint32_t recovery_grace_period;
590 uint32_t recovery_ban_period;
591 uint32_t database_hash_size;
592 uint32_t database_max_dead;
593 uint32_t rerecovery_timeout;
594 uint32_t enable_bans;
595 uint32_t deterministic_public_ips;
596 uint32_t reclock_ping_period;
597 uint32_t no_ip_failback;
598 uint32_t disable_ip_failover;
599 uint32_t verbose_memory_names;
600 uint32_t recd_ping_timeout;
601 uint32_t recd_ping_failcount;
602 uint32_t log_latency_ms;
603 uint32_t reclock_latency_ms;
604 uint32_t recovery_drop_all_ips;
605 uint32_t verify_recovery_lock;
606 uint32_t vacuum_interval;
607 uint32_t vacuum_max_run_time;
608 uint32_t repack_limit;
609 uint32_t vacuum_limit;
610 uint32_t max_queue_depth_drop_msg;
611 uint32_t allow_unhealthy_db_read;
612 uint32_t stat_history_interval;
613 uint32_t deferred_attach_timeout;
614 uint32_t vacuum_fast_path_count;
615 uint32_t lcp2_public_ip_assignment;
616 uint32_t allow_client_db_attach;
617 uint32_t recover_pdb_by_seqnum;
618 uint32_t deferred_rebalance_on_node_add;
619 uint32_t fetch_collapse;
620 uint32_t hopcount_make_sticky;
621 uint32_t sticky_duration;
622 uint32_t sticky_pindown;
623 uint32_t no_ip_takeover;
624 uint32_t db_record_count_warn;
625 uint32_t db_record_size_warn;
626 uint32_t db_size_warn;
627 uint32_t pulldb_preallocation_size;
628 uint32_t no_ip_host_on_all_disabled;
629 uint32_t samba3_hack;
630 uint32_t mutex_enabled;
631 uint32_t lock_processes_per_db;
632 uint32_t rec_buffer_size_limit;
633 uint32_t queue_buffer_size;
634 uint32_t ip_alloc_algorithm;
637 struct ctdb_tickle_list {
638 ctdb_sock_addr addr;
639 uint32_t num;
640 struct ctdb_connection *conn;
643 struct ctdb_addr_info {
644 ctdb_sock_addr addr;
645 uint32_t mask;
646 const char *iface;
649 struct ctdb_transdb {
650 uint32_t db_id;
651 uint32_t tid;
654 struct ctdb_uptime {
655 struct timeval current_time;
656 struct timeval ctdbd_start_time;
657 struct timeval last_recovery_started;
658 struct timeval last_recovery_finished;
661 struct ctdb_public_ip {
662 uint32_t pnn;
663 ctdb_sock_addr addr;
666 struct ctdb_public_ip_list {
667 uint32_t num;
668 struct ctdb_public_ip *ip;
672 * Node flags
674 #define NODE_FLAGS_DISCONNECTED 0x00000001 /* node isn't connected */
675 #define NODE_FLAGS_UNHEALTHY 0x00000002 /* monitoring says node is unhealthy */
676 #define NODE_FLAGS_PERMANENTLY_DISABLED 0x00000004 /* administrator has disabled node */
677 #define NODE_FLAGS_BANNED 0x00000008 /* recovery daemon has banned the node */
678 #define NODE_FLAGS_DELETED 0x00000010 /* this node has been deleted */
679 #define NODE_FLAGS_STOPPED 0x00000020 /* this node has been stopped */
680 #define NODE_FLAGS_DISABLED (NODE_FLAGS_UNHEALTHY|NODE_FLAGS_PERMANENTLY_DISABLED)
681 #define NODE_FLAGS_INACTIVE (NODE_FLAGS_DELETED|NODE_FLAGS_DISCONNECTED|NODE_FLAGS_BANNED|NODE_FLAGS_STOPPED)
684 * Node capabilities
686 #define CTDB_CAP_RECMASTER 0x00000001
687 #define CTDB_CAP_LMASTER 0x00000002
688 #define CTDB_CAP_LVS 0x00000004 /* obsolete */
689 #define CTDB_CAP_NATGW 0x00000008 /* obsolete */
692 * Node features
694 #define CTDB_CAP_PARALLEL_RECOVERY 0x00010000
695 #define CTDB_CAP_FRAGMENTED_CONTROLS 0x00020000
697 #define CTDB_CAP_FEATURES (CTDB_CAP_PARALLEL_RECOVERY | \
698 CTDB_CAP_FRAGMENTED_CONTROLS)
700 #define CTDB_CAP_DEFAULT (CTDB_CAP_RECMASTER | \
701 CTDB_CAP_LMASTER | \
702 CTDB_CAP_FEATURES)
704 struct ctdb_node_and_flags {
705 uint32_t pnn;
706 uint32_t flags;
707 ctdb_sock_addr addr;
710 struct ctdb_node_map {
711 uint32_t num;
712 struct ctdb_node_and_flags *node;
715 enum ctdb_event {
716 CTDB_EVENT_INIT, /* CTDB starting up: no args */
717 CTDB_EVENT_SETUP, /* CTDB starting up after transport is readdy: no args. */
718 CTDB_EVENT_STARTUP, /* CTDB starting up after initial recovery: no args. */
719 CTDB_EVENT_START_RECOVERY, /* CTDB recovery starting: no args. */
720 CTDB_EVENT_RECOVERED, /* CTDB recovery finished: no args. */
721 CTDB_EVENT_TAKE_IP, /* IP taken: interface, IP address, netmask bits. */
722 CTDB_EVENT_RELEASE_IP, /* IP released: interface, IP address, netmask bits. */
723 CTDB_EVENT_STOPPED, /* Deprecated, do not use. */
724 CTDB_EVENT_MONITOR, /* Please check if service is healthy: no args. */
725 CTDB_EVENT_STATUS, /* Deprecated, do not use. */
726 CTDB_EVENT_SHUTDOWN, /* CTDB shutting down: no args. */
727 CTDB_EVENT_RELOAD, /* Deprecated, do not use */
728 CTDB_EVENT_UPDATE_IP, /* IP updating: old interface, new interface, IP address, netmask bits. */
729 CTDB_EVENT_IPREALLOCATED, /* when a takeover_run() completes */
730 CTDB_EVENT_MAX
733 #define MAX_SCRIPT_NAME 31
734 #define MAX_SCRIPT_OUTPUT 511
736 struct ctdb_script {
737 char name[MAX_SCRIPT_NAME+1];
738 struct timeval start;
739 struct timeval finished;
740 int32_t status;
741 char output[MAX_SCRIPT_OUTPUT+1];
744 struct ctdb_script_list {
745 uint32_t num_scripts;
746 struct ctdb_script *script;
749 struct ctdb_ban_state {
750 uint32_t pnn;
751 uint32_t time;
754 struct ctdb_notify_data {
755 uint64_t srvid;
756 TDB_DATA data;
759 #ifdef IFNAMSIZ
760 #define CTDB_IFACE_SIZE IFNAMSIZ
761 #else
762 #define CTDB_IFACE_SIZE 16
763 #endif
765 struct ctdb_iface {
766 char name[CTDB_IFACE_SIZE+2];
767 uint16_t link_state;
768 uint32_t references;
771 struct ctdb_iface_list {
772 uint32_t num;
773 struct ctdb_iface *iface;
776 struct ctdb_public_ip_info {
777 struct ctdb_public_ip ip;
778 uint32_t active_idx;
779 struct ctdb_iface_list *ifaces;
782 struct ctdb_statistics_list {
783 int num;
784 struct ctdb_statistics *stats;
787 struct ctdb_key_data {
788 uint32_t db_id;
789 struct ctdb_ltdb_header header;
790 TDB_DATA key;
793 struct ctdb_uint8_array {
794 int num;
795 uint8_t *val;
798 struct ctdb_uint64_array {
799 int num;
800 uint64_t *val;
803 struct ctdb_db_statistics {
804 struct {
805 uint32_t num_calls;
806 uint32_t num_current;
807 uint32_t num_pending;
808 uint32_t num_failed;
809 struct ctdb_latency_counter latency;
810 uint32_t buckets[MAX_COUNT_BUCKETS];
811 } locks;
812 struct {
813 struct ctdb_latency_counter latency;
814 } vacuum;
815 uint32_t db_ro_delegations;
816 uint32_t db_ro_revokes;
817 uint32_t hop_count_bucket[MAX_COUNT_BUCKETS];
818 uint32_t num_hot_keys;
819 struct {
820 uint32_t count;
821 TDB_DATA key;
822 } hot_keys[MAX_HOT_KEYS];
825 enum ctdb_runstate {
826 CTDB_RUNSTATE_UNKNOWN,
827 CTDB_RUNSTATE_INIT,
828 CTDB_RUNSTATE_SETUP,
829 CTDB_RUNSTATE_FIRST_RECOVERY,
830 CTDB_RUNSTATE_STARTUP,
831 CTDB_RUNSTATE_RUNNING,
832 CTDB_RUNSTATE_SHUTDOWN,
835 struct ctdb_req_control_data {
836 uint32_t opcode;
837 union {
838 pid_t pid;
839 uint32_t db_id;
840 struct ctdb_vnn_map *vnnmap;
841 uint32_t loglevel;
842 struct ctdb_pulldb *pulldb;
843 struct ctdb_pulldb_ext *pulldb_ext;
844 struct ctdb_rec_buffer *recbuf;
845 uint32_t recmode;
846 const char *db_name;
847 struct ctdb_traverse_start *traverse_start;
848 struct ctdb_traverse_all *traverse_all;
849 struct ctdb_rec_data *rec_data;
850 uint32_t recmaster;
851 struct ctdb_connection *conn;
852 struct ctdb_tunable *tunable;
853 const char *tun_var;
854 struct ctdb_node_flag_change *flag_change;
855 ctdb_sock_addr *addr;
856 struct ctdb_tickle_list *tickles;
857 struct ctdb_client_id *cid;
858 struct ctdb_addr_info *addr_info;
859 struct ctdb_transdb *transdb;
860 struct ctdb_public_ip *pubip;
861 enum ctdb_event event;
862 double reclock_latency;
863 uint32_t role;
864 struct ctdb_ban_state *ban_state;
865 struct ctdb_notify_data *notify;
866 uint64_t srvid;
867 struct ctdb_iface *iface;
868 struct ctdb_key_data *key;
869 struct ctdb_uint64_array *u64_array;
870 struct ctdb_traverse_start_ext *traverse_start_ext;
871 struct ctdb_traverse_all_ext *traverse_all_ext;
872 } data;
875 struct ctdb_reply_control_data {
876 uint32_t opcode;
877 union {
878 struct ctdb_statistics *stats;
879 const char *db_path;
880 struct ctdb_vnn_map *vnnmap;
881 uint32_t loglevel;
882 struct ctdb_dbid_map *dbmap;
883 struct ctdb_rec_buffer *recbuf;
884 uint32_t db_id;
885 const char *db_name;
886 const char *mem_str;
887 uint32_t tun_value;
888 struct ctdb_var_list *tun_var_list;
889 struct ctdb_tunable_list *tun_list;
890 struct ctdb_tickle_list *tickles;
891 struct ctdb_client_id_map *cid_map;
892 struct ctdb_uptime *uptime;
893 uint32_t caps;
894 struct ctdb_public_ip_list *pubip_list;
895 struct ctdb_node_map *nodemap;
896 const char *reclock_file;
897 struct ctdb_ban_state *ban_state;
898 uint64_t seqnum;
899 const char *reason;
900 struct ctdb_public_ip_info *ipinfo;
901 struct ctdb_iface_list *iface_list;
902 struct ctdb_statistics_list *stats_list;
903 struct ctdb_uint8_array *u8_array;
904 struct ctdb_db_statistics *dbstats;
905 enum ctdb_runstate runstate;
906 uint32_t num_records;
907 } data;
910 struct ctdb_req_control {
911 uint32_t opcode;
912 uint32_t pad;
913 uint64_t srvid;
914 uint32_t client_id;
915 #define CTDB_CTRL_FLAG_NOREPLY 1
916 #define CTDB_CTRL_FLAG_OPCODE_SPECIFIC 0xFFFF0000
917 /* Ugly overloading of this field... */
918 #define CTDB_PUBLIC_IP_FLAGS_ONLY_AVAILABLE 0x00010000
919 uint32_t flags;
920 struct ctdb_req_control_data rdata;
923 struct ctdb_reply_control {
924 int32_t status;
925 const char *errmsg;
926 struct ctdb_reply_control_data rdata;
929 struct ctdb_election_message {
930 uint32_t num_connected;
931 struct timeval priority_time;
932 uint32_t pnn;
933 uint32_t node_flags;
936 struct ctdb_srvid_message {
937 uint32_t pnn;
938 uint64_t srvid;
941 struct ctdb_disable_message {
942 uint32_t pnn;
943 uint64_t srvid;
944 uint32_t timeout;
947 union ctdb_message_data {
948 /* SRVID_ELECTION */
949 struct ctdb_election_message *election;
950 /* SRVID_RELEASE_IP, SRVID_TAKE_IP */
951 const char *ipaddr;
952 /* SRVID_SET_NODE_FLAGS, SERVID_PUSH_NODE_FLAGS */
953 struct ctdb_node_flag_change *flag_change;
954 /* SRVID_RECD_UPDATE_IP */
955 struct ctdb_public_ip *pubip;
956 /* SRVID_VACUUM_FETCH */
957 struct ctdb_rec_buffer *recbuf;
958 /* SRVID_DETACH_DATABASE */
959 uint32_t db_id;
960 /* SRVID_MEM_DUMP, SRVID_TAKEOVER_RUN */
961 struct ctdb_srvid_message *msg;
962 /* SRVID_BANNING, SRVID_REBALANCE_NODE */
963 uint32_t pnn;
964 /* SRVID_DISABLE_TAKEOVER_RUNS, SRVID_DISABLE_RECOVERIES */
965 struct ctdb_disable_message *disable;
966 /* SRVID_DISABLE_IP_CHECK */
967 uint32_t timeout;
968 /* Other */
969 TDB_DATA data;
972 struct ctdb_req_message {
973 uint64_t srvid;
974 union ctdb_message_data data;
977 struct ctdb_req_message_data {
978 uint64_t srvid;
979 TDB_DATA data;
982 /* This is equivalent to server_id */
983 struct ctdb_server_id {
984 uint64_t pid;
985 uint32_t task_id;
986 uint32_t vnn;
987 uint64_t unique_id;
990 enum ctdb_g_lock_type {
991 CTDB_G_LOCK_READ = 0,
992 CTDB_G_LOCK_WRITE = 1,
995 struct ctdb_g_lock {
996 enum ctdb_g_lock_type type;
997 struct ctdb_server_id sid;
1000 struct ctdb_g_lock_list {
1001 unsigned int num;
1002 struct ctdb_g_lock *lock;
1006 * Eventd protocol
1009 enum ctdb_event_command {
1010 CTDB_EVENT_COMMAND_RUN = 1,
1011 CTDB_EVENT_COMMAND_STATUS = 2,
1012 CTDB_EVENT_COMMAND_SCRIPT_LIST = 3,
1013 CTDB_EVENT_COMMAND_SCRIPT_ENABLE = 4,
1014 CTDB_EVENT_COMMAND_SCRIPT_DISABLE = 5,
1017 enum ctdb_event_status_state {
1018 CTDB_EVENT_LAST_RUN = 1,
1019 CTDB_EVENT_LAST_PASS = 2,
1020 CTDB_EVENT_LAST_FAIL = 3,
1023 struct ctdb_event_request_run {
1024 enum ctdb_event event;
1025 uint32_t timeout;
1026 const char *arg_str;
1029 struct ctdb_event_request_status {
1030 enum ctdb_event event;
1031 enum ctdb_event_status_state state;
1034 struct ctdb_event_request_script_enable {
1035 const char *script_name;
1038 struct ctdb_event_request_script_disable {
1039 const char *script_name;
1042 struct ctdb_event_request_data {
1043 enum ctdb_event_command command;
1044 union {
1045 struct ctdb_event_request_run *run;
1046 struct ctdb_event_request_status *status;
1047 struct ctdb_event_request_script_enable *script_enable;
1048 struct ctdb_event_request_script_disable *script_disable;
1049 } data;
1052 struct ctdb_event_reply_status {
1053 int status;
1054 struct ctdb_script_list *script_list;
1057 struct ctdb_event_reply_script_list {
1058 struct ctdb_script_list *script_list;
1061 struct ctdb_event_reply_data {
1062 enum ctdb_event_command command;
1063 int32_t result;
1064 union {
1065 struct ctdb_event_reply_status *status;
1066 struct ctdb_event_reply_script_list *script_list;
1067 } data;
1070 struct ctdb_event_header {
1071 uint32_t length;
1072 uint32_t reqid;
1075 struct ctdb_event_request {
1076 struct ctdb_event_header header;
1077 struct ctdb_event_request_data rdata;
1080 struct ctdb_event_reply {
1081 struct ctdb_event_header header;
1082 struct ctdb_event_reply_data rdata;
1085 #endif /* __CTDB_PROTOCOL_H__ */