90af21f574d09f20f9a6a1899311614765cc942a
[ctdb.git] / include / ctdb_protocol.h
1 /*
2    ctdb database library
3
4    Copyright (C) Andrew Tridgell  2006
5
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.
10
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.
15
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/>.
18 */
19
20 #ifndef _CTDB_PROTOCOL_H
21 #define _CTDB_PROTOCOL_H
22
23 /* location of daemon socket */
24 #define CTDB_PATH       "/tmp/ctdb.socket"
25
26 /* default ctdb port number */
27 #define CTDB_PORT 4379
28
29 /* we must align packets to ensure ctdb works on all architectures (eg. sparc) */
30 #define CTDB_DS_ALIGNMENT 8
31
32
33 #define CTDB_NULL_FUNC      0xFF000001
34 #define CTDB_FETCH_FUNC     0xFF000002
35
36
37 struct ctdb_call {
38         int call_id;
39         TDB_DATA key;
40         TDB_DATA call_data;
41         TDB_DATA reply_data;
42         uint32_t status;
43 #define CTDB_IMMEDIATE_MIGRATION        0x00000001
44 #define CTDB_CALL_FLAG_VACUUM_MIGRATION         0x00000002
45         uint32_t flags;
46 };
47
48 /*
49   structure passed to a ctdb call backend function
50 */
51 struct ctdb_call_info {
52         TDB_DATA key;          /* record key */
53         TDB_DATA record_data;  /* current data in the record */
54         TDB_DATA *new_data;    /* optionally updated record data */
55         TDB_DATA *call_data;   /* optionally passed from caller */
56         TDB_DATA *reply_data;  /* optionally returned by function */
57         uint32_t status;       /* optional reply status - defaults to zero */
58 };
59
60 #define CTDB_ERR_INVALID 1
61 #define CTDB_ERR_NOMEM 2
62
63 /*
64   ctdb flags
65 */
66 #define CTDB_FLAG_TORTURE      (1<<1)
67
68 /*
69    a message handler ID meaning "give me all messages"
70  */
71 #define CTDB_SRVID_ALL (~(uint64_t)0)
72
73 /*
74   srvid type : RECOVERY
75 */
76 #define CTDB_SRVID_RECOVERY     0xF100000000000000LL
77
78 /*
79    a message handler ID meaning that the cluster has been reconfigured
80  */
81 #define CTDB_SRVID_RECONFIGURE 0xF200000000000000LL
82
83 /*
84    a message handler ID meaning that an IP address has been released
85  */
86 #define CTDB_SRVID_RELEASE_IP 0xF300000000000000LL
87
88 /*
89    a message handler ID meaning that an IP address has been taken
90  */
91 #define CTDB_SRVID_TAKE_IP 0xF301000000000000LL
92
93 /*
94    a message ID to set the node flags in the recovery daemon
95  */
96 #define CTDB_SRVID_SET_NODE_FLAGS 0xF400000000000000LL
97
98 /*
99    a message ID to ask the recovery daemon to update the expected node
100    assignment for a public ip
101  */
102 #define CTDB_SRVID_RECD_UPDATE_IP 0xF500000000000000LL
103
104 /*
105   a message to tell the recovery daemon to fetch a set of records
106  */
107 #define CTDB_SRVID_VACUUM_FETCH 0xF700000000000000LL
108
109 /*
110   a message to tell the recovery daemon to write a talloc memdump
111   to the log
112  */
113 #define CTDB_SRVID_MEM_DUMP 0xF800000000000000LL
114
115 /*
116    a message ID to get the recovery daemon to push the node flags out
117  */
118 #define CTDB_SRVID_PUSH_NODE_FLAGS 0xF900000000000000LL
119
120 /*
121    a message ID to get the recovery daemon to reload the nodes file
122  */
123 #define CTDB_SRVID_RELOAD_NODES 0xFA00000000000000LL
124
125 /*
126    a message ID to get the recovery daemon to perform a takeover run
127  */
128 #define CTDB_SRVID_TAKEOVER_RUN 0xFB00000000000000LL
129
130 /* A message id to ask the recovery daemon to temporarily disable the
131    public ip checks
132 */
133 #define CTDB_SRVID_DISABLE_IP_CHECK  0xFC00000000000000LL
134
135 /* A dummy port used for sending back ipreallocate resposnes to the main
136    daemon
137 */
138 #define CTDB_SRVID_TAKEOVER_RUN_RESPONSE  0xFD00000000000000LL
139
140 /* A range of ports reserved for samba (top 32 bits)
141  * All ports matching the 32 top bits are reserved for exclusive use by
142  * CIFS server
143  */
144 #define CTDB_SRVID_SAMBA_NOTIFY  0xFE00000000000000LL
145 #define CTDB_SRVID_SAMBA_RANGE   0xFE00000000000000LL
146
147 /* A range of ports reserved for a CTDB NFS server (top 32 bits)
148  * All ports matching the 32 top bits are reserved for exclusive use by
149  * NFS server
150  */
151 #define CTDB_SRVID_NFSD_RANGE  0xFE01000000000000LL
152
153 /* A range of ports reserved for a CTDB ISCSI server (top 32 bits)
154  * All ports matching the 32 top bits are reserved for exclusive use by
155  * ISCSI server
156  */
157 #define CTDB_SRVID_ISCSID_RANGE  0xFE02000000000000LL
158
159 /* A range of ports reserved for testing (top 32 bits)
160  * All ports matching the 32 top bits are reserved for exclusive use by
161  * test applications
162  */
163 #define CTDB_SRVID_TEST_RANGE  0xFE03000000000000LL
164
165 /* Range of ports reserved for traversals */
166 #define CTDB_SRVID_TRAVERSE_RANGE  0xFE04000000000000LL
167
168 /* used on the domain socket, send a pdu to the local daemon */
169 #define CTDB_CURRENT_NODE     0xF0000001
170 /* send a broadcast to all nodes in the cluster, active or not */
171 #define CTDB_BROADCAST_ALL    0xF0000002
172 /* send a broadcast to all nodes in the current vnn map */
173 #define CTDB_BROADCAST_VNNMAP 0xF0000003
174 /* send a broadcast to all connected nodes */
175 #define CTDB_BROADCAST_CONNECTED 0xF0000004
176
177 /* the key used for transaction locking on persistent databases */
178 #define CTDB_TRANSACTION_LOCK_KEY "__transaction_lock__"
179
180 /* the key used to store persistent db sequence number */
181 #define CTDB_DB_SEQNUM_KEY "__db_sequence_number__"
182
183 #define MONITOR_SCRIPT_OK      0
184 #define MONITOR_SCRIPT_TIMEOUT 1
185
186 #define MAX_SCRIPT_NAME 31
187 #define MAX_SCRIPT_OUTPUT 511
188 struct ctdb_script_wire {
189         char name[MAX_SCRIPT_NAME+1];
190         struct timeval start;
191         struct timeval finished;
192         int32_t status;
193         char output[MAX_SCRIPT_OUTPUT+1];
194 };
195
196 struct ctdb_scripts_wire {
197         uint32_t num_scripts;
198         struct ctdb_script_wire scripts[1];
199 };
200
201 /* different calls to event scripts. */
202 enum ctdb_eventscript_call {
203         CTDB_EVENT_INIT,                /* CTDB starting up: no args */
204         CTDB_EVENT_SETUP,               /* CTDB starting up after transport is readdy: no args. */
205         CTDB_EVENT_STARTUP,             /* CTDB starting up after initial recovery: no args. */
206         CTDB_EVENT_START_RECOVERY,      /* CTDB recovery starting: no args. */
207         CTDB_EVENT_RECOVERED,           /* CTDB recovery finished: no args. */
208         CTDB_EVENT_TAKE_IP,             /* IP taken: interface, IP address, netmask bits. */
209         CTDB_EVENT_RELEASE_IP,          /* IP released: interface, IP address, netmask bits. */
210         CTDB_EVENT_STOPPED,             /* This node is stopped: no args. */
211         CTDB_EVENT_MONITOR,             /* Please check if service is healthy: no args. */
212         CTDB_EVENT_STATUS,              /* Report service status: no args. */
213         CTDB_EVENT_SHUTDOWN,            /* CTDB shutting down: no args. */
214         CTDB_EVENT_RELOAD,              /* magic */
215         CTDB_EVENT_UPDATE_IP,           /* IP updating: old interface, new interface, IP address, netmask bits. */
216         CTDB_EVENT_IPREALLOCATED,       /* when a takeover_run() completes */
217         CTDB_EVENT_MAX
218 };
219
220 /* Mapping from enum to names. */
221 extern const char *ctdb_eventscript_call_names[];
222
223 /*
224   operation IDs
225 */
226 enum ctdb_operation {
227         CTDB_REQ_CALL           = 0,
228         CTDB_REPLY_CALL         = 1,
229         CTDB_REQ_DMASTER        = 2,
230         CTDB_REPLY_DMASTER      = 3,
231         CTDB_REPLY_ERROR        = 4,
232         CTDB_REQ_MESSAGE        = 5,
233         /* #6 removed */
234         CTDB_REQ_CONTROL        = 7,
235         CTDB_REPLY_CONTROL      = 8,
236         CTDB_REQ_KEEPALIVE      = 9,
237 };
238
239 #define CTDB_MAGIC 0x43544442 /* CTDB */
240 #define CTDB_VERSION 1
241
242 enum ctdb_controls {CTDB_CONTROL_PROCESS_EXISTS          = 0,
243                     CTDB_CONTROL_STATISTICS              = 1,
244                     /* #2 removed */
245                     CTDB_CONTROL_PING                    = 3,
246                     CTDB_CONTROL_GETDBPATH               = 4,
247                     CTDB_CONTROL_GETVNNMAP               = 5,
248                     CTDB_CONTROL_SETVNNMAP               = 6,
249                     CTDB_CONTROL_GET_DEBUG               = 7,
250                     CTDB_CONTROL_SET_DEBUG               = 8,
251                     CTDB_CONTROL_GET_DBMAP               = 9,
252                     CTDB_CONTROL_GET_NODEMAPv4           = 10, /* obsolete */
253                     CTDB_CONTROL_SET_DMASTER             = 11,
254                     /* #12 removed */
255                     CTDB_CONTROL_PULL_DB                 = 13,
256                     CTDB_CONTROL_PUSH_DB                 = 14,
257                     CTDB_CONTROL_GET_RECMODE             = 15,
258                     CTDB_CONTROL_SET_RECMODE             = 16,
259                     CTDB_CONTROL_STATISTICS_RESET        = 17,
260                     CTDB_CONTROL_DB_ATTACH               = 18,
261                     CTDB_CONTROL_SET_CALL                = 19,
262                     CTDB_CONTROL_TRAVERSE_START          = 20,
263                     CTDB_CONTROL_TRAVERSE_ALL            = 21,
264                     CTDB_CONTROL_TRAVERSE_DATA           = 22,
265                     CTDB_CONTROL_REGISTER_SRVID          = 23,
266                     CTDB_CONTROL_DEREGISTER_SRVID        = 24,
267                     CTDB_CONTROL_GET_DBNAME              = 25,
268                     CTDB_CONTROL_ENABLE_SEQNUM           = 26,
269                     CTDB_CONTROL_UPDATE_SEQNUM           = 27,
270                     /* #28 removed */
271                     CTDB_CONTROL_DUMP_MEMORY             = 29,
272                     CTDB_CONTROL_GET_PID                 = 30,
273                     CTDB_CONTROL_GET_RECMASTER           = 31,
274                     CTDB_CONTROL_SET_RECMASTER           = 32,
275                     CTDB_CONTROL_FREEZE                  = 33,
276                     CTDB_CONTROL_THAW                    = 34,
277                     CTDB_CONTROL_GET_PNN                 = 35,
278                     CTDB_CONTROL_SHUTDOWN                = 36,
279                     CTDB_CONTROL_GET_MONMODE             = 37,
280                     /* #38 removed */
281                     /* #39 removed */
282                     /* #40 removed */
283                     /* #41 removed */
284                     CTDB_CONTROL_TAKEOVER_IPv4           = 42, /* obsolete */
285                     CTDB_CONTROL_RELEASE_IPv4            = 43, /* obsolete */
286                     CTDB_CONTROL_TCP_CLIENT              = 44,
287                     CTDB_CONTROL_TCP_ADD                 = 45,
288                     CTDB_CONTROL_TCP_REMOVE              = 46,
289                     CTDB_CONTROL_STARTUP                 = 47,
290                     CTDB_CONTROL_SET_TUNABLE             = 48,
291                     CTDB_CONTROL_GET_TUNABLE             = 49,
292                     CTDB_CONTROL_LIST_TUNABLES           = 50,
293                     CTDB_CONTROL_GET_PUBLIC_IPSv4        = 51, /* obsolete */
294                     CTDB_CONTROL_MODIFY_FLAGS            = 52,
295                     CTDB_CONTROL_GET_ALL_TUNABLES        = 53,
296                     CTDB_CONTROL_KILL_TCP                = 54,
297                     CTDB_CONTROL_GET_TCP_TICKLE_LIST     = 55,
298                     CTDB_CONTROL_SET_TCP_TICKLE_LIST     = 56,
299                     CTDB_CONTROL_REGISTER_SERVER_ID      = 57,
300                     CTDB_CONTROL_UNREGISTER_SERVER_ID    = 58,
301                     CTDB_CONTROL_CHECK_SERVER_ID         = 59,
302                     CTDB_CONTROL_GET_SERVER_ID_LIST      = 60,
303                     CTDB_CONTROL_DB_ATTACH_PERSISTENT    = 61,
304                     CTDB_CONTROL_PERSISTENT_STORE        = 62,
305                     CTDB_CONTROL_UPDATE_RECORD           = 63,
306                     CTDB_CONTROL_SEND_GRATIOUS_ARP       = 64,
307                     CTDB_CONTROL_TRANSACTION_START       = 65,
308                     CTDB_CONTROL_TRANSACTION_COMMIT      = 66,
309                     CTDB_CONTROL_WIPE_DATABASE           = 67,
310                     /* #68 removed */
311                     CTDB_CONTROL_UPTIME                  = 69,
312                     CTDB_CONTROL_START_RECOVERY          = 70,
313                     CTDB_CONTROL_END_RECOVERY            = 71,
314                     CTDB_CONTROL_RELOAD_NODES_FILE       = 72,
315                     /* #73 removed */
316                     CTDB_CONTROL_TRY_DELETE_RECORDS      = 74,
317                     CTDB_CONTROL_ENABLE_MONITOR          = 75,
318                     CTDB_CONTROL_DISABLE_MONITOR         = 76,
319                     CTDB_CONTROL_ADD_PUBLIC_IP           = 77,
320                     CTDB_CONTROL_DEL_PUBLIC_IP           = 78,
321                     CTDB_CONTROL_RUN_EVENTSCRIPTS        = 79,
322                     CTDB_CONTROL_GET_CAPABILITIES        = 80,
323                     CTDB_CONTROL_START_PERSISTENT_UPDATE = 81,
324                     CTDB_CONTROL_CANCEL_PERSISTENT_UPDATE= 82,
325                     CTDB_CONTROL_TRANS2_COMMIT           = 83,
326                     CTDB_CONTROL_TRANS2_FINISHED         = 84,
327                     CTDB_CONTROL_TRANS2_ERROR            = 85,
328                     CTDB_CONTROL_TRANS2_COMMIT_RETRY     = 86,
329                     CTDB_CONTROL_RECD_PING               = 87,
330                     CTDB_CONTROL_RELEASE_IP              = 88,
331                     CTDB_CONTROL_TAKEOVER_IP             = 89,
332                     CTDB_CONTROL_GET_PUBLIC_IPS          = 90,
333                     CTDB_CONTROL_GET_NODEMAP             = 91,
334                     CTDB_CONTROL_GET_EVENT_SCRIPT_STATUS = 96,
335                     CTDB_CONTROL_TRAVERSE_KILL           = 97,
336                     CTDB_CONTROL_RECD_RECLOCK_LATENCY    = 98,
337                     CTDB_CONTROL_GET_RECLOCK_FILE        = 99,
338                     CTDB_CONTROL_SET_RECLOCK_FILE        = 100,
339                     CTDB_CONTROL_STOP_NODE               = 101,
340                     CTDB_CONTROL_CONTINUE_NODE           = 102,
341                     CTDB_CONTROL_SET_NATGWSTATE          = 103,
342                     CTDB_CONTROL_SET_LMASTERROLE         = 104,
343                     CTDB_CONTROL_SET_RECMASTERROLE       = 105,
344                     CTDB_CONTROL_ENABLE_SCRIPT           = 107,
345                     CTDB_CONTROL_DISABLE_SCRIPT          = 108,
346                     CTDB_CONTROL_SET_BAN_STATE           = 109,
347                     CTDB_CONTROL_GET_BAN_STATE           = 110,
348                     CTDB_CONTROL_SET_DB_PRIORITY         = 111,
349                     CTDB_CONTROL_GET_DB_PRIORITY         = 112,
350                     CTDB_CONTROL_TRANSACTION_CANCEL      = 113,
351                     CTDB_CONTROL_REGISTER_NOTIFY         = 114,
352                     CTDB_CONTROL_DEREGISTER_NOTIFY       = 115,
353                     CTDB_CONTROL_TRANS2_ACTIVE           = 116,
354                     CTDB_CONTROL_GET_LOG                 = 117,
355                     CTDB_CONTROL_CLEAR_LOG               = 118,
356                     CTDB_CONTROL_TRANS3_COMMIT           = 119,
357                     CTDB_CONTROL_GET_DB_SEQNUM           = 120,
358                     CTDB_CONTROL_DB_SET_HEALTHY          = 121,
359                     CTDB_CONTROL_DB_GET_HEALTH           = 122,
360                     CTDB_CONTROL_GET_PUBLIC_IP_INFO      = 123,
361                     CTDB_CONTROL_GET_IFACES              = 124,
362                     CTDB_CONTROL_SET_IFACE_LINK_STATE    = 125,
363                     CTDB_CONTROL_TCP_ADD_DELAYED_UPDATE  = 126,
364                     CTDB_CONTROL_GET_STAT_HISTORY        = 127,
365                     CTDB_CONTROL_SCHEDULE_FOR_DELETION   = 128,
366                     CTDB_CONTROL_CHECK_SRVIDS            = 130,
367 };
368
369 /*
370   packet structures
371 */
372 struct ctdb_req_header {
373         uint32_t length;
374         uint32_t ctdb_magic;
375         uint32_t ctdb_version;
376         uint32_t generation;
377         uint32_t operation;
378         uint32_t destnode;
379         uint32_t srcnode;
380         uint32_t reqid;
381 };
382
383 struct ctdb_req_call {
384         struct ctdb_req_header hdr;
385         uint32_t flags;
386         uint32_t db_id;
387         uint32_t callid;
388         uint32_t hopcount;
389         uint32_t keylen;
390         uint32_t calldatalen;
391         uint8_t data[1]; /* key[] followed by calldata[] */
392 };
393
394 struct ctdb_reply_call {
395         struct ctdb_req_header hdr;
396         uint32_t status;
397         uint32_t datalen;
398         uint8_t  data[1];
399 };
400
401 struct ctdb_reply_error {
402         struct ctdb_req_header hdr;
403         uint32_t status;
404         uint32_t msglen;
405         uint8_t  msg[1];
406 };
407
408 struct ctdb_req_dmaster {
409         struct ctdb_req_header hdr;
410         uint32_t db_id;
411         uint64_t rsn;
412         uint32_t dmaster;
413         uint32_t keylen;
414         uint32_t datalen;
415         uint8_t  data[1];
416 };
417
418 struct ctdb_reply_dmaster {
419         struct ctdb_req_header hdr;
420         uint32_t db_id;
421         uint64_t rsn;
422         uint32_t keylen;
423         uint32_t datalen;
424         uint8_t  data[1];
425 };
426
427 struct ctdb_req_message {
428         struct ctdb_req_header hdr;
429         uint64_t srvid;
430         uint32_t datalen;
431         uint8_t data[1];
432 };
433
434 struct ctdb_req_getdbpath {
435         struct ctdb_req_header hdr;
436         uint32_t db_id;
437 };
438
439 struct ctdb_reply_getdbpath {
440         struct ctdb_req_header hdr;
441         uint32_t datalen;
442         uint8_t data[1];
443 };
444
445 struct ctdb_req_control {
446         struct ctdb_req_header hdr;
447         uint32_t opcode;
448         uint32_t pad;
449         uint64_t srvid;
450         uint32_t client_id;
451 #define CTDB_CTRL_FLAG_NOREPLY   1
452 #define CTDB_CTRL_FLAG_OPCODE_SPECIFIC   0xFFFF0000
453         uint32_t flags;
454         uint32_t datalen;
455         uint8_t data[1];
456 };
457
458 struct ctdb_reply_control {
459         struct ctdb_req_header hdr;
460         int32_t  status;
461         uint32_t datalen;
462         uint32_t errorlen;
463         uint8_t data[1];
464 };
465
466 struct ctdb_req_keepalive {
467         struct ctdb_req_header hdr;
468 };
469
470
471 /* types of failures possible from TRANS2_COMMIT */
472 enum ctdb_trans2_commit_error {
473         CTDB_TRANS2_COMMIT_SUCCESS=0, /* all nodes committed successfully */
474         CTDB_TRANS2_COMMIT_TIMEOUT=1, /* at least one node timed out */
475         CTDB_TRANS2_COMMIT_ALLFAIL=2, /* all nodes failed the commit */
476         CTDB_TRANS2_COMMIT_SOMEFAIL=3 /* some nodes failed the commit, some allowed it */
477 };
478
479 /*
480   the extended header for records in the ltdb
481 */
482 struct ctdb_ltdb_header {
483         uint64_t rsn;
484         uint32_t dmaster;
485         uint16_t laccessor;
486         uint16_t lacount;
487 #define CTDB_REC_FLAG_DEFAULT                   0x00000000
488 #define CTDB_REC_FLAG_MIGRATED_WITH_DATA        0x00010000
489 #define CTDB_REC_FLAG_VACUUM_MIGRATED           0x00020000
490 #define CTDB_REC_FLAG_AUTOMATIC                 0x00040000
491         uint32_t flags;
492 };
493
494
495 /*
496   definitions for different socket structures
497  */
498 typedef struct sockaddr_in ctdb_addr_in;
499 typedef struct sockaddr_in6 ctdb_addr_in6;
500 typedef union {
501         struct sockaddr sa;
502         ctdb_addr_in    ip;
503         ctdb_addr_in6   ip6;
504 } ctdb_sock_addr;
505
506 /*
507    A structure describing a single node, its flags and its address
508 */
509 struct ctdb_node_and_flags {
510         uint32_t pnn;
511         uint32_t flags;
512         ctdb_sock_addr addr;
513 };
514
515
516 /*
517    Structure used for a nodemap. 
518    The nodemap is the structure containing a list of all nodes
519    known to the cluster and their associated flags.
520 */
521 struct ctdb_node_map {
522         uint32_t num;
523         struct ctdb_node_and_flags nodes[1];
524 };
525
526 /*
527  * Node flags
528  */
529 #define NODE_FLAGS_DISCONNECTED         0x00000001 /* node isn't connected */
530 #define NODE_FLAGS_UNHEALTHY            0x00000002 /* monitoring says node is unhealthy */
531 #define NODE_FLAGS_PERMANENTLY_DISABLED 0x00000004 /* administrator has disabled node */
532 #define NODE_FLAGS_BANNED               0x00000008 /* recovery daemon has banned the node */
533 #define NODE_FLAGS_DELETED              0x00000010 /* this node has been deleted */
534 #define NODE_FLAGS_STOPPED              0x00000020 /* this node has been stopped */
535 #define NODE_FLAGS_DISABLED             (NODE_FLAGS_UNHEALTHY|NODE_FLAGS_PERMANENTLY_DISABLED)
536 #define NODE_FLAGS_INACTIVE             (NODE_FLAGS_DELETED|NODE_FLAGS_DISCONNECTED|NODE_FLAGS_BANNED|NODE_FLAGS_STOPPED)
537
538
539 struct ctdb_public_ip {
540         uint32_t pnn;
541         ctdb_sock_addr addr;
542 };
543
544 struct ctdb_all_public_ips {
545         uint32_t num;
546         struct ctdb_public_ip ips[1];
547 };
548
549
550 struct latency_counter {
551         int num;
552         double min;
553         double max;
554         double total;
555 };
556
557 /*
558   structure used to pass record data between the child and parent
559  */
560 struct ctdb_rec_data {
561         uint32_t length;
562         uint32_t reqid;
563         uint32_t keylen;
564         uint32_t datalen;
565         uint8_t  data[1];
566 };
567
568 struct ctdb_traverse_start {
569         uint32_t db_id;
570         uint32_t reqid;
571         uint64_t srvid;
572 };
573
574 /*
575   ctdb statistics information
576  */
577 struct ctdb_statistics {
578         uint32_t num_clients;
579         uint32_t frozen;
580         uint32_t recovering;
581         uint32_t client_packets_sent;
582         uint32_t client_packets_recv;
583         uint32_t node_packets_sent;
584         uint32_t node_packets_recv;
585         uint32_t keepalive_packets_sent;
586         uint32_t keepalive_packets_recv;
587         struct {
588                 uint32_t req_call;
589                 uint32_t reply_call;
590                 uint32_t req_dmaster;
591                 uint32_t reply_dmaster;
592                 uint32_t reply_error;
593                 uint32_t req_message;
594                 uint32_t req_control;
595                 uint32_t reply_control;
596         } node;
597         struct {
598                 uint32_t req_call;
599                 uint32_t req_message;
600                 uint32_t req_control;
601         } client;
602         struct {
603                 uint32_t call;
604                 uint32_t control;
605                 uint32_t traverse;
606         } timeouts;
607         struct {
608                 struct latency_counter ctdbd;
609                 struct latency_counter recd;
610         } reclock;
611         uint32_t total_calls;
612         uint32_t pending_calls;
613         uint32_t lockwait_calls;
614         uint32_t pending_lockwait_calls;
615         uint32_t childwrite_calls;
616         uint32_t pending_childwrite_calls;
617         uint32_t memory_used;
618         uint32_t __last_counter; /* hack for control_statistics_all */
619         uint32_t max_hop_count;
620 #define MAX_HOP_COUNT_BUCKETS 16
621         uint32_t hop_count_bucket[MAX_HOP_COUNT_BUCKETS];
622         struct latency_counter call_latency;
623         struct latency_counter lockwait_latency;
624         struct latency_counter childwrite_latency;
625         uint32_t num_recoveries;
626         struct timeval statistics_start_time;
627         struct timeval statistics_current_time;
628 };
629
630 /*
631  * wire format for statistics history
632  */
633 struct ctdb_statistics_wire {
634         uint32_t num;
635         struct ctdb_statistics stats[1];
636 };
637
638
639 #endif