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>
25 #include <netinet/in.h>
27 /* location of daemon socket */
28 #define CTDB_PATH "/tmp/ctdb.socket"
30 /* default ctdb port number */
31 #define CTDB_PORT 4379
33 /* we must align packets to ensure ctdb works on all architectures (eg. sparc) */
34 #define CTDB_DS_ALIGNMENT 8
37 #define CTDB_NULL_FUNC 0xFF000001
38 #define CTDB_FETCH_FUNC 0xFF000002
40 /* all tunable variables go in here */
42 uint32_t max_redirect_count;
43 uint32_t seqnum_frequency;
44 uint32_t control_timeout;
45 uint32_t traverse_timeout;
46 uint32_t keepalive_interval;
47 uint32_t keepalive_limit;
49 uint32_t recover_timeout;
50 uint32_t recover_interval;
51 uint32_t election_timeout;
52 uint32_t takeover_timeout;
53 uint32_t monitor_interval;
54 uint32_t script_timeout;
55 uint32_t recovery_grace_period;
56 uint32_t recovery_ban_period;
57 uint32_t database_hash_size;
58 uint32_t rerecovery_timeout;
62 an installed ctdb remote call
64 struct ctdb_registered_call {
65 struct ctdb_registered_call *next, *prev;
71 this address structure might need to be generalised later for some
82 #define ctdb_validate_vnn(ctdb, vnn) (((uint32_t)(vnn)) < (ctdb)->num_nodes)
85 /* called from the queue code when a packet comes in. Called with data==NULL
87 typedef void (*ctdb_queue_cb_fn_t)(uint8_t *data, size_t length,
90 /* used for callbacks in ctdb_control requests */
91 typedef void (*ctdb_control_callback_fn_t)(struct ctdb_context *,
92 int32_t status, TDB_DATA data,
97 structure describing a connected client in the daemon
100 struct ctdb_context *ctdb;
102 struct ctdb_queue *queue;
105 struct ctdb_tcp_list *tcp_list;
110 state associated with one node
113 struct ctdb_context *ctdb;
114 struct ctdb_address address;
115 const char *name; /* for debug messages */
116 void *private_data; /* private to transport */
118 #define NODE_FLAGS_DISCONNECTED 0x00000001 /* node isn't connected */
119 #define NODE_FLAGS_UNHEALTHY 0x00000002 /* monitoring says node is unhealthy */
120 #define NODE_FLAGS_PERMANENTLY_DISABLED 0x00000004 /* administrator has disabled node */
121 #define NODE_FLAGS_BANNED 0x00000008 /* recovery daemon has banned the node */
122 #define NODE_FLAGS_DISABLED (NODE_FLAGS_UNHEALTHY|NODE_FLAGS_PERMANENTLY_DISABLED)
123 #define NODE_FLAGS_INACTIVE (NODE_FLAGS_DISCONNECTED|NODE_FLAGS_BANNED)
126 /* used by the dead node monitoring */
131 /* a list of controls pending to this node, so we can time them out quickly
132 if the node becomes disconnected */
133 struct daemon_control_state *pending_controls;
135 /* the public address of this node, if known */
136 const char *public_address;
137 uint8_t public_netmask_bits;
139 /* the node number that has taken over this nodes public address, if any.
140 If not taken over, then set to -1 */
141 int32_t takeover_vnn;
145 transport specific methods
147 struct ctdb_methods {
148 int (*initialise)(struct ctdb_context *); /* initialise transport structures */
149 int (*start)(struct ctdb_context *); /* start protocol processing */
150 int (*add_node)(struct ctdb_node *); /* setup a new node */
151 int (*queue_pkt)(struct ctdb_node *, uint8_t *data, uint32_t length);
152 void *(*allocate_pkt)(TALLOC_CTX *mem_ctx, size_t );
153 void (*shutdown)(struct ctdb_context *); /* shutdown transport */
157 transport calls up to the ctdb layer
159 struct ctdb_upcalls {
160 /* recv_pkt is called when a packet comes in */
161 void (*recv_pkt)(struct ctdb_context *, uint8_t *data, uint32_t length);
163 /* node_dead is called when an attempt to send to a node fails */
164 void (*node_dead)(struct ctdb_node *);
166 /* node_connected is called when a connection to a node is established */
167 void (*node_connected)(struct ctdb_node *);
170 /* list of message handlers - needs to be changed to a more efficient data
171 structure so we can find a message handler given a srvid quickly */
172 struct ctdb_message_list {
173 struct ctdb_context *ctdb;
174 struct ctdb_message_list *next, *prev;
176 ctdb_message_fn_t message_handler;
177 void *message_private;
180 /* additional data required for the daemon mode */
181 struct ctdb_daemon_data {
184 struct ctdb_queue *queue;
188 ctdb status information
190 struct ctdb_statistics {
191 uint32_t num_clients;
194 uint32_t client_packets_sent;
195 uint32_t client_packets_recv;
196 uint32_t node_packets_sent;
197 uint32_t node_packets_recv;
198 uint32_t keepalive_packets_sent;
199 uint32_t keepalive_packets_recv;
203 uint32_t req_dmaster;
204 uint32_t reply_dmaster;
205 uint32_t reply_error;
206 uint32_t req_message;
207 uint32_t req_control;
208 uint32_t reply_control;
212 uint32_t req_message;
213 uint32_t req_control;
220 uint32_t total_calls;
221 uint32_t pending_calls;
222 uint32_t lockwait_calls;
223 uint32_t pending_lockwait_calls;
224 uint32_t memory_used;
225 uint32_t __last_counter; /* hack for control_statistics_all */
226 uint32_t max_hop_count;
227 double max_call_latency;
228 double max_lockwait_latency;
231 /* table that contains the mapping between a hash value and lmaster
233 struct ctdb_vnn_map {
240 a wire representation of the vnn map
242 struct ctdb_vnn_map_wire {
248 /* a structure that contains the elements required for the write record
251 struct ctdb_write_record {
255 unsigned char blob[1];
258 enum ctdb_freeze_mode {CTDB_FREEZE_NONE, CTDB_FREEZE_PENDING, CTDB_FREEZE_FROZEN};
260 #define CTDB_MONITORING_ACTIVE 0
261 #define CTDB_MONITORING_DISABLED 1
263 /* information about IP takeover */
264 struct ctdb_takeover {
266 const char *interface;
267 const char *event_script;
268 TALLOC_CTX *last_ctx;
271 /* main state of the ctdb daemon */
272 struct ctdb_context {
273 struct event_context *ev;
274 uint32_t recovery_mode;
275 uint32_t monitoring_mode;
276 TALLOC_CTX *monitor_context;
277 struct ctdb_tunable tunable;
278 enum ctdb_freeze_mode freeze_mode;
279 struct ctdb_freeze_handle *freeze_handle;
280 struct ctdb_address address;
282 const char *db_directory;
283 const char *transport;
285 char *node_list_file;
286 char *recovery_lock_file;
287 int recovery_lock_fd;
288 uint32_t vnn; /* our own vnn */
290 uint32_t num_connected;
292 struct idr_context *idr;
294 struct ctdb_node **nodes; /* array of nodes in the cluster - indexed by vnn */
296 const struct ctdb_methods *methods; /* transport methods */
297 const struct ctdb_upcalls *upcalls; /* transport upcalls */
298 void *private_data; /* private to transport */
299 struct ctdb_db_context *db_list;
300 struct ctdb_message_list *message_list;
301 struct ctdb_daemon_data daemon;
302 struct ctdb_statistics statistics;
303 struct ctdb_vnn_map *vnn_map;
304 uint32_t num_clients;
305 uint32_t recovery_master;
306 struct ctdb_call_state *pending_calls;
307 struct ctdb_takeover takeover;
308 struct ctdb_tcp_list *tcp_list;
309 struct ctdb_client_ip *client_ip_list;
313 struct ctdb_db_context {
314 struct ctdb_db_context *next, *prev;
315 struct ctdb_context *ctdb;
319 struct tdb_wrap *ltdb;
320 struct ctdb_registered_call *calls; /* list of registered calls */
322 struct timed_event *te;
326 #define CTDB_NO_MEMORY(ctdb, p) do { if (!(p)) { \
327 DEBUG(0,("Out of memory for %s at %s\n", #p, __location__)); \
328 ctdb_set_error(ctdb, "Out of memory at %s:%d", __FILE__, __LINE__); \
329 return -1; }} while (0)
331 #define CTDB_NO_MEMORY_VOID(ctdb, p) do { if (!(p)) { \
332 DEBUG(0,("Out of memory for %s at %s\n", #p, __location__)); \
333 ctdb_set_error(ctdb, "Out of memory at %s:%d", __FILE__, __LINE__); \
336 #define CTDB_NO_MEMORY_NULL(ctdb, p) do { if (!(p)) { \
337 DEBUG(0,("Out of memory for %s at %s\n", #p, __location__)); \
338 ctdb_set_error(ctdb, "Out of memory at %s:%d", __FILE__, __LINE__); \
339 return NULL; }} while (0)
341 #define CTDB_NO_MEMORY_FATAL(ctdb, p) do { if (!(p)) { \
342 DEBUG(0,("Out of memory for %s at %s\n", #p, __location__)); \
343 ctdb_fatal(ctdb, "Out of memory in " __location__ ); \
347 the extended header for records in the ltdb
349 struct ctdb_ltdb_header {
356 enum ctdb_controls {CTDB_CONTROL_PROCESS_EXISTS = 0,
357 CTDB_CONTROL_STATISTICS = 1,
359 CTDB_CONTROL_PING = 3,
360 CTDB_CONTROL_GETDBPATH = 4,
361 CTDB_CONTROL_GETVNNMAP = 5,
362 CTDB_CONTROL_SETVNNMAP = 6,
363 CTDB_CONTROL_GET_DEBUG = 7,
364 CTDB_CONTROL_SET_DEBUG = 8,
365 CTDB_CONTROL_GET_DBMAP = 9,
366 CTDB_CONTROL_GET_NODEMAP = 10,
367 CTDB_CONTROL_SET_DMASTER = 11,
369 CTDB_CONTROL_PULL_DB = 13,
370 CTDB_CONTROL_PUSH_DB = 14,
371 CTDB_CONTROL_GET_RECMODE = 15,
372 CTDB_CONTROL_SET_RECMODE = 16,
373 CTDB_CONTROL_STATISTICS_RESET = 17,
374 CTDB_CONTROL_DB_ATTACH = 18,
375 CTDB_CONTROL_SET_CALL = 19,
376 CTDB_CONTROL_TRAVERSE_START = 20,
377 CTDB_CONTROL_TRAVERSE_ALL = 21,
378 CTDB_CONTROL_TRAVERSE_DATA = 22,
379 CTDB_CONTROL_REGISTER_SRVID = 23,
380 CTDB_CONTROL_DEREGISTER_SRVID = 24,
381 CTDB_CONTROL_GET_DBNAME = 25,
382 CTDB_CONTROL_ENABLE_SEQNUM = 26,
383 CTDB_CONTROL_UPDATE_SEQNUM = 27,
385 CTDB_CONTROL_DUMP_MEMORY = 29,
386 CTDB_CONTROL_GET_PID = 30,
387 CTDB_CONTROL_GET_RECMASTER = 31,
388 CTDB_CONTROL_SET_RECMASTER = 32,
389 CTDB_CONTROL_FREEZE = 33,
390 CTDB_CONTROL_THAW = 34,
391 CTDB_CONTROL_GET_VNN = 35,
392 CTDB_CONTROL_SHUTDOWN = 36,
393 CTDB_CONTROL_GET_MONMODE = 37,
394 CTDB_CONTROL_SET_MONMODE = 38,
395 CTDB_CONTROL_MAX_RSN = 39,
396 CTDB_CONTROL_SET_RSN_NONEMPTY = 40,
397 CTDB_CONTROL_DELETE_LOW_RSN = 41,
398 CTDB_CONTROL_TAKEOVER_IP = 42,
399 CTDB_CONTROL_RELEASE_IP = 43,
400 CTDB_CONTROL_TCP_CLIENT = 44,
401 CTDB_CONTROL_TCP_ADD = 45,
402 CTDB_CONTROL_TCP_REMOVE = 46,
403 CTDB_CONTROL_STARTUP = 47,
404 CTDB_CONTROL_SET_TUNABLE = 48,
405 CTDB_CONTROL_GET_TUNABLE = 49,
406 CTDB_CONTROL_LIST_TUNABLES = 50,
407 CTDB_CONTROL_GET_PUBLIC_IPS = 51,
408 CTDB_CONTROL_MODIFY_FLAGS = 52,
409 CTDB_CONTROL_GET_ALL_TUNABLES = 53,
413 structure passed in ctdb_control_set_rsn_nonempty
415 struct ctdb_control_set_rsn_nonempty {
421 structure passed in ctdb_control_delete_low_rsn
423 struct ctdb_control_delete_low_rsn {
429 structure passed in set_call control
431 struct ctdb_control_set_call {
438 struct for tcp_client control
440 struct ctdb_control_tcp {
441 struct sockaddr_in src;
442 struct sockaddr_in dest;
446 struct for tcp_add and tcp_remove controls
448 struct ctdb_control_tcp_vnn {
450 struct sockaddr_in src;
451 struct sockaddr_in dest;
455 structure used for CTDB_SRVID_NODE_FLAGS_CHANGED
457 struct ctdb_node_flag_change {
463 structure to change flags on a node
465 struct ctdb_node_modflags {
471 struct for admin setting a ban
473 struct ctdb_ban_info {
478 enum call_state {CTDB_CALL_WAIT, CTDB_CALL_DONE, CTDB_CALL_ERROR};
480 #define CTDB_LMASTER_ANY 0xffffffff
483 state of a in-progress ctdb call
485 struct ctdb_call_state {
486 struct ctdb_call_state *next, *prev;
487 enum call_state state;
489 struct ctdb_req_call *c;
490 struct ctdb_db_context *ctdb_db;
492 struct ctdb_call call;
495 void (*fn)(struct ctdb_call_state *);
501 /* used for fetch_lock */
502 struct ctdb_fetch_handle {
503 struct ctdb_db_context *ctdb_db;
506 struct ctdb_ltdb_header header;
512 enum ctdb_operation {
515 CTDB_REQ_DMASTER = 2,
516 CTDB_REPLY_DMASTER = 3,
517 CTDB_REPLY_ERROR = 4,
518 CTDB_REQ_MESSAGE = 5,
520 CTDB_REQ_CONTROL = 7,
521 CTDB_REPLY_CONTROL = 8,
522 CTDB_REQ_KEEPALIVE = 9,
525 #define CTDB_MAGIC 0x43544442 /* CTDB */
526 #define CTDB_VERSION 1
531 struct ctdb_req_header {
534 uint32_t ctdb_version;
542 struct ctdb_req_call {
543 struct ctdb_req_header hdr;
549 uint32_t calldatalen;
550 uint8_t data[1]; /* key[] followed by calldata[] */
553 struct ctdb_reply_call {
554 struct ctdb_req_header hdr;
560 struct ctdb_reply_error {
561 struct ctdb_req_header hdr;
567 struct ctdb_req_dmaster {
568 struct ctdb_req_header hdr;
577 struct ctdb_reply_dmaster {
578 struct ctdb_req_header hdr;
586 struct ctdb_req_message {
587 struct ctdb_req_header hdr;
593 struct ctdb_req_getdbpath {
594 struct ctdb_req_header hdr;
598 struct ctdb_reply_getdbpath {
599 struct ctdb_req_header hdr;
604 struct ctdb_req_control {
605 struct ctdb_req_header hdr;
609 #define CTDB_CTRL_FLAG_NOREPLY 1
615 struct ctdb_reply_control {
616 struct ctdb_req_header hdr;
623 struct ctdb_req_keepalive {
624 struct ctdb_req_header hdr;
627 /* internal prototypes */
628 void ctdb_set_error(struct ctdb_context *ctdb, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3);
629 void ctdb_fatal(struct ctdb_context *ctdb, const char *msg);
630 bool ctdb_same_address(struct ctdb_address *a1, struct ctdb_address *a2);
631 int ctdb_parse_address(struct ctdb_context *ctdb,
632 TALLOC_CTX *mem_ctx, const char *str,
633 struct ctdb_address *address);
634 uint32_t ctdb_hash(const TDB_DATA *key);
635 uint32_t ctdb_hash_string(const char *str);
636 void ctdb_request_call(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
637 void ctdb_request_dmaster(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
638 void ctdb_request_message(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
639 void ctdb_reply_dmaster(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
640 void ctdb_reply_call(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
641 void ctdb_reply_error(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
643 uint32_t ctdb_lmaster(struct ctdb_context *ctdb, const TDB_DATA *key);
644 int ctdb_ltdb_fetch(struct ctdb_db_context *ctdb_db,
645 TDB_DATA key, struct ctdb_ltdb_header *header,
646 TALLOC_CTX *mem_ctx, TDB_DATA *data);
647 int ctdb_ltdb_store(struct ctdb_db_context *ctdb_db, TDB_DATA key,
648 struct ctdb_ltdb_header *header, TDB_DATA data);
649 void ctdb_queue_packet(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
650 int ctdb_ltdb_lock_requeue(struct ctdb_db_context *ctdb_db,
651 TDB_DATA key, struct ctdb_req_header *hdr,
652 void (*recv_pkt)(void *, struct ctdb_req_header *),
653 void *recv_context, bool ignore_generation);
654 int ctdb_ltdb_lock_fetch_requeue(struct ctdb_db_context *ctdb_db,
655 TDB_DATA key, struct ctdb_ltdb_header *header,
656 struct ctdb_req_header *hdr, TDB_DATA *data,
657 void (*recv_pkt)(void *, struct ctdb_req_header *),
658 void *recv_context, bool ignore_generation);
659 void ctdb_input_pkt(struct ctdb_context *ctdb, struct ctdb_req_header *);
661 struct ctdb_call_state *ctdb_call_local_send(struct ctdb_db_context *ctdb_db,
662 struct ctdb_call *call,
663 struct ctdb_ltdb_header *header,
667 int ctdbd_start(struct ctdb_context *ctdb);
668 struct ctdb_call_state *ctdbd_call_send(struct ctdb_db_context *ctdb_db, struct ctdb_call *call);
669 int ctdbd_call_recv(struct ctdb_call_state *state, struct ctdb_call *call);
672 queue a packet for sending
674 int ctdb_queue_send(struct ctdb_queue *queue, uint8_t *data, uint32_t length);
677 setup the fd used by the queue
679 int ctdb_queue_set_fd(struct ctdb_queue *queue, int fd);
682 setup a packet queue on a socket
684 struct ctdb_queue *ctdb_queue_setup(struct ctdb_context *ctdb,
685 TALLOC_CTX *mem_ctx, int fd, int alignment,
687 ctdb_queue_cb_fn_t callback,
691 allocate a packet for use in client<->daemon communication
693 struct ctdb_req_header *_ctdbd_allocate_pkt(struct ctdb_context *ctdb,
695 enum ctdb_operation operation,
696 size_t length, size_t slength,
698 #define ctdbd_allocate_pkt(ctdb, mem_ctx, operation, length, type) \
699 (type *)_ctdbd_allocate_pkt(ctdb, mem_ctx, operation, length, sizeof(type), #type)
701 struct ctdb_req_header *_ctdb_transport_allocate(struct ctdb_context *ctdb,
703 enum ctdb_operation operation,
704 size_t length, size_t slength,
706 #define ctdb_transport_allocate(ctdb, mem_ctx, operation, length, type) \
707 (type *)_ctdb_transport_allocate(ctdb, mem_ctx, operation, length, sizeof(type), #type)
711 lock a record in the ltdb, given a key
713 int ctdb_ltdb_lock(struct ctdb_db_context *ctdb_db, TDB_DATA key);
716 unlock a record in the ltdb, given a key
718 int ctdb_ltdb_unlock(struct ctdb_db_context *ctdb_db, TDB_DATA key);
722 make a ctdb call to the local daemon - async send. Called from client context.
724 This constructs a ctdb_call request and queues it for processing.
725 This call never blocks.
727 struct ctdb_call_state *ctdb_client_call_send(struct ctdb_db_context *ctdb_db,
728 struct ctdb_call *call);
731 make a recv call to the local ctdb daemon - called from client context
733 This is called when the program wants to wait for a ctdb_call to complete and get the
734 results. This call will block unless the call has already completed.
736 int ctdb_client_call_recv(struct ctdb_call_state *state, struct ctdb_call *call);
738 int ctdb_daemon_set_message_handler(struct ctdb_context *ctdb, uint64_t srvid,
739 ctdb_message_fn_t handler,
742 int ctdb_client_send_message(struct ctdb_context *ctdb, uint32_t vnn,
743 uint64_t srvid, TDB_DATA data);
748 int ctdb_daemon_send_message(struct ctdb_context *ctdb, uint32_t vnn,
749 uint64_t srvid, TDB_DATA data);
752 struct lockwait_handle *ctdb_lockwait(struct ctdb_db_context *ctdb_db,
754 void (*callback)(void *), void *private_data);
756 struct ctdb_call_state *ctdb_daemon_call_send(struct ctdb_db_context *ctdb_db,
757 struct ctdb_call *call);
759 int ctdb_daemon_call_recv(struct ctdb_call_state *state, struct ctdb_call *call);
761 struct ctdb_call_state *ctdb_daemon_call_send_remote(struct ctdb_db_context *ctdb_db,
762 struct ctdb_call *call,
763 struct ctdb_ltdb_header *header);
765 int ctdb_call_local(struct ctdb_db_context *ctdb_db, struct ctdb_call *call,
766 struct ctdb_ltdb_header *header, TALLOC_CTX *mem_ctx, TDB_DATA *data,
769 #define ctdb_reqid_find(ctdb, reqid, type) (type *)_ctdb_reqid_find(ctdb, reqid, #type, __location__)
771 void ctdb_recv_raw_pkt(void *p, uint8_t *data, uint32_t length);
773 int ctdb_socket_connect(struct ctdb_context *ctdb);
775 void ctdb_latency(double *latency, struct timeval t);
777 uint32_t ctdb_reqid_new(struct ctdb_context *ctdb, void *state);
778 void *_ctdb_reqid_find(struct ctdb_context *ctdb, uint32_t reqid, const char *type, const char *location);
779 void ctdb_reqid_remove(struct ctdb_context *ctdb, uint32_t reqid);
781 void ctdb_request_control(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
782 void ctdb_reply_control(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
784 int ctdb_daemon_send_control(struct ctdb_context *ctdb, uint32_t destnode,
785 uint64_t srvid, uint32_t opcode, uint32_t client_id, uint32_t flags,
787 ctdb_control_callback_fn_t callback,
790 int32_t ctdb_control_db_attach(struct ctdb_context *ctdb, TDB_DATA indata,
793 int ctdb_daemon_set_call(struct ctdb_context *ctdb, uint32_t db_id,
794 ctdb_fn_t fn, int id);
796 int ctdb_control(struct ctdb_context *ctdb, uint32_t destnode, uint64_t srvid,
797 uint32_t opcode, uint32_t flags, TDB_DATA data,
798 TALLOC_CTX *mem_ctx, TDB_DATA *outdata, int32_t *status,
799 struct timeval *timeout, char **errormsg);
804 #define CHECK_CONTROL_DATA_SIZE(size) do { \
805 if (indata.dsize != size) { \
806 DEBUG(0,(__location__ " Invalid data size in opcode %u. Got %u expected %u\n", \
807 opcode, (unsigned)indata.dsize, (unsigned)size)); \
812 int ctdb_control_getvnnmap(struct ctdb_context *ctdb, uint32_t opcode, TDB_DATA indata, TDB_DATA *outdata);
813 int ctdb_control_setvnnmap(struct ctdb_context *ctdb, uint32_t opcode, TDB_DATA indata, TDB_DATA *outdata);
814 int ctdb_control_getdbmap(struct ctdb_context *ctdb, uint32_t opcode, TDB_DATA indata, TDB_DATA *outdata);
815 int ctdb_control_getnodemap(struct ctdb_context *ctdb, uint32_t opcode, TDB_DATA indata, TDB_DATA *outdata);
816 int ctdb_control_writerecord(struct ctdb_context *ctdb, uint32_t opcode, TDB_DATA indata, TDB_DATA *outdata);
819 struct ctdb_traverse_start {
826 structure used to pass record data between the child and parent
828 struct ctdb_rec_data {
837 /* structure used for pulldb control */
838 struct ctdb_control_pulldb {
843 /* structure used for pulldb control */
844 struct ctdb_control_pulldb_reply {
850 /* set dmaster control structure */
851 struct ctdb_control_set_dmaster {
857 structure for setting a tunable
859 struct ctdb_control_set_tunable {
866 structure for getting a tunable
868 struct ctdb_control_get_tunable {
874 structure for listing tunables
876 struct ctdb_control_list_tunable {
878 /* returns a : separated list of tunable names */
883 /* table that contains a list of all nodes a ctdb knows about and their
886 struct ctdb_node_and_flags {
889 struct sockaddr_in sin;
893 struct ctdb_node_map {
895 struct ctdb_node_and_flags nodes[1];
898 int32_t ctdb_control_traverse_start(struct ctdb_context *ctdb, TDB_DATA indata,
899 TDB_DATA *outdata, uint32_t srcnode);
900 int32_t ctdb_control_traverse_all(struct ctdb_context *ctdb, TDB_DATA data, TDB_DATA *outdata);
901 int32_t ctdb_control_traverse_data(struct ctdb_context *ctdb, TDB_DATA data, TDB_DATA *outdata);
903 int ctdb_dispatch_message(struct ctdb_context *ctdb, uint64_t srvid, TDB_DATA data);
905 int daemon_register_message_handler(struct ctdb_context *ctdb, uint32_t client_id, uint64_t srvid);
906 int ctdb_deregister_message_handler(struct ctdb_context *ctdb, uint64_t srvid, void *private_data);
907 int daemon_deregister_message_handler(struct ctdb_context *ctdb, uint32_t client_id, uint64_t srvid);
909 int32_t ctdb_ltdb_enable_seqnum(struct ctdb_context *ctdb, uint32_t db_id);
910 int32_t ctdb_ltdb_update_seqnum(struct ctdb_context *ctdb, uint32_t db_id, uint32_t srcnode);
911 int32_t ctdb_ltdb_set_seqnum_frequency(struct ctdb_context *ctdb, uint32_t frequency);
913 struct ctdb_rec_data *ctdb_marshall_record(TALLOC_CTX *mem_ctx, uint32_t reqid, TDB_DATA key, TDB_DATA data);
915 int32_t ctdb_control_pull_db(struct ctdb_context *ctdb, TDB_DATA indata, TDB_DATA *outdata);
916 int32_t ctdb_control_push_db(struct ctdb_context *ctdb, TDB_DATA indata);
917 int32_t ctdb_control_set_dmaster(struct ctdb_context *ctdb, TDB_DATA indata);
919 int32_t ctdb_control_set_recmode(struct ctdb_context *ctdb,
920 struct ctdb_req_control *c,
921 TDB_DATA indata, bool *async_reply,
922 const char **errormsg);
923 void ctdb_request_control_reply(struct ctdb_context *ctdb, struct ctdb_req_control *c,
924 TDB_DATA *outdata, int32_t status, const char *errormsg);
926 int32_t ctdb_control_freeze(struct ctdb_context *ctdb, struct ctdb_req_control *c, bool *async_reply);
927 int32_t ctdb_control_thaw(struct ctdb_context *ctdb);
929 int ctdb_start_recoverd(struct ctdb_context *ctdb);
931 uint32_t ctdb_get_num_active_nodes(struct ctdb_context *ctdb);
933 void ctdb_stop_monitoring(struct ctdb_context *ctdb);
934 void ctdb_start_monitoring(struct ctdb_context *ctdb);
935 void ctdb_send_keepalive(struct ctdb_context *ctdb, uint32_t destnode);
937 void ctdb_daemon_cancel_controls(struct ctdb_context *ctdb, struct ctdb_node *node);
938 void ctdb_call_resend_all(struct ctdb_context *ctdb);
939 void ctdb_node_dead(struct ctdb_node *node);
940 void ctdb_node_connected(struct ctdb_node *node);
941 bool ctdb_blocking_freeze(struct ctdb_context *ctdb);
942 int32_t ctdb_control_max_rsn(struct ctdb_context *ctdb, TDB_DATA indata, TDB_DATA *outdata);
943 int32_t ctdb_control_set_rsn_nonempty(struct ctdb_context *ctdb, TDB_DATA indata, TDB_DATA *outdata);
944 int32_t ctdb_control_delete_low_rsn(struct ctdb_context *ctdb, TDB_DATA indata, TDB_DATA *outdata);
945 int ctdb_ctrl_get_max_rsn(struct ctdb_context *ctdb, struct timeval timeout,
946 uint32_t destnode, uint32_t db_id, uint64_t *max_rsn);
947 int ctdb_ctrl_set_rsn_nonempty(struct ctdb_context *ctdb, struct timeval timeout,
948 uint32_t destnode, uint32_t db_id, uint64_t rsn);
949 int ctdb_ctrl_delete_low_rsn(struct ctdb_context *ctdb, struct timeval timeout,
950 uint32_t destnode, uint32_t db_id, uint64_t rsn);
951 void ctdb_set_realtime(bool enable);
952 int32_t ctdb_control_takeover_ip(struct ctdb_context *ctdb,
953 struct ctdb_req_control *c,
956 int32_t ctdb_control_release_ip(struct ctdb_context *ctdb,
957 struct ctdb_req_control *c,
961 struct ctdb_public_ip {
963 uint32_t takeover_vnn;
964 struct sockaddr_in sin;
966 int ctdb_ctrl_takeover_ip(struct ctdb_context *ctdb, struct timeval timeout,
967 uint32_t destnode, struct ctdb_public_ip *ip);
968 int ctdb_ctrl_release_ip(struct ctdb_context *ctdb, struct timeval timeout,
969 uint32_t destnode, struct ctdb_public_ip *ip);
971 struct ctdb_all_public_ips {
973 struct ctdb_public_ip ips[1];
975 int32_t ctdb_control_get_public_ips(struct ctdb_context *ctdb, struct ctdb_req_control *c, TDB_DATA *outdata);
976 int ctdb_ctrl_get_public_ips(struct ctdb_context *ctdb,
977 struct timeval timeout, uint32_t destnode,
978 TALLOC_CTX *mem_ctx, struct ctdb_all_public_ips **ips);
981 /* from takeover/system.c */
982 int ctdb_sys_send_arp(const struct sockaddr_in *saddr, const char *iface);
983 bool ctdb_sys_have_ip(const char *ip);
984 int ctdb_sys_send_tcp(const struct sockaddr_in *dest,
985 const struct sockaddr_in *src,
986 uint32_t seq, uint32_t ack, int rst);
987 int ctdb_sys_kill_tcp(struct event_context *ev,
988 const struct sockaddr_in *dest,
989 const struct sockaddr_in *src);
991 int ctdb_set_public_addresses(struct ctdb_context *ctdb, const char *alist);
992 int ctdb_set_event_script(struct ctdb_context *ctdb, const char *script);
993 int ctdb_takeover_run(struct ctdb_context *ctdb, struct ctdb_node_map *nodemap);
995 int32_t ctdb_control_tcp_client(struct ctdb_context *ctdb, uint32_t client_id,
996 uint32_t srcnode, TDB_DATA indata);
997 int32_t ctdb_control_tcp_add(struct ctdb_context *ctdb, TDB_DATA indata);
998 int32_t ctdb_control_tcp_remove(struct ctdb_context *ctdb, TDB_DATA indata);
999 int32_t ctdb_control_startup(struct ctdb_context *ctdb, uint32_t vnn);
1001 void ctdb_takeover_client_destructor_hook(struct ctdb_client *client);
1002 int ctdb_event_script(struct ctdb_context *ctdb, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3);
1003 int ctdb_event_script_callback(struct ctdb_context *ctdb,
1004 struct timeval timeout,
1005 TALLOC_CTX *mem_ctx,
1006 void (*callback)(struct ctdb_context *, int, void *),
1008 const char *fmt, ...) PRINTF_ATTRIBUTE(6,7);
1009 void ctdb_release_all_ips(struct ctdb_context *ctdb);
1011 void set_nonblocking(int fd);
1012 void set_close_on_exec(int fd);
1014 bool ctdb_recovery_lock(struct ctdb_context *ctdb, bool keep);
1016 int ctdb_set_recovery_lock_file(struct ctdb_context *ctdb, const char *file);
1018 int32_t ctdb_control_get_tunable(struct ctdb_context *ctdb, TDB_DATA indata,
1020 int32_t ctdb_control_set_tunable(struct ctdb_context *ctdb, TDB_DATA indata);
1021 int32_t ctdb_control_list_tunables(struct ctdb_context *ctdb, TDB_DATA *outdata);
1023 void ctdb_tunables_set_defaults(struct ctdb_context *ctdb);
1025 int32_t ctdb_control_modflags(struct ctdb_context *ctdb, TDB_DATA indata);
1027 int ctdb_ctrl_get_all_tunables(struct ctdb_context *ctdb,
1028 struct timeval timeout,
1030 struct ctdb_tunable *tunables);
1032 void ctdb_start_freeze(struct ctdb_context *ctdb);
1034 bool parse_ip_port(const char *s, struct sockaddr_in *ip);