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 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_PRIVATE_H
21 #define _CTDB_PRIVATE_H
24 #include <sys/socket.h>
26 /* location of daemon socket */
27 #define CTDB_PATH "/tmp/ctdb.socket"
29 /* default ctdb port number */
30 #define CTDB_PORT 4379
32 /* we must align packets to ensure ctdb works on all architectures (eg. sparc) */
33 #define CTDB_DS_ALIGNMENT 8
36 #define CTDB_NULL_FUNC 0xFF000001
37 #define CTDB_FETCH_FUNC 0xFF000002
41 recovery daemon memdump reply address
43 struct rd_memdump_reply {
49 a tcp connection description
51 struct ctdb_tcp_connection {
52 ctdb_sock_addr src_addr;
53 ctdb_sock_addr dst_addr;
56 /* the wire representation for a tcp tickle array */
57 struct ctdb_tcp_wire_array {
59 struct ctdb_tcp_connection connections[1];
62 /* the list of tcp tickles used by get/set tcp tickle list */
63 struct ctdb_control_tcp_tickle_list {
65 struct ctdb_tcp_wire_array tickles;
69 array of tcp connections
71 struct ctdb_tcp_array {
73 struct ctdb_tcp_connection *connections;
77 /* all tunable variables go in here */
79 uint32_t max_redirect_count;
80 uint32_t seqnum_interval; /* unit is ms */
81 uint32_t control_timeout;
82 uint32_t traverse_timeout;
83 uint32_t keepalive_interval;
84 uint32_t keepalive_limit;
86 uint32_t recover_timeout;
87 uint32_t recover_interval;
88 uint32_t election_timeout;
89 uint32_t takeover_timeout;
90 uint32_t monitor_interval;
91 uint32_t tickle_update_interval;
92 uint32_t script_timeout;
93 uint32_t script_ban_count; /* ban after this many consec timeouts*/
94 uint32_t recovery_grace_period;
95 uint32_t recovery_ban_period;
96 uint32_t database_hash_size;
97 uint32_t database_max_dead;
98 uint32_t rerecovery_timeout;
100 uint32_t deterministic_public_ips;
101 uint32_t disable_when_unhealthy;
102 uint32_t reclock_ping_period;
103 uint32_t no_ip_failback;
104 uint32_t verbose_memory_names;
105 uint32_t recd_ping_timeout;
106 uint32_t recd_ping_failcount;
107 uint32_t log_latency_ms;
108 uint32_t recovery_drop_all_ips;
112 an installed ctdb remote call
114 struct ctdb_registered_call {
115 struct ctdb_registered_call *next, *prev;
121 this address structure might need to be generalised later for some
124 struct ctdb_address {
130 check that a pnn is valid
132 #define ctdb_validate_pnn(ctdb, pnn) (((uint32_t)(pnn)) < (ctdb)->num_nodes)
135 /* called from the queue code when a packet comes in. Called with data==NULL
137 typedef void (*ctdb_queue_cb_fn_t)(uint8_t *data, size_t length,
140 /* used for callbacks in ctdb_control requests */
141 typedef void (*ctdb_control_callback_fn_t)(struct ctdb_context *,
142 int32_t status, TDB_DATA data,
143 const char *errormsg,
147 structure describing a connected client in the daemon
150 struct ctdb_context *ctdb;
152 struct ctdb_queue *queue;
155 struct ctdb_tcp_list *tcp_list;
156 uint32_t num_persistent_updates;
160 /* state associated with a public ip address */
162 struct ctdb_vnn *prev, *next;
165 ctdb_sock_addr public_address;
166 uint8_t public_netmask_bits;
168 /* the node number that is serving this public address, if any.
169 If no node serves this ip it is set to -1 */
172 /* List of clients to tickle for this public address */
173 struct ctdb_tcp_array *tcp_array;
175 /* whether we need to update the other nodes with changes to our list
176 of connected clients */
177 bool tcp_update_needed;
179 /* a context to hang sending gratious arp events off */
180 TALLOC_CTX *takeover_ctx;
182 struct ctdb_kill_tcp *killtcp;
186 state associated with one node
189 struct ctdb_context *ctdb;
190 struct ctdb_address address;
191 const char *name; /* for debug messages */
192 void *private_data; /* private to transport */
194 #define NODE_FLAGS_DISCONNECTED 0x00000001 /* node isn't connected */
195 #define NODE_FLAGS_UNHEALTHY 0x00000002 /* monitoring says node is unhealthy */
196 #define NODE_FLAGS_PERMANENTLY_DISABLED 0x00000004 /* administrator has disabled node */
197 #define NODE_FLAGS_BANNED 0x00000008 /* recovery daemon has banned the node */
198 #define NODE_FLAGS_DISABLED (NODE_FLAGS_UNHEALTHY|NODE_FLAGS_PERMANENTLY_DISABLED)
199 #define NODE_FLAGS_INACTIVE (NODE_FLAGS_DISCONNECTED|NODE_FLAGS_BANNED)
202 /* used by the dead node monitoring */
207 /* used to track node capabilities, is only valid/tracked inside the
210 uint32_t capabilities;
212 /* a list of controls pending to this node, so we can time them out quickly
213 if the node becomes disconnected */
214 struct daemon_control_state *pending_controls;
216 /* used by the recovery daemon when distributing ip addresses
217 across the nodes. it needs to know which public ip's can be handled
220 struct ctdb_all_public_ips *public_ips;
224 transport specific methods
226 struct ctdb_methods {
227 int (*initialise)(struct ctdb_context *); /* initialise transport structures */
228 int (*start)(struct ctdb_context *); /* start the transport */
229 int (*add_node)(struct ctdb_node *); /* setup a new node */
230 int (*connect_node)(struct ctdb_node *); /* connect to node */
231 int (*queue_pkt)(struct ctdb_node *, uint8_t *data, uint32_t length);
232 void *(*allocate_pkt)(TALLOC_CTX *mem_ctx, size_t );
233 void (*shutdown)(struct ctdb_context *); /* shutdown transport */
234 void (*restart)(struct ctdb_node *); /* stop and restart the connection */
238 transport calls up to the ctdb layer
240 struct ctdb_upcalls {
241 /* recv_pkt is called when a packet comes in */
242 void (*recv_pkt)(struct ctdb_context *, uint8_t *data, uint32_t length);
244 /* node_dead is called when an attempt to send to a node fails */
245 void (*node_dead)(struct ctdb_node *);
247 /* node_connected is called when a connection to a node is established */
248 void (*node_connected)(struct ctdb_node *);
251 /* list of message handlers - needs to be changed to a more efficient data
252 structure so we can find a message handler given a srvid quickly */
253 struct ctdb_message_list {
254 struct ctdb_context *ctdb;
255 struct ctdb_message_list *next, *prev;
257 ctdb_message_fn_t message_handler;
258 void *message_private;
261 /* additional data required for the daemon mode */
262 struct ctdb_daemon_data {
265 struct ctdb_queue *queue;
269 ctdb status information
271 struct ctdb_statistics {
272 uint32_t num_clients;
275 uint32_t client_packets_sent;
276 uint32_t client_packets_recv;
277 uint32_t node_packets_sent;
278 uint32_t node_packets_recv;
279 uint32_t keepalive_packets_sent;
280 uint32_t keepalive_packets_recv;
284 uint32_t req_dmaster;
285 uint32_t reply_dmaster;
286 uint32_t reply_error;
287 uint32_t req_message;
288 uint32_t req_control;
289 uint32_t reply_control;
293 uint32_t req_message;
294 uint32_t req_control;
301 uint32_t total_calls;
302 uint32_t pending_calls;
303 uint32_t lockwait_calls;
304 uint32_t pending_lockwait_calls;
305 uint32_t childwrite_calls;
306 uint32_t pending_childwrite_calls;
307 uint32_t memory_used;
308 uint32_t __last_counter; /* hack for control_statistics_all */
309 uint32_t max_hop_count;
310 double max_call_latency;
311 double max_lockwait_latency;
312 double max_childwrite_latency;
316 #define INVALID_GENERATION 1
317 /* table that contains the mapping between a hash value and lmaster
319 struct ctdb_vnn_map {
326 a wire representation of the vnn map
328 struct ctdb_vnn_map_wire {
334 /* a structure that contains the elements required for the write record
337 struct ctdb_write_record {
341 unsigned char blob[1];
344 enum ctdb_freeze_mode {CTDB_FREEZE_NONE, CTDB_FREEZE_PENDING, CTDB_FREEZE_FROZEN};
346 #define CTDB_MONITORING_ACTIVE 0
347 #define CTDB_MONITORING_DISABLED 1
349 /* The different capabilities of the ctdb daemon. */
350 #define CTDB_CAP_RECMASTER 0x00000001
351 #define CTDB_CAP_LMASTER 0x00000002
352 /* This capability is set if CTDB_LVS_PUBLIC_IP is set */
353 #define CTDB_CAP_LVS 0x00000004
355 /* main state of the ctdb daemon */
356 struct ctdb_context {
357 struct event_context *ev;
358 struct timeval ctdbd_start_time;
359 struct timeval last_recovery_started;
360 struct timeval last_recovery_finished;
361 uint32_t recovery_mode;
362 TALLOC_CTX *tickle_update_context;
363 TALLOC_CTX *keepalive_ctx;
364 struct ctdb_tunable tunable;
365 enum ctdb_freeze_mode freeze_mode;
366 struct ctdb_freeze_handle *freeze_handle;
367 struct ctdb_address address;
369 const char *db_directory;
370 const char *db_directory_persistent;
371 const char *transport;
373 char *node_list_file;
374 char *recovery_lock_file;
375 int recovery_lock_fd;
376 uint32_t pnn; /* our own pnn */
378 uint32_t num_connected;
380 uint32_t capabilities;
381 struct idr_context *idr;
383 struct ctdb_node **nodes; /* array of nodes in the cluster - indexed by vnn */
384 struct ctdb_vnn *vnn; /* list of public ip addresses and interfaces */
385 struct ctdb_vnn *single_ip_vnn; /* a structure for the single ip */
387 const struct ctdb_methods *methods; /* transport methods */
388 const struct ctdb_upcalls *upcalls; /* transport upcalls */
389 void *private_data; /* private to transport */
390 struct ctdb_db_context *db_list;
391 struct ctdb_message_list *message_list;
392 struct ctdb_daemon_data daemon;
393 struct ctdb_statistics statistics;
394 struct ctdb_vnn_map *vnn_map;
395 uint32_t num_clients;
396 uint32_t recovery_master;
397 struct ctdb_call_state *pending_calls;
398 struct ctdb_client_ip *client_ip_list;
400 bool do_checkpublicip;
401 void *saved_scheduler_param;
402 struct _trbt_tree_t *server_ids;
403 const char *event_script_dir;
404 const char *notification_script;
405 const char *default_public_interface;
410 struct ctdb_monitor_state *monitor;
411 struct ctdb_log_state *log;
412 int start_as_disabled;
413 uint32_t event_script_timeouts; /* counting how many consecutive times an eventscript has timedout */
414 TALLOC_CTX *eventscripts_ctx; /* a context to hold data for the RUN_EVENTSCRIPTS control */
415 uint32_t *recd_ping_count;
416 TALLOC_CTX *release_ips_ctx; /* a context used to automatically drop all IPs if we fail to recover the node */
417 TALLOC_CTX *script_monitoring_ctx; /* a context where we store results while running the monitor event */
418 TALLOC_CTX *last_monitoring_ctx;
421 struct ctdb_db_context {
422 struct ctdb_db_context *next, *prev;
423 struct ctdb_context *ctdb;
428 struct tdb_wrap *ltdb;
429 struct ctdb_registered_call *calls; /* list of registered calls */
431 struct timed_event *te;
435 #define CTDB_NO_MEMORY(ctdb, p) do { if (!(p)) { \
436 DEBUG(0,("Out of memory for %s at %s\n", #p, __location__)); \
437 ctdb_set_error(ctdb, "Out of memory at %s:%d", __FILE__, __LINE__); \
438 return -1; }} while (0)
440 #define CTDB_NO_MEMORY_VOID(ctdb, p) do { if (!(p)) { \
441 DEBUG(0,("Out of memory for %s at %s\n", #p, __location__)); \
442 ctdb_set_error(ctdb, "Out of memory at %s:%d", __FILE__, __LINE__); \
445 #define CTDB_NO_MEMORY_NULL(ctdb, p) do { if (!(p)) { \
446 DEBUG(0,("Out of memory for %s at %s\n", #p, __location__)); \
447 ctdb_set_error(ctdb, "Out of memory at %s:%d", __FILE__, __LINE__); \
448 return NULL; }} while (0)
450 #define CTDB_NO_MEMORY_FATAL(ctdb, p) do { if (!(p)) { \
451 DEBUG(0,("Out of memory for %s at %s\n", #p, __location__)); \
452 ctdb_fatal(ctdb, "Out of memory in " __location__ ); \
456 the extended header for records in the ltdb
458 struct ctdb_ltdb_header {
465 enum ctdb_controls {CTDB_CONTROL_PROCESS_EXISTS = 0,
466 CTDB_CONTROL_STATISTICS = 1,
468 CTDB_CONTROL_PING = 3,
469 CTDB_CONTROL_GETDBPATH = 4,
470 CTDB_CONTROL_GETVNNMAP = 5,
471 CTDB_CONTROL_SETVNNMAP = 6,
472 CTDB_CONTROL_GET_DEBUG = 7,
473 CTDB_CONTROL_SET_DEBUG = 8,
474 CTDB_CONTROL_GET_DBMAP = 9,
475 CTDB_CONTROL_GET_NODEMAPv4 = 10, /* obsolete */
476 CTDB_CONTROL_SET_DMASTER = 11,
478 CTDB_CONTROL_PULL_DB = 13,
479 CTDB_CONTROL_PUSH_DB = 14,
480 CTDB_CONTROL_GET_RECMODE = 15,
481 CTDB_CONTROL_SET_RECMODE = 16,
482 CTDB_CONTROL_STATISTICS_RESET = 17,
483 CTDB_CONTROL_DB_ATTACH = 18,
484 CTDB_CONTROL_SET_CALL = 19,
485 CTDB_CONTROL_TRAVERSE_START = 20,
486 CTDB_CONTROL_TRAVERSE_ALL = 21,
487 CTDB_CONTROL_TRAVERSE_DATA = 22,
488 CTDB_CONTROL_REGISTER_SRVID = 23,
489 CTDB_CONTROL_DEREGISTER_SRVID = 24,
490 CTDB_CONTROL_GET_DBNAME = 25,
491 CTDB_CONTROL_ENABLE_SEQNUM = 26,
492 CTDB_CONTROL_UPDATE_SEQNUM = 27,
494 CTDB_CONTROL_DUMP_MEMORY = 29,
495 CTDB_CONTROL_GET_PID = 30,
496 CTDB_CONTROL_GET_RECMASTER = 31,
497 CTDB_CONTROL_SET_RECMASTER = 32,
498 CTDB_CONTROL_FREEZE = 33,
499 CTDB_CONTROL_THAW = 34,
500 CTDB_CONTROL_GET_PNN = 35,
501 CTDB_CONTROL_SHUTDOWN = 36,
502 CTDB_CONTROL_GET_MONMODE = 37,
507 CTDB_CONTROL_TAKEOVER_IPv4 = 42, /* obsolete */
508 CTDB_CONTROL_RELEASE_IPv4 = 43, /* obsolete */
509 CTDB_CONTROL_TCP_CLIENT = 44,
510 CTDB_CONTROL_TCP_ADD = 45,
511 CTDB_CONTROL_TCP_REMOVE = 46,
512 CTDB_CONTROL_STARTUP = 47,
513 CTDB_CONTROL_SET_TUNABLE = 48,
514 CTDB_CONTROL_GET_TUNABLE = 49,
515 CTDB_CONTROL_LIST_TUNABLES = 50,
516 CTDB_CONTROL_GET_PUBLIC_IPSv4 = 51, /* obsolete */
517 CTDB_CONTROL_MODIFY_FLAGS = 52,
518 CTDB_CONTROL_GET_ALL_TUNABLES = 53,
519 CTDB_CONTROL_KILL_TCP = 54,
520 CTDB_CONTROL_GET_TCP_TICKLE_LIST = 55,
521 CTDB_CONTROL_SET_TCP_TICKLE_LIST = 56,
522 CTDB_CONTROL_REGISTER_SERVER_ID = 57,
523 CTDB_CONTROL_UNREGISTER_SERVER_ID = 58,
524 CTDB_CONTROL_CHECK_SERVER_ID = 59,
525 CTDB_CONTROL_GET_SERVER_ID_LIST = 60,
526 CTDB_CONTROL_DB_ATTACH_PERSISTENT = 61,
527 CTDB_CONTROL_PERSISTENT_STORE = 62,
528 CTDB_CONTROL_UPDATE_RECORD = 63,
529 CTDB_CONTROL_SEND_GRATIOUS_ARP = 64,
530 CTDB_CONTROL_TRANSACTION_START = 65,
531 CTDB_CONTROL_TRANSACTION_COMMIT = 66,
532 CTDB_CONTROL_WIPE_DATABASE = 67,
534 CTDB_CONTROL_UPTIME = 69,
535 CTDB_CONTROL_START_RECOVERY = 70,
536 CTDB_CONTROL_END_RECOVERY = 71,
537 CTDB_CONTROL_RELOAD_NODES_FILE = 72,
539 CTDB_CONTROL_TRY_DELETE_RECORDS = 74,
540 CTDB_CONTROL_ENABLE_MONITOR = 75,
541 CTDB_CONTROL_DISABLE_MONITOR = 76,
542 CTDB_CONTROL_ADD_PUBLIC_IP = 77,
543 CTDB_CONTROL_DEL_PUBLIC_IP = 78,
544 CTDB_CONTROL_RUN_EVENTSCRIPTS = 79,
545 CTDB_CONTROL_GET_CAPABILITIES = 80,
546 CTDB_CONTROL_START_PERSISTENT_UPDATE = 81,
547 CTDB_CONTROL_CANCEL_PERSISTENT_UPDATE= 82,
548 CTDB_CONTROL_TRANS2_COMMIT = 83,
549 CTDB_CONTROL_TRANS2_FINISHED = 84,
550 CTDB_CONTROL_TRANS2_ERROR = 85,
551 CTDB_CONTROL_TRANS2_COMMIT_RETRY = 86,
552 CTDB_CONTROL_RECD_PING = 87,
553 CTDB_CONTROL_RELEASE_IP = 88,
554 CTDB_CONTROL_TAKEOVER_IP = 89,
555 CTDB_CONTROL_GET_PUBLIC_IPS = 90,
556 CTDB_CONTROL_GET_NODEMAP = 91,
557 CTDB_CONTROL_EVENT_SCRIPT_INIT = 92,
558 CTDB_CONTROL_EVENT_SCRIPT_START = 93,
559 CTDB_CONTROL_EVENT_SCRIPT_STOP = 94,
560 CTDB_CONTROL_EVENT_SCRIPT_FINISHED = 95,
561 CTDB_CONTROL_GET_EVENT_SCRIPT_STATUS = 96,
565 structure passed in set_call control
567 struct ctdb_control_set_call {
574 struct for kill_tcp control
576 struct ctdb_control_killtcp {
577 ctdb_sock_addr src_addr;
578 ctdb_sock_addr dst_addr;
582 struct holding a ctdb_sock_addr and an interface name,
583 used to add/remove public addresses
585 struct ctdb_control_ip_iface {
593 struct holding a ctdb_sock_addr and an interface name,
594 used for send_gratious_arp
596 struct ctdb_control_gratious_arp {
604 struct for tcp_add and tcp_remove controls
606 struct ctdb_control_tcp_vnn {
612 persistent store control - update this record on all other nodes
614 struct ctdb_control_persistent_store {
621 structure used for CTDB_SRVID_NODE_FLAGS_CHANGED
623 struct ctdb_node_flag_change {
630 struct for admin setting a ban
632 struct ctdb_ban_info {
637 enum call_state {CTDB_CALL_WAIT, CTDB_CALL_DONE, CTDB_CALL_ERROR};
639 #define CTDB_LMASTER_ANY 0xffffffff
642 state of a in-progress ctdb call
644 struct ctdb_call_state {
645 struct ctdb_call_state *next, *prev;
646 enum call_state state;
648 struct ctdb_req_call *c;
649 struct ctdb_db_context *ctdb_db;
651 struct ctdb_call *call;
654 void (*fn)(struct ctdb_call_state *);
660 /* used for fetch_lock */
661 struct ctdb_fetch_handle {
662 struct ctdb_db_context *ctdb_db;
665 struct ctdb_ltdb_header header;
671 enum ctdb_operation {
674 CTDB_REQ_DMASTER = 2,
675 CTDB_REPLY_DMASTER = 3,
676 CTDB_REPLY_ERROR = 4,
677 CTDB_REQ_MESSAGE = 5,
679 CTDB_REQ_CONTROL = 7,
680 CTDB_REPLY_CONTROL = 8,
681 CTDB_REQ_KEEPALIVE = 9,
684 #define CTDB_MAGIC 0x43544442 /* CTDB */
685 #define CTDB_VERSION 1
690 struct ctdb_req_header {
693 uint32_t ctdb_version;
701 struct ctdb_req_call {
702 struct ctdb_req_header hdr;
708 uint32_t calldatalen;
709 uint8_t data[1]; /* key[] followed by calldata[] */
712 struct ctdb_reply_call {
713 struct ctdb_req_header hdr;
719 struct ctdb_reply_error {
720 struct ctdb_req_header hdr;
726 struct ctdb_req_dmaster {
727 struct ctdb_req_header hdr;
736 struct ctdb_reply_dmaster {
737 struct ctdb_req_header hdr;
745 struct ctdb_req_message {
746 struct ctdb_req_header hdr;
752 struct ctdb_req_getdbpath {
753 struct ctdb_req_header hdr;
757 struct ctdb_reply_getdbpath {
758 struct ctdb_req_header hdr;
763 struct ctdb_req_control {
764 struct ctdb_req_header hdr;
768 #define CTDB_CTRL_FLAG_NOREPLY 1
774 struct ctdb_reply_control {
775 struct ctdb_req_header hdr;
782 struct ctdb_req_keepalive {
783 struct ctdb_req_header hdr;
787 /* types of failures possible from TRANS2_COMMIT */
788 enum ctdb_trans2_commit_error {
789 CTDB_TRANS2_COMMIT_SUCCESS=0, /* all nodes committed successfully */
790 CTDB_TRANS2_COMMIT_TIMEOUT=1, /* at least one node timed out */
791 CTDB_TRANS2_COMMIT_ALLFAIL=2, /* all nodes failed the commit */
792 CTDB_TRANS2_COMMIT_SOMEFAIL=3 /* some nodes failed the commit, some allowed it */
796 /* internal prototypes */
797 void ctdb_set_error(struct ctdb_context *ctdb, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3);
798 void ctdb_fatal(struct ctdb_context *ctdb, const char *msg);
799 bool ctdb_same_address(struct ctdb_address *a1, struct ctdb_address *a2);
800 int ctdb_parse_address(struct ctdb_context *ctdb,
801 TALLOC_CTX *mem_ctx, const char *str,
802 struct ctdb_address *address);
803 bool ctdb_same_ip(const ctdb_sock_addr *ip1, const ctdb_sock_addr *ip2);
804 bool ctdb_same_sockaddr(const ctdb_sock_addr *ip1, const ctdb_sock_addr *ip2);
805 uint32_t ctdb_hash(const TDB_DATA *key);
806 uint32_t ctdb_hash_string(const char *str);
807 void ctdb_request_call(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
808 void ctdb_request_dmaster(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
809 void ctdb_request_message(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
810 void ctdb_reply_dmaster(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
811 void ctdb_reply_call(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
812 void ctdb_reply_error(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
814 uint32_t ctdb_lmaster(struct ctdb_context *ctdb, const TDB_DATA *key);
815 int ctdb_ltdb_fetch(struct ctdb_db_context *ctdb_db,
816 TDB_DATA key, struct ctdb_ltdb_header *header,
817 TALLOC_CTX *mem_ctx, TDB_DATA *data);
818 int ctdb_ltdb_store(struct ctdb_db_context *ctdb_db, TDB_DATA key,
819 struct ctdb_ltdb_header *header, TDB_DATA data);
820 int32_t ctdb_control_start_persistent_update(struct ctdb_context *ctdb,
821 struct ctdb_req_control *c,
823 int32_t ctdb_control_cancel_persistent_update(struct ctdb_context *ctdb,
824 struct ctdb_req_control *c,
826 void ctdb_queue_packet(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
827 void ctdb_queue_packet_opcode(struct ctdb_context *ctdb, struct ctdb_req_header *hdr, unsigned opcode);
828 int ctdb_ltdb_lock_requeue(struct ctdb_db_context *ctdb_db,
829 TDB_DATA key, struct ctdb_req_header *hdr,
830 void (*recv_pkt)(void *, struct ctdb_req_header *),
831 void *recv_context, bool ignore_generation);
832 int ctdb_ltdb_lock_fetch_requeue(struct ctdb_db_context *ctdb_db,
833 TDB_DATA key, struct ctdb_ltdb_header *header,
834 struct ctdb_req_header *hdr, TDB_DATA *data,
835 void (*recv_pkt)(void *, struct ctdb_req_header *),
836 void *recv_context, bool ignore_generation);
837 void ctdb_input_pkt(struct ctdb_context *ctdb, struct ctdb_req_header *);
839 struct ctdb_call_state *ctdb_call_local_send(struct ctdb_db_context *ctdb_db,
840 struct ctdb_call *call,
841 struct ctdb_ltdb_header *header,
845 int ctdbd_start(struct ctdb_context *ctdb);
846 struct ctdb_call_state *ctdbd_call_send(struct ctdb_db_context *ctdb_db, struct ctdb_call *call);
847 int ctdbd_call_recv(struct ctdb_call_state *state, struct ctdb_call *call);
850 queue a packet for sending
852 int ctdb_queue_send(struct ctdb_queue *queue, uint8_t *data, uint32_t length);
855 setup the fd used by the queue
857 int ctdb_queue_set_fd(struct ctdb_queue *queue, int fd);
860 setup a packet queue on a socket
862 struct ctdb_queue *ctdb_queue_setup(struct ctdb_context *ctdb,
863 TALLOC_CTX *mem_ctx, int fd, int alignment,
865 ctdb_queue_cb_fn_t callback,
869 allocate a packet for use in client<->daemon communication
871 struct ctdb_req_header *_ctdbd_allocate_pkt(struct ctdb_context *ctdb,
873 enum ctdb_operation operation,
874 size_t length, size_t slength,
876 #define ctdbd_allocate_pkt(ctdb, mem_ctx, operation, length, type) \
877 (type *)_ctdbd_allocate_pkt(ctdb, mem_ctx, operation, length, sizeof(type), #type)
879 struct ctdb_req_header *_ctdb_transport_allocate(struct ctdb_context *ctdb,
881 enum ctdb_operation operation,
882 size_t length, size_t slength,
884 #define ctdb_transport_allocate(ctdb, mem_ctx, operation, length, type) \
885 (type *)_ctdb_transport_allocate(ctdb, mem_ctx, operation, length, sizeof(type), #type)
889 lock a record in the ltdb, given a key
891 int ctdb_ltdb_lock(struct ctdb_db_context *ctdb_db, TDB_DATA key);
894 unlock a record in the ltdb, given a key
896 int ctdb_ltdb_unlock(struct ctdb_db_context *ctdb_db, TDB_DATA key);
900 make a ctdb call to the local daemon - async send. Called from client context.
902 This constructs a ctdb_call request and queues it for processing.
903 This call never blocks.
905 struct ctdb_call_state *ctdb_client_call_send(struct ctdb_db_context *ctdb_db,
906 struct ctdb_call *call);
909 make a recv call to the local ctdb daemon - called from client context
911 This is called when the program wants to wait for a ctdb_call to complete and get the
912 results. This call will block unless the call has already completed.
914 int ctdb_client_call_recv(struct ctdb_call_state *state, struct ctdb_call *call);
916 int ctdb_daemon_set_message_handler(struct ctdb_context *ctdb, uint64_t srvid,
917 ctdb_message_fn_t handler,
920 int ctdb_client_send_message(struct ctdb_context *ctdb, uint32_t vnn,
921 uint64_t srvid, TDB_DATA data);
926 int ctdb_daemon_send_message(struct ctdb_context *ctdb, uint32_t pnn,
927 uint64_t srvid, TDB_DATA data);
930 struct lockwait_handle *ctdb_lockwait(struct ctdb_db_context *ctdb_db,
932 void (*callback)(void *), void *private_data);
934 struct ctdb_call_state *ctdb_daemon_call_send(struct ctdb_db_context *ctdb_db,
935 struct ctdb_call *call);
937 int ctdb_daemon_call_recv(struct ctdb_call_state *state, struct ctdb_call *call);
939 struct ctdb_call_state *ctdb_daemon_call_send_remote(struct ctdb_db_context *ctdb_db,
940 struct ctdb_call *call,
941 struct ctdb_ltdb_header *header);
943 int ctdb_call_local(struct ctdb_db_context *ctdb_db, struct ctdb_call *call,
944 struct ctdb_ltdb_header *header, TALLOC_CTX *mem_ctx, TDB_DATA *data,
947 #define ctdb_reqid_find(ctdb, reqid, type) (type *)_ctdb_reqid_find(ctdb, reqid, #type, __location__)
949 void ctdb_recv_raw_pkt(void *p, uint8_t *data, uint32_t length);
951 int ctdb_socket_connect(struct ctdb_context *ctdb);
953 void ctdb_latency(struct ctdb_db_context *ctdb_db, const char *name, double *latency, struct timeval t);
955 uint32_t ctdb_reqid_new(struct ctdb_context *ctdb, void *state);
956 void *_ctdb_reqid_find(struct ctdb_context *ctdb, uint32_t reqid, const char *type, const char *location);
957 void ctdb_reqid_remove(struct ctdb_context *ctdb, uint32_t reqid);
959 void ctdb_request_control(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
960 void ctdb_reply_control(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
962 int ctdb_daemon_send_control(struct ctdb_context *ctdb, uint32_t destnode,
963 uint64_t srvid, uint32_t opcode, uint32_t client_id, uint32_t flags,
965 ctdb_control_callback_fn_t callback,
968 int32_t ctdb_control_db_attach(struct ctdb_context *ctdb, TDB_DATA indata,
969 TDB_DATA *outdata, uint64_t tdb_flags, bool persistent);
971 int ctdb_daemon_set_call(struct ctdb_context *ctdb, uint32_t db_id,
972 ctdb_fn_t fn, int id);
974 int ctdb_control(struct ctdb_context *ctdb, uint32_t destnode, uint64_t srvid,
975 uint32_t opcode, uint32_t flags, TDB_DATA data,
976 TALLOC_CTX *mem_ctx, TDB_DATA *outdata, int32_t *status,
977 struct timeval *timeout, char **errormsg);
978 int ctdb_control_recv(struct ctdb_context *ctdb,
979 struct ctdb_client_control_state *state,
981 TDB_DATA *outdata, int32_t *status, char **errormsg);
983 struct ctdb_client_control_state *
984 ctdb_control_send(struct ctdb_context *ctdb,
985 uint32_t destnode, uint64_t srvid,
986 uint32_t opcode, uint32_t flags, TDB_DATA data,
988 struct timeval *timeout,
994 #define CHECK_CONTROL_DATA_SIZE(size) do { \
995 if (indata.dsize != size) { \
996 DEBUG(0,(__location__ " Invalid data size in opcode %u. Got %u expected %u\n", \
997 opcode, (unsigned)indata.dsize, (unsigned)size)); \
1002 int ctdb_control_getvnnmap(struct ctdb_context *ctdb, uint32_t opcode, TDB_DATA indata, TDB_DATA *outdata);
1003 int ctdb_control_setvnnmap(struct ctdb_context *ctdb, uint32_t opcode, TDB_DATA indata, TDB_DATA *outdata);
1004 int ctdb_control_getdbmap(struct ctdb_context *ctdb, uint32_t opcode, TDB_DATA indata, TDB_DATA *outdata);
1005 int ctdb_control_getnodemapv4(struct ctdb_context *ctdb, uint32_t opcode, TDB_DATA indata, TDB_DATA *outdata);
1006 int ctdb_control_getnodemap(struct ctdb_context *ctdb, uint32_t opcode, TDB_DATA indata, TDB_DATA *outdata);
1007 int ctdb_control_writerecord(struct ctdb_context *ctdb, uint32_t opcode, TDB_DATA indata, TDB_DATA *outdata);
1010 struct ctdb_traverse_start {
1017 structure used to pass record data between the child and parent
1019 struct ctdb_rec_data {
1028 /* structure used for pulldb control */
1029 struct ctdb_control_pulldb {
1034 /* structure used for sending lists of records */
1035 struct ctdb_marshall_buffer {
1041 /* set dmaster control structure */
1042 struct ctdb_control_set_dmaster {
1048 structure for setting a tunable
1050 struct ctdb_control_set_tunable {
1057 structure for getting a tunable
1059 struct ctdb_control_get_tunable {
1065 structure for listing tunables
1067 struct ctdb_control_list_tunable {
1069 /* returns a : separated list of tunable names */
1074 /* table that contains a list of all nodes a ctdb knows about and their
1077 struct ctdb_node_and_flags {
1080 ctdb_sock_addr addr;
1083 struct ctdb_node_map {
1085 struct ctdb_node_and_flags nodes[1];
1088 struct ctdb_node_and_flagsv4 {
1091 struct sockaddr_in sin;
1094 struct ctdb_node_mapv4 {
1096 struct ctdb_node_and_flagsv4 nodes[1];
1099 struct ctdb_control_wipe_database {
1101 uint32_t transaction_id;
1105 state of a in-progress ctdb call in client
1107 struct ctdb_client_call_state {
1108 enum call_state state;
1110 struct ctdb_db_context *ctdb_db;
1111 struct ctdb_call *call;
1113 void (*fn)(struct ctdb_client_call_state *);
1119 int32_t ctdb_control_traverse_start(struct ctdb_context *ctdb, TDB_DATA indata,
1120 TDB_DATA *outdata, uint32_t srcnode);
1121 int32_t ctdb_control_traverse_all(struct ctdb_context *ctdb, TDB_DATA data, TDB_DATA *outdata);
1122 int32_t ctdb_control_traverse_data(struct ctdb_context *ctdb, TDB_DATA data, TDB_DATA *outdata);
1124 int ctdb_dispatch_message(struct ctdb_context *ctdb, uint64_t srvid, TDB_DATA data);
1126 int daemon_register_message_handler(struct ctdb_context *ctdb, uint32_t client_id, uint64_t srvid);
1127 int ctdb_deregister_message_handler(struct ctdb_context *ctdb, uint64_t srvid, void *private_data);
1128 int daemon_deregister_message_handler(struct ctdb_context *ctdb, uint32_t client_id, uint64_t srvid);
1130 int32_t ctdb_ltdb_enable_seqnum(struct ctdb_context *ctdb, uint32_t db_id);
1131 int32_t ctdb_ltdb_update_seqnum(struct ctdb_context *ctdb, uint32_t db_id, uint32_t srcnode);
1133 struct ctdb_rec_data *ctdb_marshall_record(TALLOC_CTX *mem_ctx, uint32_t reqid,
1134 TDB_DATA key, struct ctdb_ltdb_header *, TDB_DATA data);
1136 struct ctdb_rec_data *ctdb_marshall_loop_next(struct ctdb_marshall_buffer *m, struct ctdb_rec_data *r,
1138 struct ctdb_ltdb_header *header,
1139 TDB_DATA *key, TDB_DATA *data);
1141 int32_t ctdb_control_pull_db(struct ctdb_context *ctdb, TDB_DATA indata, TDB_DATA *outdata);
1142 int32_t ctdb_control_push_db(struct ctdb_context *ctdb, TDB_DATA indata);
1143 int32_t ctdb_control_set_dmaster(struct ctdb_context *ctdb, TDB_DATA indata);
1145 int32_t ctdb_control_set_recmode(struct ctdb_context *ctdb,
1146 struct ctdb_req_control *c,
1147 TDB_DATA indata, bool *async_reply,
1148 const char **errormsg);
1149 void ctdb_request_control_reply(struct ctdb_context *ctdb, struct ctdb_req_control *c,
1150 TDB_DATA *outdata, int32_t status, const char *errormsg);
1152 int32_t ctdb_control_freeze(struct ctdb_context *ctdb, struct ctdb_req_control *c, bool *async_reply);
1153 int32_t ctdb_control_thaw(struct ctdb_context *ctdb);
1155 int ctdb_start_recoverd(struct ctdb_context *ctdb);
1156 void ctdb_stop_recoverd(struct ctdb_context *ctdb);
1158 uint32_t ctdb_get_num_active_nodes(struct ctdb_context *ctdb);
1160 void ctdb_disable_monitoring(struct ctdb_context *ctdb);
1161 void ctdb_enable_monitoring(struct ctdb_context *ctdb);
1162 void ctdb_stop_monitoring(struct ctdb_context *ctdb);
1163 void ctdb_start_monitoring(struct ctdb_context *ctdb);
1164 void ctdb_start_tcp_tickle_update(struct ctdb_context *ctdb);
1165 void ctdb_send_keepalive(struct ctdb_context *ctdb, uint32_t destnode);
1166 void ctdb_start_keepalive(struct ctdb_context *ctdb);
1167 void ctdb_stop_keepalive(struct ctdb_context *ctdb);
1168 int32_t ctdb_run_eventscripts(struct ctdb_context *ctdb, struct ctdb_req_control *c, TDB_DATA data, bool *async_reply);
1171 void ctdb_daemon_cancel_controls(struct ctdb_context *ctdb, struct ctdb_node *node);
1172 void ctdb_call_resend_all(struct ctdb_context *ctdb);
1173 void ctdb_node_dead(struct ctdb_node *node);
1174 void ctdb_node_connected(struct ctdb_node *node);
1175 bool ctdb_blocking_freeze(struct ctdb_context *ctdb);
1176 void ctdb_set_scheduler(struct ctdb_context *ctdb);
1177 void ctdb_restore_scheduler(struct ctdb_context *ctdb);
1178 int32_t ctdb_control_takeover_ip(struct ctdb_context *ctdb,
1179 struct ctdb_req_control *c,
1182 int32_t ctdb_control_takeover_ipv4(struct ctdb_context *ctdb,
1183 struct ctdb_req_control *c,
1186 int32_t ctdb_control_release_ip(struct ctdb_context *ctdb,
1187 struct ctdb_req_control *c,
1190 int32_t ctdb_control_release_ipv4(struct ctdb_context *ctdb,
1191 struct ctdb_req_control *c,
1194 int32_t ctdb_control_start_recovery(struct ctdb_context *ctdb,
1195 struct ctdb_req_control *c,
1197 int32_t ctdb_control_end_recovery(struct ctdb_context *ctdb,
1198 struct ctdb_req_control *c,
1201 struct ctdb_public_ipv4 {
1203 struct sockaddr_in sin;
1206 struct ctdb_public_ip {
1208 ctdb_sock_addr addr;
1210 int ctdb_ctrl_takeover_ip(struct ctdb_context *ctdb, struct timeval timeout,
1211 uint32_t destnode, struct ctdb_public_ip *ip);
1212 int ctdb_ctrl_release_ip(struct ctdb_context *ctdb, struct timeval timeout,
1213 uint32_t destnode, struct ctdb_public_ip *ip);
1215 struct ctdb_all_public_ipsv4 {
1217 struct ctdb_public_ipv4 ips[1];
1220 struct ctdb_all_public_ips {
1222 struct ctdb_public_ip ips[1];
1224 int32_t ctdb_control_get_public_ipsv4(struct ctdb_context *ctdb, struct ctdb_req_control *c, TDB_DATA *outdata);
1225 int32_t ctdb_control_get_public_ips(struct ctdb_context *ctdb, struct ctdb_req_control *c, TDB_DATA *outdata);
1226 int ctdb_ctrl_get_public_ips(struct ctdb_context *ctdb,
1227 struct timeval timeout, uint32_t destnode,
1228 TALLOC_CTX *mem_ctx, struct ctdb_all_public_ips **ips);
1229 int ctdb_ctrl_get_public_ipsv4(struct ctdb_context *ctdb,
1230 struct timeval timeout, uint32_t destnode,
1231 TALLOC_CTX *mem_ctx, struct ctdb_all_public_ips **ips);
1234 /* from takeover/system.c */
1235 uint32_t uint16_checksum(uint16_t *data, size_t n);
1236 int ctdb_sys_send_arp(const ctdb_sock_addr *addr, const char *iface);
1237 bool ctdb_sys_have_ip(ctdb_sock_addr *addr);
1238 int ctdb_sys_send_tcp(const ctdb_sock_addr *dest,
1239 const ctdb_sock_addr *src,
1240 uint32_t seq, uint32_t ack, int rst);
1242 int ctdb_set_public_addresses(struct ctdb_context *ctdb, const char *alist);
1243 int ctdb_set_event_script(struct ctdb_context *ctdb, const char *script);
1244 int ctdb_set_event_script_dir(struct ctdb_context *ctdb, const char *script_dir);
1245 int ctdb_set_notification_script(struct ctdb_context *ctdb, const char *script);
1246 int ctdb_takeover_run(struct ctdb_context *ctdb, struct ctdb_node_map *nodemap);
1248 int32_t ctdb_control_tcp_client(struct ctdb_context *ctdb, uint32_t client_id,
1250 int32_t ctdb_control_tcp_add(struct ctdb_context *ctdb, TDB_DATA indata);
1251 int32_t ctdb_control_tcp_remove(struct ctdb_context *ctdb, TDB_DATA indata);
1252 int32_t ctdb_control_startup(struct ctdb_context *ctdb, uint32_t vnn);
1253 int32_t ctdb_control_kill_tcp(struct ctdb_context *ctdb, TDB_DATA indata);
1254 int32_t ctdb_control_send_gratious_arp(struct ctdb_context *ctdb, TDB_DATA indata);
1255 int32_t ctdb_control_get_tcp_tickle_list(struct ctdb_context *ctdb, TDB_DATA indata, TDB_DATA *outdata);
1256 int32_t ctdb_control_set_tcp_tickle_list(struct ctdb_context *ctdb, TDB_DATA indata);
1258 void ctdb_takeover_client_destructor_hook(struct ctdb_client *client);
1259 int ctdb_event_script(struct ctdb_context *ctdb, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3);
1260 int ctdb_event_script_callback(struct ctdb_context *ctdb,
1261 struct timeval timeout,
1262 TALLOC_CTX *mem_ctx,
1263 void (*callback)(struct ctdb_context *, int, void *),
1265 const char *fmt, ...) PRINTF_ATTRIBUTE(6,7);
1266 void ctdb_release_all_ips(struct ctdb_context *ctdb);
1268 void set_nonblocking(int fd);
1269 void set_close_on_exec(int fd);
1271 bool ctdb_recovery_lock(struct ctdb_context *ctdb, bool keep);
1273 int ctdb_set_recovery_lock_file(struct ctdb_context *ctdb, const char *file);
1275 int32_t ctdb_control_get_tunable(struct ctdb_context *ctdb, TDB_DATA indata,
1277 int32_t ctdb_control_set_tunable(struct ctdb_context *ctdb, TDB_DATA indata);
1278 int32_t ctdb_control_list_tunables(struct ctdb_context *ctdb, TDB_DATA *outdata);
1279 int32_t ctdb_control_try_delete_records(struct ctdb_context *ctdb, TDB_DATA indata, TDB_DATA *outdata);
1280 int32_t ctdb_control_add_public_address(struct ctdb_context *ctdb, TDB_DATA indata);
1281 int32_t ctdb_control_del_public_address(struct ctdb_context *ctdb, TDB_DATA indata);
1283 void ctdb_tunables_set_defaults(struct ctdb_context *ctdb);
1285 int32_t ctdb_control_modflags(struct ctdb_context *ctdb, TDB_DATA indata);
1287 int ctdb_ctrl_get_all_tunables(struct ctdb_context *ctdb,
1288 struct timeval timeout,
1290 struct ctdb_tunable *tunables);
1292 void ctdb_start_freeze(struct ctdb_context *ctdb);
1294 bool parse_ip_mask(const char *s, const char *iface, ctdb_sock_addr *addr, unsigned *mask);
1295 bool parse_ip_port(const char *s, ctdb_sock_addr *addr);
1296 bool parse_ip(const char *s, const char *iface, unsigned port, ctdb_sock_addr *addr);
1297 bool parse_ipv4(const char *s, unsigned port, struct sockaddr_in *sin);
1300 int ctdb_sys_open_capture_socket(const char *iface, void **private_data);
1301 int ctdb_sys_close_capture_socket(void *private_data);
1302 int ctdb_sys_read_tcp_packet(int s, void *private_data, ctdb_sock_addr *src, ctdb_sock_addr *dst, uint32_t *ack_seq, uint32_t *seq);
1304 int ctdb_ctrl_killtcp(struct ctdb_context *ctdb,
1305 struct timeval timeout,
1307 struct ctdb_control_killtcp *killtcp);
1309 int ctdb_ctrl_add_public_ip(struct ctdb_context *ctdb,
1310 struct timeval timeout,
1312 struct ctdb_control_ip_iface *pub);
1314 int ctdb_ctrl_del_public_ip(struct ctdb_context *ctdb,
1315 struct timeval timeout,
1317 struct ctdb_control_ip_iface *pub);
1319 int ctdb_ctrl_gratious_arp(struct ctdb_context *ctdb,
1320 struct timeval timeout,
1322 ctdb_sock_addr *addr,
1323 const char *ifname);
1325 int ctdb_ctrl_get_tcp_tickles(struct ctdb_context *ctdb,
1326 struct timeval timeout,
1328 TALLOC_CTX *mem_ctx,
1329 ctdb_sock_addr *addr,
1330 struct ctdb_control_tcp_tickle_list **list);
1333 int32_t ctdb_control_register_server_id(struct ctdb_context *ctdb,
1336 int32_t ctdb_control_check_server_id(struct ctdb_context *ctdb,
1338 int32_t ctdb_control_unregister_server_id(struct ctdb_context *ctdb,
1340 int32_t ctdb_control_get_server_id_list(struct ctdb_context *ctdb,
1342 int32_t ctdb_control_uptime(struct ctdb_context *ctdb,
1345 int ctdb_attach_persistent(struct ctdb_context *ctdb);
1347 int32_t ctdb_control_persistent_store(struct ctdb_context *ctdb,
1348 struct ctdb_req_control *c,
1349 TDB_DATA recdata, bool *async_reply);
1350 int32_t ctdb_control_update_record(struct ctdb_context *ctdb,
1351 struct ctdb_req_control *c, TDB_DATA recdata,
1353 int32_t ctdb_control_trans2_commit(struct ctdb_context *ctdb,
1354 struct ctdb_req_control *c,
1355 TDB_DATA recdata, bool *async_reply);
1357 int32_t ctdb_control_transaction_start(struct ctdb_context *ctdb, uint32_t id);
1358 int32_t ctdb_control_transaction_commit(struct ctdb_context *ctdb, uint32_t id);
1359 int32_t ctdb_control_wipe_database(struct ctdb_context *ctdb, TDB_DATA indata);
1362 int ctdb_vacuum(struct ctdb_context *ctdb, int argc, const char **argv);
1363 int ctdb_repack(struct ctdb_context *ctdb, int argc, const char **argv);
1365 void ctdb_block_signal(int signum);
1366 void ctdb_unblock_signal(int signum);
1367 int32_t ctdb_monitoring_mode(struct ctdb_context *ctdb);
1368 int ctdb_set_child_logging(struct ctdb_context *ctdb);
1371 typedef void (*client_async_callback)(struct ctdb_context *ctdb, uint32_t node_pnn, int32_t res, TDB_DATA outdata, void *callback_data);
1373 struct client_async_data {
1374 enum ctdb_controls opcode;
1375 bool dont_log_errors;
1377 uint32_t fail_count;
1378 client_async_callback callback;
1379 client_async_callback fail_callback;
1380 void *callback_data;
1382 void ctdb_client_async_add(struct client_async_data *data, struct ctdb_client_control_state *state);
1383 int ctdb_client_async_wait(struct ctdb_context *ctdb, struct client_async_data *data);
1384 int ctdb_client_async_control(struct ctdb_context *ctdb,
1385 enum ctdb_controls opcode,
1387 struct timeval timeout,
1388 bool dont_log_errors,
1390 client_async_callback client_callback,
1391 client_async_callback fail_callback,
1392 void *callback_data);
1394 void ctdb_load_nodes_file(struct ctdb_context *ctdb);
1396 int ctdb_control_reload_nodes_file(struct ctdb_context *ctdb, uint32_t opcode);
1398 int32_t ctdb_dump_memory(struct ctdb_context *ctdb, TDB_DATA *outdata);
1399 int32_t ctdb_control_get_capabilities(struct ctdb_context *ctdb, TDB_DATA *outdata);
1401 int32_t ctdb_control_trans2_finished(struct ctdb_context *ctdb,
1402 struct ctdb_req_control *c);
1403 int32_t ctdb_control_trans2_error(struct ctdb_context *ctdb,
1404 struct ctdb_req_control *c);
1406 char *ctdb_addr_to_str(ctdb_sock_addr *addr);
1407 unsigned ctdb_addr_to_port(ctdb_sock_addr *addr);
1408 void ctdb_canonicalize_ip(const ctdb_sock_addr *ip, ctdb_sock_addr *cip);
1410 int32_t ctdb_control_recd_ping(struct ctdb_context *ctdb);
1411 int32_t ctdb_control_set_recmaster(struct ctdb_context *ctdb, uint32_t opcode, TDB_DATA indata);
1413 extern int script_log_level;
1415 int ctdb_ctrl_event_script_init(struct ctdb_context *ctdb);
1416 int ctdb_ctrl_event_script_start(struct ctdb_context *ctdb, const char *name);
1417 int ctdb_ctrl_event_script_stop(struct ctdb_context *ctdb, int32_t res);
1418 int ctdb_ctrl_event_script_finished(struct ctdb_context *ctdb);
1420 int32_t ctdb_control_event_script_init(struct ctdb_context *ctdb);
1421 int32_t ctdb_control_event_script_start(struct ctdb_context *ctdb, TDB_DATA indata);
1422 int32_t ctdb_control_event_script_stop(struct ctdb_context *ctdb, TDB_DATA indata);
1423 int32_t ctdb_control_event_script_finished(struct ctdb_context *ctdb);
1426 int32_t ctdb_control_get_event_script_status(struct ctdb_context *ctdb, TDB_DATA *outdata);
1428 int ctdb_log_event_script_output(struct ctdb_context *ctdb, char *str, uint16_t len);