4 Copyright (C) Andrew Tridgell 2006
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 2 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, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #ifndef _CTDB_PRIVATE_H
22 #define _CTDB_PRIVATE_H
25 #include <sys/socket.h>
26 #include <netinet/in.h>
28 /* location of daemon socket */
29 #define CTDB_PATH "/tmp/ctdb.socket"
31 /* default ctdb port number */
32 #define CTDB_PORT 9001
34 /* we must align packets to ensure ctdb works on all architectures (eg. sparc) */
35 #define CTDB_DS_ALIGNMENT 8
38 #define CTDB_NULL_FUNC 0xFF000001
39 #define CTDB_FETCH_FUNC 0xFF000002
41 /* all tunable variables go in here */
43 uint32_t max_redirect_count;
44 uint32_t seqnum_frequency;
45 uint32_t control_timeout;
46 uint32_t traverse_timeout;
47 uint32_t keepalive_interval;
48 uint32_t keepalive_limit;
50 uint32_t recover_timeout;
51 uint32_t recover_interval;
52 uint32_t election_timeout;
53 uint32_t takeover_timeout;
54 uint32_t monitor_interval;
55 uint32_t script_timeout;
59 an installed ctdb remote call
61 struct ctdb_registered_call {
62 struct ctdb_registered_call *next, *prev;
68 this address structure might need to be generalised later for some
79 #define ctdb_validate_vnn(ctdb, vnn) (((uint32_t)(vnn)) < (ctdb)->num_nodes)
82 /* called from the queue code when a packet comes in. Called with data==NULL
84 typedef void (*ctdb_queue_cb_fn_t)(uint8_t *data, size_t length,
87 /* used for callbacks in ctdb_control requests */
88 typedef void (*ctdb_control_callback_fn_t)(struct ctdb_context *,
89 int32_t status, TDB_DATA data,
94 structure describing a connected client in the daemon
97 struct ctdb_context *ctdb;
99 struct ctdb_queue *queue;
101 struct ctdb_tcp_list *tcp_list;
106 state associated with one node
109 struct ctdb_context *ctdb;
110 struct ctdb_address address;
111 const char *name; /* for debug messages */
112 void *private_data; /* private to transport */
114 #define NODE_FLAGS_CONNECTED 0x00000001
115 #define NODE_FLAGS_DISABLED 0x00000002
116 #define NODE_FLAGS_PERMANENTLY_DISABLED 0x00000004
119 /* used by the dead node monitoring */
124 /* a list of controls pending to this node, so we can time them out quickly
125 if the node becomes disconnected */
126 struct daemon_control_state *pending_controls;
128 /* the public address of this node, if known */
129 const char *public_address;
130 uint8_t public_netmask_bits;
132 /* the node number that has taken over this nodes public address, if any.
133 If not taken over, then set to -1 */
134 int32_t takeover_vnn;
138 transport specific methods
140 struct ctdb_methods {
141 int (*initialise)(struct ctdb_context *); /* initialise transport structures */
142 int (*start)(struct ctdb_context *); /* start protocol processing */
143 int (*add_node)(struct ctdb_node *); /* setup a new node */
144 int (*queue_pkt)(struct ctdb_node *, uint8_t *data, uint32_t length);
145 void *(*allocate_pkt)(TALLOC_CTX *mem_ctx, size_t );
146 void (*shutdown)(struct ctdb_context *); /* shutdown transport */
150 transport calls up to the ctdb layer
152 struct ctdb_upcalls {
153 /* recv_pkt is called when a packet comes in */
154 void (*recv_pkt)(struct ctdb_context *, uint8_t *data, uint32_t length);
156 /* node_dead is called when an attempt to send to a node fails */
157 void (*node_dead)(struct ctdb_node *);
159 /* node_connected is called when a connection to a node is established */
160 void (*node_connected)(struct ctdb_node *);
163 /* list of message handlers - needs to be changed to a more efficient data
164 structure so we can find a message handler given a srvid quickly */
165 struct ctdb_message_list {
166 struct ctdb_context *ctdb;
167 struct ctdb_message_list *next, *prev;
169 ctdb_message_fn_t message_handler;
170 void *message_private;
173 /* additional data required for the daemon mode */
174 struct ctdb_daemon_data {
177 struct ctdb_queue *queue;
181 ctdb status information
183 struct ctdb_statistics {
184 uint32_t num_clients;
187 uint32_t client_packets_sent;
188 uint32_t client_packets_recv;
189 uint32_t node_packets_sent;
190 uint32_t node_packets_recv;
191 uint32_t keepalive_packets_sent;
192 uint32_t keepalive_packets_recv;
196 uint32_t req_dmaster;
197 uint32_t reply_dmaster;
198 uint32_t reply_error;
199 uint32_t req_message;
200 uint32_t req_control;
201 uint32_t reply_control;
205 uint32_t req_message;
206 uint32_t req_control;
214 uint32_t process_exists;
215 uint32_t traverse_start;
216 uint32_t traverse_all;
217 uint32_t traverse_data;
218 uint32_t update_seqnum;
219 uint32_t enable_seqnum;
220 uint32_t set_seqnum_frequency;
221 uint32_t register_srvid;
222 uint32_t deregister_srvid;
229 uint32_t total_calls;
230 uint32_t pending_calls;
231 uint32_t lockwait_calls;
232 uint32_t pending_lockwait_calls;
233 uint32_t memory_used;
234 uint32_t __last_counter; /* hack for control_statistics_all */
235 uint32_t max_hop_count;
236 double max_call_latency;
237 double max_lockwait_latency;
240 /* table that contains the mapping between a hash value and lmaster
242 struct ctdb_vnn_map {
249 a wire representation of the vnn map
251 struct ctdb_vnn_map_wire {
257 /* a structure that contains the elements required for the write record
260 struct ctdb_write_record {
264 unsigned char blob[1];
267 enum ctdb_freeze_mode {CTDB_FREEZE_NONE, CTDB_FREEZE_PENDING, CTDB_FREEZE_FROZEN};
269 #define CTDB_MONITORING_ACTIVE 0
270 #define CTDB_MONITORING_DISABLED 1
272 /* information about IP takeover */
273 struct ctdb_takeover {
275 const char *interface;
276 const char *event_script;
277 TALLOC_CTX *last_ctx;
281 /* main state of the ctdb daemon */
282 struct ctdb_context {
283 struct event_context *ev;
284 uint32_t recovery_mode;
285 uint32_t monitoring_mode;
286 TALLOC_CTX *monitor_context;
287 struct ctdb_tunable tunable;
288 enum ctdb_freeze_mode freeze_mode;
289 struct ctdb_freeze_handle *freeze_handle;
290 struct ctdb_address address;
292 const char *db_directory;
293 const char *transport;
295 char *node_list_file;
296 char *recovery_lock_file;
297 int recovery_lock_fd;
298 uint32_t vnn; /* our own vnn */
300 uint32_t num_connected;
302 struct idr_context *idr;
304 struct ctdb_node **nodes; /* array of nodes in the cluster - indexed by vnn */
306 const struct ctdb_methods *methods; /* transport methods */
307 const struct ctdb_upcalls *upcalls; /* transport upcalls */
308 void *private_data; /* private to transport */
309 struct ctdb_db_context *db_list;
310 struct ctdb_message_list *message_list;
311 struct ctdb_daemon_data daemon;
312 struct ctdb_statistics statistics;
313 struct ctdb_vnn_map *vnn_map;
314 uint32_t num_clients;
315 uint32_t recovery_master;
316 struct ctdb_call_state *pending_calls;
317 struct ctdb_takeover takeover;
318 struct ctdb_tcp_list *tcp_list;
321 struct ctdb_db_context {
322 struct ctdb_db_context *next, *prev;
323 struct ctdb_context *ctdb;
327 struct tdb_wrap *ltdb;
328 struct ctdb_registered_call *calls; /* list of registered calls */
330 struct timed_event *te;
334 #define CTDB_NO_MEMORY(ctdb, p) do { if (!(p)) { \
335 DEBUG(0,("Out of memory for %s at %s\n", #p, __location__)); \
336 ctdb_set_error(ctdb, "Out of memory at %s:%d", __FILE__, __LINE__); \
337 return -1; }} while (0)
339 #define CTDB_NO_MEMORY_VOID(ctdb, p) do { if (!(p)) { \
340 DEBUG(0,("Out of memory for %s at %s\n", #p, __location__)); \
341 ctdb_set_error(ctdb, "Out of memory at %s:%d", __FILE__, __LINE__); \
344 #define CTDB_NO_MEMORY_NULL(ctdb, p) do { if (!(p)) { \
345 DEBUG(0,("Out of memory for %s at %s\n", #p, __location__)); \
346 ctdb_set_error(ctdb, "Out of memory at %s:%d", __FILE__, __LINE__); \
347 return NULL; }} while (0)
349 #define CTDB_NO_MEMORY_FATAL(ctdb, p) do { if (!(p)) { \
350 DEBUG(0,("Out of memory for %s at %s\n", #p, __location__)); \
351 ctdb_fatal(ctdb, "Out of memory in " __location__ ); \
355 the extended header for records in the ltdb
357 struct ctdb_ltdb_header {
364 enum ctdb_controls {CTDB_CONTROL_PROCESS_EXISTS = 0,
365 CTDB_CONTROL_STATISTICS = 1,
367 CTDB_CONTROL_PING = 3,
368 CTDB_CONTROL_GETDBPATH = 4,
369 CTDB_CONTROL_GETVNNMAP = 5,
370 CTDB_CONTROL_SETVNNMAP = 6,
371 CTDB_CONTROL_GET_DEBUG = 7,
372 CTDB_CONTROL_SET_DEBUG = 8,
373 CTDB_CONTROL_GET_DBMAP = 9,
374 CTDB_CONTROL_GET_NODEMAP = 10,
375 CTDB_CONTROL_SET_DMASTER = 11,
377 CTDB_CONTROL_PULL_DB = 13,
378 CTDB_CONTROL_PUSH_DB = 14,
379 CTDB_CONTROL_GET_RECMODE = 15,
380 CTDB_CONTROL_SET_RECMODE = 16,
381 CTDB_CONTROL_STATISTICS_RESET = 17,
382 CTDB_CONTROL_DB_ATTACH = 18,
383 CTDB_CONTROL_SET_CALL = 19,
384 CTDB_CONTROL_TRAVERSE_START = 20,
385 CTDB_CONTROL_TRAVERSE_ALL = 21,
386 CTDB_CONTROL_TRAVERSE_DATA = 22,
387 CTDB_CONTROL_REGISTER_SRVID = 23,
388 CTDB_CONTROL_DEREGISTER_SRVID = 24,
389 CTDB_CONTROL_GET_DBNAME = 25,
390 CTDB_CONTROL_ENABLE_SEQNUM = 26,
391 CTDB_CONTROL_UPDATE_SEQNUM = 27,
393 CTDB_CONTROL_DUMP_MEMORY = 29,
394 CTDB_CONTROL_GET_PID = 30,
395 CTDB_CONTROL_GET_RECMASTER = 31,
396 CTDB_CONTROL_SET_RECMASTER = 32,
397 CTDB_CONTROL_FREEZE = 33,
398 CTDB_CONTROL_THAW = 34,
399 CTDB_CONTROL_GET_VNN = 35,
400 CTDB_CONTROL_SHUTDOWN = 36,
401 CTDB_CONTROL_GET_MONMODE = 37,
402 CTDB_CONTROL_SET_MONMODE = 38,
403 CTDB_CONTROL_MAX_RSN = 39,
404 CTDB_CONTROL_SET_RSN_NONEMPTY = 40,
405 CTDB_CONTROL_DELETE_LOW_RSN = 41,
406 CTDB_CONTROL_TAKEOVER_IP = 42,
407 CTDB_CONTROL_RELEASE_IP = 43,
408 CTDB_CONTROL_TCP_CLIENT = 44,
409 CTDB_CONTROL_TCP_ADD = 45,
410 CTDB_CONTROL_TCP_REMOVE = 46,
411 CTDB_CONTROL_STARTUP = 47,
412 CTDB_CONTROL_SET_TUNABLE = 48,
413 CTDB_CONTROL_GET_TUNABLE = 49,
414 CTDB_CONTROL_LIST_TUNABLES = 50,
415 CTDB_CONTROL_GET_PUBLIC_IPS = 51,
416 CTDB_CONTROL_PERMANENTLY_DISABLE = 52,
420 structure passed in ctdb_control_set_rsn_nonempty
422 struct ctdb_control_set_rsn_nonempty {
428 structure passed in ctdb_control_delete_low_rsn
430 struct ctdb_control_delete_low_rsn {
436 structure passed in set_call control
438 struct ctdb_control_set_call {
445 struct for tcp_client control
447 struct ctdb_control_tcp {
448 struct sockaddr_in src;
449 struct sockaddr_in dest;
453 struct for tcp_add and tcp_remove controls
455 struct ctdb_control_tcp_vnn {
457 struct sockaddr_in src;
458 struct sockaddr_in dest;
462 structure used for CTDB_SRVID_NODE_FLAGS_CHANGED
464 struct ctdb_node_flag_change {
469 enum call_state {CTDB_CALL_WAIT, CTDB_CALL_DONE, CTDB_CALL_ERROR};
471 #define CTDB_LMASTER_ANY 0xffffffff
474 state of a in-progress ctdb call
476 struct ctdb_call_state {
477 struct ctdb_call_state *next, *prev;
478 enum call_state state;
480 struct ctdb_req_call *c;
481 struct ctdb_db_context *ctdb_db;
483 struct ctdb_call call;
486 void (*fn)(struct ctdb_call_state *);
492 /* used for fetch_lock */
493 struct ctdb_fetch_handle {
494 struct ctdb_db_context *ctdb_db;
497 struct ctdb_ltdb_header header;
503 enum ctdb_operation {
506 CTDB_REQ_DMASTER = 2,
507 CTDB_REPLY_DMASTER = 3,
508 CTDB_REPLY_ERROR = 4,
509 CTDB_REQ_MESSAGE = 5,
511 CTDB_REQ_CONTROL = 7,
512 CTDB_REPLY_CONTROL = 8,
513 CTDB_REQ_KEEPALIVE = 9,
516 #define CTDB_MAGIC 0x43544442 /* CTDB */
517 #define CTDB_VERSION 1
522 struct ctdb_req_header {
525 uint32_t ctdb_version;
533 struct ctdb_req_call {
534 struct ctdb_req_header hdr;
540 uint32_t calldatalen;
541 uint8_t data[1]; /* key[] followed by calldata[] */
544 struct ctdb_reply_call {
545 struct ctdb_req_header hdr;
551 struct ctdb_reply_error {
552 struct ctdb_req_header hdr;
558 struct ctdb_req_dmaster {
559 struct ctdb_req_header hdr;
568 struct ctdb_reply_dmaster {
569 struct ctdb_req_header hdr;
577 struct ctdb_req_message {
578 struct ctdb_req_header hdr;
584 struct ctdb_req_getdbpath {
585 struct ctdb_req_header hdr;
589 struct ctdb_reply_getdbpath {
590 struct ctdb_req_header hdr;
595 struct ctdb_req_control {
596 struct ctdb_req_header hdr;
600 #define CTDB_CTRL_FLAG_NOREPLY 1
606 struct ctdb_reply_control {
607 struct ctdb_req_header hdr;
614 struct ctdb_req_keepalive {
615 struct ctdb_req_header hdr;
618 /* internal prototypes */
619 void ctdb_set_error(struct ctdb_context *ctdb, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3);
620 void ctdb_fatal(struct ctdb_context *ctdb, const char *msg);
621 bool ctdb_same_address(struct ctdb_address *a1, struct ctdb_address *a2);
622 int ctdb_parse_address(struct ctdb_context *ctdb,
623 TALLOC_CTX *mem_ctx, const char *str,
624 struct ctdb_address *address);
625 uint32_t ctdb_hash(const TDB_DATA *key);
626 uint32_t ctdb_hash_string(const char *str);
627 void ctdb_request_call(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
628 void ctdb_request_dmaster(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
629 void ctdb_request_message(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
630 void ctdb_reply_dmaster(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
631 void ctdb_reply_call(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
632 void ctdb_reply_error(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
634 uint32_t ctdb_lmaster(struct ctdb_context *ctdb, const TDB_DATA *key);
635 int ctdb_ltdb_fetch(struct ctdb_db_context *ctdb_db,
636 TDB_DATA key, struct ctdb_ltdb_header *header,
637 TALLOC_CTX *mem_ctx, TDB_DATA *data);
638 int ctdb_ltdb_store(struct ctdb_db_context *ctdb_db, TDB_DATA key,
639 struct ctdb_ltdb_header *header, TDB_DATA data);
640 void ctdb_queue_packet(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
641 int ctdb_ltdb_lock_requeue(struct ctdb_db_context *ctdb_db,
642 TDB_DATA key, struct ctdb_req_header *hdr,
643 void (*recv_pkt)(void *, struct ctdb_req_header *),
644 void *recv_context, bool ignore_generation);
645 int ctdb_ltdb_lock_fetch_requeue(struct ctdb_db_context *ctdb_db,
646 TDB_DATA key, struct ctdb_ltdb_header *header,
647 struct ctdb_req_header *hdr, TDB_DATA *data,
648 void (*recv_pkt)(void *, struct ctdb_req_header *),
649 void *recv_context, bool ignore_generation);
650 void ctdb_input_pkt(struct ctdb_context *ctdb, struct ctdb_req_header *);
652 struct ctdb_call_state *ctdb_call_local_send(struct ctdb_db_context *ctdb_db,
653 struct ctdb_call *call,
654 struct ctdb_ltdb_header *header,
658 int ctdbd_start(struct ctdb_context *ctdb);
659 struct ctdb_call_state *ctdbd_call_send(struct ctdb_db_context *ctdb_db, struct ctdb_call *call);
660 int ctdbd_call_recv(struct ctdb_call_state *state, struct ctdb_call *call);
663 queue a packet for sending
665 int ctdb_queue_send(struct ctdb_queue *queue, uint8_t *data, uint32_t length);
668 setup the fd used by the queue
670 int ctdb_queue_set_fd(struct ctdb_queue *queue, int fd);
673 setup a packet queue on a socket
675 struct ctdb_queue *ctdb_queue_setup(struct ctdb_context *ctdb,
676 TALLOC_CTX *mem_ctx, int fd, int alignment,
678 ctdb_queue_cb_fn_t callback,
682 allocate a packet for use in client<->daemon communication
684 struct ctdb_req_header *_ctdbd_allocate_pkt(struct ctdb_context *ctdb,
686 enum ctdb_operation operation,
687 size_t length, size_t slength,
689 #define ctdbd_allocate_pkt(ctdb, mem_ctx, operation, length, type) \
690 (type *)_ctdbd_allocate_pkt(ctdb, mem_ctx, operation, length, sizeof(type), #type)
692 struct ctdb_req_header *_ctdb_transport_allocate(struct ctdb_context *ctdb,
694 enum ctdb_operation operation,
695 size_t length, size_t slength,
697 #define ctdb_transport_allocate(ctdb, mem_ctx, operation, length, type) \
698 (type *)_ctdb_transport_allocate(ctdb, mem_ctx, operation, length, sizeof(type), #type)
702 lock a record in the ltdb, given a key
704 int ctdb_ltdb_lock(struct ctdb_db_context *ctdb_db, TDB_DATA key);
707 unlock a record in the ltdb, given a key
709 int ctdb_ltdb_unlock(struct ctdb_db_context *ctdb_db, TDB_DATA key);
713 make a ctdb call to the local daemon - async send. Called from client context.
715 This constructs a ctdb_call request and queues it for processing.
716 This call never blocks.
718 struct ctdb_call_state *ctdb_client_call_send(struct ctdb_db_context *ctdb_db,
719 struct ctdb_call *call);
722 make a recv call to the local ctdb daemon - called from client context
724 This is called when the program wants to wait for a ctdb_call to complete and get the
725 results. This call will block unless the call has already completed.
727 int ctdb_client_call_recv(struct ctdb_call_state *state, struct ctdb_call *call);
729 int ctdb_daemon_set_message_handler(struct ctdb_context *ctdb, uint64_t srvid,
730 ctdb_message_fn_t handler,
733 int ctdb_client_send_message(struct ctdb_context *ctdb, uint32_t vnn,
734 uint64_t srvid, TDB_DATA data);
739 int ctdb_daemon_send_message(struct ctdb_context *ctdb, uint32_t vnn,
740 uint64_t srvid, TDB_DATA data);
743 struct lockwait_handle *ctdb_lockwait(struct ctdb_db_context *ctdb_db,
745 void (*callback)(void *), void *private_data);
747 struct ctdb_call_state *ctdb_daemon_call_send(struct ctdb_db_context *ctdb_db,
748 struct ctdb_call *call);
750 int ctdb_daemon_call_recv(struct ctdb_call_state *state, struct ctdb_call *call);
752 struct ctdb_call_state *ctdb_daemon_call_send_remote(struct ctdb_db_context *ctdb_db,
753 struct ctdb_call *call,
754 struct ctdb_ltdb_header *header);
756 int ctdb_call_local(struct ctdb_db_context *ctdb_db, struct ctdb_call *call,
757 struct ctdb_ltdb_header *header, TALLOC_CTX *mem_ctx, TDB_DATA *data,
760 #define ctdb_reqid_find(ctdb, reqid, type) (type *)_ctdb_reqid_find(ctdb, reqid, #type, __location__)
762 void ctdb_recv_raw_pkt(void *p, uint8_t *data, uint32_t length);
764 int ctdb_socket_connect(struct ctdb_context *ctdb);
766 void ctdb_latency(double *latency, struct timeval t);
768 uint32_t ctdb_reqid_new(struct ctdb_context *ctdb, void *state);
769 void *_ctdb_reqid_find(struct ctdb_context *ctdb, uint32_t reqid, const char *type, const char *location);
770 void ctdb_reqid_remove(struct ctdb_context *ctdb, uint32_t reqid);
772 void ctdb_request_control(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
773 void ctdb_reply_control(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
775 int ctdb_daemon_send_control(struct ctdb_context *ctdb, uint32_t destnode,
776 uint64_t srvid, uint32_t opcode, uint32_t client_id, uint32_t flags,
778 ctdb_control_callback_fn_t callback,
781 int32_t ctdb_control_db_attach(struct ctdb_context *ctdb, TDB_DATA indata,
784 int ctdb_daemon_set_call(struct ctdb_context *ctdb, uint32_t db_id,
785 ctdb_fn_t fn, int id);
787 int ctdb_control(struct ctdb_context *ctdb, uint32_t destnode, uint64_t srvid,
788 uint32_t opcode, uint32_t flags, TDB_DATA data,
789 TALLOC_CTX *mem_ctx, TDB_DATA *outdata, int32_t *status,
790 struct timeval *timeout, char **errormsg);
795 #define CHECK_CONTROL_DATA_SIZE(size) do { \
796 if (indata.dsize != size) { \
797 DEBUG(0,(__location__ " Invalid data size in opcode %u. Got %u expected %u\n", \
798 opcode, (unsigned)indata.dsize, (unsigned)size)); \
803 int ctdb_control_getvnnmap(struct ctdb_context *ctdb, uint32_t opcode, TDB_DATA indata, TDB_DATA *outdata);
804 int ctdb_control_setvnnmap(struct ctdb_context *ctdb, uint32_t opcode, TDB_DATA indata, TDB_DATA *outdata);
805 int ctdb_control_getdbmap(struct ctdb_context *ctdb, uint32_t opcode, TDB_DATA indata, TDB_DATA *outdata);
806 int ctdb_control_getnodemap(struct ctdb_context *ctdb, uint32_t opcode, TDB_DATA indata, TDB_DATA *outdata);
807 int ctdb_control_writerecord(struct ctdb_context *ctdb, uint32_t opcode, TDB_DATA indata, TDB_DATA *outdata);
810 struct ctdb_traverse_start {
817 structure used to pass record data between the child and parent
819 struct ctdb_rec_data {
828 /* structure used for pulldb control */
829 struct ctdb_control_pulldb {
834 /* structure used for pulldb control */
835 struct ctdb_control_pulldb_reply {
841 /* set dmaster control structure */
842 struct ctdb_control_set_dmaster {
848 structure for setting a tunable
850 struct ctdb_control_set_tunable {
857 structure for getting a tunable
859 struct ctdb_control_get_tunable {
865 structure for listing tunables
867 struct ctdb_control_list_tunable {
869 /* returns a : separated list of tunable names */
874 /* table that contains a list of all nodes a ctdb knows about and their
877 struct ctdb_node_and_flags {
880 struct sockaddr_in sin;
884 struct ctdb_node_map {
886 struct ctdb_node_and_flags nodes[1];
889 int32_t ctdb_control_traverse_start(struct ctdb_context *ctdb, TDB_DATA indata,
890 TDB_DATA *outdata, uint32_t srcnode);
891 int32_t ctdb_control_traverse_all(struct ctdb_context *ctdb, TDB_DATA data, TDB_DATA *outdata);
892 int32_t ctdb_control_traverse_data(struct ctdb_context *ctdb, TDB_DATA data, TDB_DATA *outdata);
894 int ctdb_dispatch_message(struct ctdb_context *ctdb, uint64_t srvid, TDB_DATA data);
896 int daemon_register_message_handler(struct ctdb_context *ctdb, uint32_t client_id, uint64_t srvid);
897 int ctdb_deregister_message_handler(struct ctdb_context *ctdb, uint64_t srvid, void *private_data);
898 int daemon_deregister_message_handler(struct ctdb_context *ctdb, uint32_t client_id, uint64_t srvid);
900 int32_t ctdb_ltdb_enable_seqnum(struct ctdb_context *ctdb, uint32_t db_id);
901 int32_t ctdb_ltdb_update_seqnum(struct ctdb_context *ctdb, uint32_t db_id, uint32_t srcnode);
902 int32_t ctdb_ltdb_set_seqnum_frequency(struct ctdb_context *ctdb, uint32_t frequency);
904 struct ctdb_rec_data *ctdb_marshall_record(TALLOC_CTX *mem_ctx, uint32_t reqid, TDB_DATA key, TDB_DATA data);
906 int32_t ctdb_control_pull_db(struct ctdb_context *ctdb, TDB_DATA indata, TDB_DATA *outdata);
907 int32_t ctdb_control_push_db(struct ctdb_context *ctdb, TDB_DATA indata);
908 int32_t ctdb_control_set_dmaster(struct ctdb_context *ctdb, TDB_DATA indata);
910 int32_t ctdb_control_set_recmode(struct ctdb_context *ctdb,
911 struct ctdb_req_control *c,
912 TDB_DATA indata, bool *async_reply,
913 const char **errormsg);
914 void ctdb_request_control_reply(struct ctdb_context *ctdb, struct ctdb_req_control *c,
915 TDB_DATA *outdata, int32_t status, const char *errormsg);
917 int32_t ctdb_control_freeze(struct ctdb_context *ctdb, struct ctdb_req_control *c, bool *async_reply);
918 int32_t ctdb_control_thaw(struct ctdb_context *ctdb);
920 int ctdb_start_recoverd(struct ctdb_context *ctdb);
922 uint32_t ctdb_get_num_enabled_nodes(struct ctdb_context *ctdb);
924 void ctdb_stop_monitoring(struct ctdb_context *ctdb);
925 void ctdb_start_monitoring(struct ctdb_context *ctdb);
926 void ctdb_send_keepalive(struct ctdb_context *ctdb, uint32_t destnode);
928 void ctdb_daemon_cancel_controls(struct ctdb_context *ctdb, struct ctdb_node *node);
929 void ctdb_call_resend_all(struct ctdb_context *ctdb);
930 void ctdb_node_dead(struct ctdb_node *node);
931 void ctdb_node_connected(struct ctdb_node *node);
932 bool ctdb_blocking_freeze(struct ctdb_context *ctdb);
933 int32_t ctdb_control_max_rsn(struct ctdb_context *ctdb, TDB_DATA indata, TDB_DATA *outdata);
934 int32_t ctdb_control_set_rsn_nonempty(struct ctdb_context *ctdb, TDB_DATA indata, TDB_DATA *outdata);
935 int32_t ctdb_control_delete_low_rsn(struct ctdb_context *ctdb, TDB_DATA indata, TDB_DATA *outdata);
936 int ctdb_ctrl_get_max_rsn(struct ctdb_context *ctdb, struct timeval timeout,
937 uint32_t destnode, uint32_t db_id, uint64_t *max_rsn);
938 int ctdb_ctrl_set_rsn_nonempty(struct ctdb_context *ctdb, struct timeval timeout,
939 uint32_t destnode, uint32_t db_id, uint64_t rsn);
940 int ctdb_ctrl_delete_low_rsn(struct ctdb_context *ctdb, struct timeval timeout,
941 uint32_t destnode, uint32_t db_id, uint64_t rsn);
942 void ctdb_set_realtime(bool enable);
943 int32_t ctdb_control_takeover_ip(struct ctdb_context *ctdb,
944 struct ctdb_req_control *c,
947 int32_t ctdb_control_release_ip(struct ctdb_context *ctdb,
948 struct ctdb_req_control *c,
952 struct ctdb_public_ip {
954 uint32_t takeover_vnn;
955 struct sockaddr_in sin;
957 int ctdb_ctrl_takeover_ip(struct ctdb_context *ctdb, struct timeval timeout,
958 uint32_t destnode, struct ctdb_public_ip *ip);
959 int ctdb_ctrl_release_ip(struct ctdb_context *ctdb, struct timeval timeout,
960 uint32_t destnode, struct ctdb_public_ip *ip);
962 struct ctdb_all_public_ips {
964 struct ctdb_public_ip ips[1];
966 int32_t ctdb_control_get_public_ips(struct ctdb_context *ctdb, struct ctdb_req_control *c, TDB_DATA *outdata);
967 int ctdb_ctrl_get_public_ips(struct ctdb_context *ctdb,
968 struct timeval timeout, uint32_t destnode,
969 TALLOC_CTX *mem_ctx, struct ctdb_all_public_ips **ips);
972 /* from takeover/system.c */
973 int ctdb_sys_send_arp(const struct sockaddr_in *saddr, const char *iface);
974 bool ctdb_sys_have_ip(const char *ip);
975 int ctdb_sys_send_ack(const struct sockaddr_in *dest,
976 const struct sockaddr_in *src);
978 int ctdb_set_public_addresses(struct ctdb_context *ctdb, const char *alist);
979 int ctdb_set_event_script(struct ctdb_context *ctdb, const char *script);
980 int ctdb_takeover_run(struct ctdb_context *ctdb, struct ctdb_node_map *nodemap);
982 int32_t ctdb_control_tcp_client(struct ctdb_context *ctdb, uint32_t client_id,
983 uint32_t srcnode, TDB_DATA indata);
984 int32_t ctdb_control_tcp_add(struct ctdb_context *ctdb, TDB_DATA indata);
985 int32_t ctdb_control_tcp_remove(struct ctdb_context *ctdb, TDB_DATA indata);
986 int32_t ctdb_control_startup(struct ctdb_context *ctdb, uint32_t vnn);
988 void ctdb_takeover_client_destructor_hook(struct ctdb_client *client);
989 int ctdb_event_script(struct ctdb_context *ctdb, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3);
990 int ctdb_event_script_callback(struct ctdb_context *ctdb,
991 struct timeval timeout,
993 void (*callback)(struct ctdb_context *, int, void *),
995 const char *fmt, ...) PRINTF_ATTRIBUTE(6,7);
996 void ctdb_release_all_ips(struct ctdb_context *ctdb);
998 void set_nonblocking(int fd);
999 void set_close_on_exec(int fd);
1001 bool ctdb_recovery_lock(struct ctdb_context *ctdb, bool keep);
1003 int ctdb_set_recovery_lock_file(struct ctdb_context *ctdb, const char *file);
1005 int32_t ctdb_control_get_tunable(struct ctdb_context *ctdb, TDB_DATA indata,
1007 int32_t ctdb_control_set_tunable(struct ctdb_context *ctdb, TDB_DATA indata);
1008 int32_t ctdb_control_list_tunables(struct ctdb_context *ctdb, TDB_DATA *outdata);
1010 void ctdb_tunables_set_defaults(struct ctdb_context *ctdb);