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