KCC: docstring for kcc.graph.kruskal()
[Samba.git] / ctdb / include / ctdb_private.h
blobb177d6dba8d84c8d28c68aec3b945487e51c25cc
1 /*
2 ctdb database library
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
23 #include "ctdb_client.h"
24 #include <sys/socket.h>
27 * Structures to support SRVID requests and replies
29 struct srvid_request {
30 uint32_t pnn;
31 uint64_t srvid;
34 struct srvid_request_data {
35 uint32_t pnn;
36 uint64_t srvid;
37 uint32_t data;
41 a tcp connection description
42 also used by tcp_add and tcp_remove controls
44 struct ctdb_tcp_connection {
45 ctdb_sock_addr src_addr;
46 ctdb_sock_addr dst_addr;
49 /* the wire representation for a tcp tickle array */
50 struct ctdb_tcp_wire_array {
51 uint32_t num;
52 struct ctdb_tcp_connection connections[1];
53 };
55 /* the list of tcp tickles used by get/set tcp tickle list */
56 struct ctdb_control_tcp_tickle_list {
57 ctdb_sock_addr addr;
58 struct ctdb_tcp_wire_array tickles;
62 array of tcp connections
64 struct ctdb_tcp_array {
65 uint32_t num;
66 struct ctdb_tcp_connection *connections;
67 };
70 /* all tunable variables go in here */
71 struct ctdb_tunable {
72 uint32_t max_redirect_count;
73 uint32_t seqnum_interval; /* unit is ms */
74 uint32_t control_timeout;
75 uint32_t traverse_timeout;
76 uint32_t keepalive_interval;
77 uint32_t keepalive_limit;
78 uint32_t recover_timeout;
79 uint32_t recover_interval;
80 uint32_t election_timeout;
81 uint32_t takeover_timeout;
82 uint32_t monitor_interval;
83 uint32_t tickle_update_interval;
84 uint32_t script_timeout;
85 uint32_t script_timeout_count; /* allow dodgy scripts to hang this many times in a row before we mark the node unhealthy */
86 uint32_t script_unhealthy_on_timeout; /* obsolete */
87 uint32_t recovery_grace_period;
88 uint32_t recovery_ban_period;
89 uint32_t database_hash_size;
90 uint32_t database_max_dead;
91 uint32_t rerecovery_timeout;
92 uint32_t enable_bans;
93 uint32_t deterministic_public_ips;
94 uint32_t reclock_ping_period;
95 uint32_t no_ip_failback;
96 uint32_t disable_ip_failover;
97 uint32_t verbose_memory_names;
98 uint32_t recd_ping_timeout;
99 uint32_t recd_ping_failcount;
100 uint32_t log_latency_ms;
101 uint32_t reclock_latency_ms;
102 uint32_t recovery_drop_all_ips;
103 uint32_t verify_recovery_lock;
104 uint32_t vacuum_interval;
105 uint32_t vacuum_max_run_time;
106 uint32_t repack_limit;
107 uint32_t vacuum_limit;
108 uint32_t max_queue_depth_drop_msg;
109 uint32_t allow_unhealthy_db_read;
110 uint32_t stat_history_interval;
111 uint32_t deferred_attach_timeout;
112 uint32_t vacuum_fast_path_count;
113 uint32_t lcp2_public_ip_assignment;
114 uint32_t allow_client_db_attach;
115 uint32_t recover_pdb_by_seqnum;
116 uint32_t deferred_rebalance_on_node_add;
117 uint32_t fetch_collapse;
118 uint32_t hopcount_make_sticky;
119 uint32_t sticky_duration;
120 uint32_t sticky_pindown;
121 uint32_t no_ip_takeover;
122 uint32_t db_record_count_warn;
123 uint32_t db_record_size_warn;
124 uint32_t db_size_warn;
125 uint32_t pulldb_preallocation_size;
126 uint32_t no_ip_host_on_all_disabled;
127 uint32_t samba3_hack;
128 uint32_t mutex_enabled;
129 uint32_t lock_processes_per_db;
133 an installed ctdb remote call
135 struct ctdb_registered_call {
136 struct ctdb_registered_call *next, *prev;
137 uint32_t id;
138 ctdb_fn_t fn;
142 check that a pnn is valid
144 #define ctdb_validate_pnn(ctdb, pnn) (((uint32_t)(pnn)) < (ctdb)->num_nodes)
147 /* called from the queue code when a packet comes in. Called with data==NULL
148 on error */
149 typedef void (*ctdb_queue_cb_fn_t)(uint8_t *data, size_t length,
150 void *private_data);
152 /* used for callbacks in ctdb_control requests */
153 typedef void (*ctdb_control_callback_fn_t)(struct ctdb_context *,
154 int32_t status, TDB_DATA data,
155 const char *errormsg,
156 void *private_data);
158 structure describing a connected client in the daemon
160 struct ctdb_client {
161 struct ctdb_context *ctdb;
162 int fd;
163 struct ctdb_queue *queue;
164 uint32_t client_id;
165 pid_t pid;
166 struct ctdb_tcp_list *tcp_list;
167 uint32_t db_id;
168 uint32_t num_persistent_updates;
169 struct ctdb_client_notify_list *notify;
172 struct ctdb_iface;
174 /* state associated with a public ip address */
175 struct ctdb_vnn {
176 struct ctdb_vnn *prev, *next;
178 struct ctdb_iface *iface;
179 const char **ifaces;
180 ctdb_sock_addr public_address;
181 uint8_t public_netmask_bits;
183 /* the node number that is serving this public address, if any.
184 If no node serves this ip it is set to -1 */
185 int32_t pnn;
187 /* List of clients to tickle for this public address */
188 struct ctdb_tcp_array *tcp_array;
190 /* whether we need to update the other nodes with changes to our list
191 of connected clients */
192 bool tcp_update_needed;
194 /* a context to hang sending gratious arp events off */
195 TALLOC_CTX *takeover_ctx;
197 struct ctdb_kill_tcp *killtcp;
199 /* Set to true any time an update to this VNN is in flight.
200 This helps to avoid races. */
201 bool update_in_flight;
203 /* If CTDB_CONTROL_DEL_PUBLIC_IP is received for this IP
204 * address then this flag is set. It will be deleted in the
205 * release IP callback. */
206 bool delete_pending;
210 state associated with one node
212 struct ctdb_node {
213 struct ctdb_context *ctdb;
214 ctdb_sock_addr address;
215 const char *name; /* for debug messages */
216 void *private_data; /* private to transport */
217 uint32_t pnn;
218 uint32_t flags;
220 /* used by the dead node monitoring */
221 uint32_t dead_count;
222 uint32_t rx_cnt;
223 uint32_t tx_cnt;
225 /* a list of controls pending to this node, so we can time them out quickly
226 if the node becomes disconnected */
227 struct daemon_control_state *pending_controls;
229 /* used by the recovery daemon when distributing ip addresses
230 across the nodes. it needs to know which public ip's can be handled
231 by each node.
233 struct ctdb_all_public_ips *known_public_ips;
234 struct ctdb_all_public_ips *available_public_ips;
235 /* used by the recovery dameon to track when a node should be banned */
236 struct ctdb_banning_state *ban_state;
240 transport specific methods
242 struct ctdb_methods {
243 int (*initialise)(struct ctdb_context *); /* initialise transport structures */
244 int (*start)(struct ctdb_context *); /* start the transport */
245 int (*add_node)(struct ctdb_node *); /* setup a new node */
246 int (*connect_node)(struct ctdb_node *); /* connect to node */
247 int (*queue_pkt)(struct ctdb_node *, uint8_t *data, uint32_t length);
248 void *(*allocate_pkt)(TALLOC_CTX *mem_ctx, size_t );
249 void (*shutdown)(struct ctdb_context *); /* shutdown transport */
250 void (*restart)(struct ctdb_node *); /* stop and restart the connection */
254 transport calls up to the ctdb layer
256 struct ctdb_upcalls {
257 /* recv_pkt is called when a packet comes in */
258 void (*recv_pkt)(struct ctdb_context *, uint8_t *data, uint32_t length);
260 /* node_dead is called when an attempt to send to a node fails */
261 void (*node_dead)(struct ctdb_node *);
263 /* node_connected is called when a connection to a node is established */
264 void (*node_connected)(struct ctdb_node *);
267 /* list of message handlers - needs to be changed to a more efficient data
268 structure so we can find a message handler given a srvid quickly */
269 struct ctdb_message_list_header {
270 struct ctdb_message_list_header *next, *prev;
271 struct ctdb_context *ctdb;
272 uint64_t srvid;
273 struct ctdb_message_list *m;
275 struct ctdb_message_list {
276 struct ctdb_message_list *next, *prev;
277 struct ctdb_message_list_header *h;
278 ctdb_msg_fn_t message_handler;
279 void *message_private;
282 /* additional data required for the daemon mode */
283 struct ctdb_daemon_data {
284 int sd;
285 char *name;
286 struct ctdb_queue *queue;
290 #define CTDB_UPDATE_STAT(ctdb, counter, value) \
292 if (value > ctdb->statistics.counter) { \
293 ctdb->statistics.counter = c->hopcount; \
295 if (value > ctdb->statistics_current.counter) { \
296 ctdb->statistics_current.counter = c->hopcount; \
300 #define CTDB_INCREMENT_STAT(ctdb, counter) \
302 ctdb->statistics.counter++; \
303 ctdb->statistics_current.counter++; \
306 #define CTDB_DECREMENT_STAT(ctdb, counter) \
308 if (ctdb->statistics.counter > 0) \
309 ctdb->statistics.counter--; \
310 if (ctdb->statistics_current.counter > 0) \
311 ctdb->statistics_current.counter--; \
314 #define CTDB_INCREMENT_DB_STAT(ctdb_db, counter) \
316 ctdb_db->statistics.counter++; \
319 #define CTDB_DECREMENT_DB_STAT(ctdb_db, counter) \
321 if (ctdb_db->statistics.counter > 0) \
322 ctdb_db->statistics.counter--; \
325 #define CTDB_UPDATE_RECLOCK_LATENCY(ctdb, name, counter, value) \
327 if (value > ctdb->statistics.counter.max) \
328 ctdb->statistics.counter.max = value; \
329 if (value > ctdb->statistics_current.counter.max) \
330 ctdb->statistics_current.counter.max = value; \
332 if (ctdb->statistics.counter.num == 0 || \
333 value < ctdb->statistics.counter.min) \
334 ctdb->statistics.counter.min = value; \
335 if (ctdb->statistics_current.counter.num == 0 || \
336 value < ctdb->statistics_current.counter.min) \
337 ctdb->statistics_current.counter.min = value; \
339 ctdb->statistics.counter.total += value; \
340 ctdb->statistics_current.counter.total += value; \
342 ctdb->statistics.counter.num++; \
343 ctdb->statistics_current.counter.num++; \
345 if (ctdb->tunable.reclock_latency_ms != 0) { \
346 if (value*1000 > ctdb->tunable.reclock_latency_ms) { \
347 DEBUG(DEBUG_ERR, \
348 ("High RECLOCK latency %fs for operation %s\n", \
349 value, name)); \
354 #define CTDB_UPDATE_DB_LATENCY(ctdb_db, operation, counter, value) \
356 if (value > ctdb_db->statistics.counter.max) \
357 ctdb_db->statistics.counter.max = value; \
358 if (ctdb_db->statistics.counter.num == 0 || \
359 value < ctdb_db->statistics.counter.min) \
360 ctdb_db->statistics.counter.min = value; \
362 ctdb_db->statistics.counter.total += value; \
363 ctdb_db->statistics.counter.num++; \
365 if (ctdb_db->ctdb->tunable.log_latency_ms != 0) { \
366 if (value*1000 > ctdb_db->ctdb->tunable.log_latency_ms) { \
367 DEBUG(DEBUG_ERR, \
368 ("High latency %.6fs for operation %s on database %s\n",\
369 value, operation, ctdb_db->db_name)); \
374 #define CTDB_UPDATE_LATENCY(ctdb, db, operation, counter, t) \
376 double l = timeval_elapsed(&t); \
378 if (l > ctdb->statistics.counter.max) \
379 ctdb->statistics.counter.max = l; \
380 if (l > ctdb->statistics_current.counter.max) \
381 ctdb->statistics_current.counter.max = l; \
383 if (ctdb->statistics.counter.num == 0 || \
384 l < ctdb->statistics.counter.min) \
385 ctdb->statistics.counter.min = l; \
386 if (ctdb->statistics_current.counter.num == 0 || \
387 l < ctdb->statistics_current.counter.min) \
388 ctdb->statistics_current.counter.min = l; \
390 ctdb->statistics.counter.total += l; \
391 ctdb->statistics_current.counter.total += l; \
393 ctdb->statistics.counter.num++; \
394 ctdb->statistics_current.counter.num++; \
396 if (ctdb->tunable.log_latency_ms != 0) { \
397 if (l*1000 > ctdb->tunable.log_latency_ms) { \
398 DEBUG(DEBUG_WARNING, \
399 ("High latency %.6fs for operation %s on database %s\n",\
400 l, operation, db->db_name)); \
407 /* a structure that contains the elements required for the write record
408 control
410 struct ctdb_write_record {
411 uint32_t dbid;
412 uint32_t keylen;
413 uint32_t datalen;
414 unsigned char blob[1];
417 enum ctdb_freeze_mode {CTDB_FREEZE_NONE, CTDB_FREEZE_PENDING, CTDB_FREEZE_FROZEN};
419 enum ctdb_runstate {
420 CTDB_RUNSTATE_UNKNOWN,
421 CTDB_RUNSTATE_INIT,
422 CTDB_RUNSTATE_SETUP,
423 CTDB_RUNSTATE_FIRST_RECOVERY,
424 CTDB_RUNSTATE_STARTUP,
425 CTDB_RUNSTATE_RUNNING,
426 CTDB_RUNSTATE_SHUTDOWN,
429 const char *runstate_to_string(enum ctdb_runstate runstate);
430 enum ctdb_runstate runstate_from_string(const char *label);
431 void ctdb_set_runstate(struct ctdb_context *ctdb, enum ctdb_runstate runstate);
433 void ctdb_shutdown_sequence(struct ctdb_context *ctdb, int exit_code);
435 #define CTDB_MONITORING_ACTIVE 0
436 #define CTDB_MONITORING_DISABLED 1
438 #define NUM_DB_PRIORITIES 3
439 /* main state of the ctdb daemon */
440 struct ctdb_context {
441 struct tevent_context *ev;
442 struct timeval ctdbd_start_time;
443 struct timeval last_recovery_started;
444 struct timeval last_recovery_finished;
445 uint32_t recovery_mode;
446 TALLOC_CTX *tickle_update_context;
447 TALLOC_CTX *keepalive_ctx;
448 TALLOC_CTX *check_public_ifaces_ctx;
449 struct ctdb_tunable tunable;
450 enum ctdb_freeze_mode freeze_mode[NUM_DB_PRIORITIES+1];
451 struct ctdb_freeze_handle *freeze_handles[NUM_DB_PRIORITIES+1];
452 bool freeze_transaction_started;
453 uint32_t freeze_transaction_id;
454 ctdb_sock_addr *address;
455 const char *name;
456 const char *db_directory;
457 const char *db_directory_persistent;
458 const char *db_directory_state;
459 struct tdb_wrap *db_persistent_health;
460 uint32_t db_persistent_startup_generation;
461 uint64_t db_persistent_check_errors;
462 uint64_t max_persistent_check_errors;
463 const char *transport;
464 char *recovery_lock_file;
465 int recovery_lock_fd;
466 uint32_t pnn; /* our own pnn */
467 uint32_t num_nodes;
468 uint32_t num_connected;
469 unsigned flags;
470 uint32_t capabilities;
471 struct idr_context *idr;
472 int lastid;
473 struct ctdb_node **nodes; /* array of nodes in the cluster - indexed by vnn */
474 struct ctdb_vnn *vnn; /* list of public ip addresses and interfaces */
475 struct ctdb_vnn *single_ip_vnn; /* a structure for the single ip */
476 struct ctdb_iface *ifaces; /* list of local interfaces */
477 char *err_msg;
478 const struct ctdb_methods *methods; /* transport methods */
479 const struct ctdb_upcalls *upcalls; /* transport upcalls */
480 void *private_data; /* private to transport */
481 struct ctdb_db_context *db_list;
482 struct ctdb_message_list_header *message_list_header;
483 struct tdb_context *message_list_indexdb;
484 struct ctdb_daemon_data daemon;
485 struct ctdb_statistics statistics;
486 struct ctdb_statistics statistics_current;
487 #define MAX_STAT_HISTORY 100
488 struct ctdb_statistics statistics_history[MAX_STAT_HISTORY];
489 struct ctdb_vnn_map *vnn_map;
490 uint32_t num_clients;
491 uint32_t recovery_master;
492 struct ctdb_call_state *pending_calls;
493 struct ctdb_client_ip *client_ip_list;
494 bool do_checkpublicip;
495 struct trbt_tree *server_ids;
496 bool do_setsched;
497 const char *event_script_dir;
498 const char *notification_script;
499 const char *default_public_interface;
500 pid_t ctdbd_pid;
501 pid_t recoverd_pid;
502 enum ctdb_runstate runstate;
503 struct ctdb_monitor_state *monitor;
504 int start_as_disabled;
505 int start_as_stopped;
506 bool valgrinding;
507 uint32_t event_script_timeouts; /* counting how many consecutive times an eventscript has timedout */
508 uint32_t *recd_ping_count;
509 TALLOC_CTX *recd_ctx; /* a context used to track recoverd monitoring events */
510 TALLOC_CTX *release_ips_ctx; /* a context used to automatically drop all IPs if we fail to recover the node */
512 TALLOC_CTX *event_script_ctx;
513 int active_events;
515 struct ctdb_event_script_state *current_monitor;
516 struct ctdb_scripts_wire *last_status[CTDB_EVENT_MAX];
518 TALLOC_CTX *banning_ctx;
520 struct ctdb_vacuum_child_context *vacuumers;
522 /* mapping from pid to ctdb_client * */
523 struct ctdb_client_pid_list *client_pids;
525 /* used in the recovery daemon to remember the ip allocation */
526 struct trbt_tree *ip_tree;
528 /* Used to defer db attach requests while in recovery mode */
529 struct ctdb_deferred_attach_context *deferred_attach;
531 /* if we are a child process, do we have a domain socket to send controls on */
532 bool can_send_controls;
534 /* list of event script callback functions that are active */
535 struct event_script_callback *script_callbacks;
537 struct ctdb_reloadips_handle *reload_ips;
539 const char *nodes_file;
540 const char *public_addresses_file;
541 struct trbt_tree *child_processes;
543 /* Used for locking record/db/alldb */
544 struct lock_context *lock_current;
545 struct lock_context *lock_pending;
548 struct ctdb_db_context {
549 struct ctdb_db_context *next, *prev;
550 struct ctdb_context *ctdb;
551 uint32_t db_id;
552 uint32_t priority;
553 bool persistent;
554 bool readonly; /* Do we support read-only delegations ? */
555 bool sticky; /* Do we support sticky records ? */
556 const char *db_name;
557 const char *db_path;
558 struct tdb_wrap *ltdb;
559 struct tdb_context *rottdb; /* ReadOnly tracking TDB */
560 struct ctdb_registered_call *calls; /* list of registered calls */
561 uint32_t seqnum;
562 struct timed_event *seqnum_update;
563 struct ctdb_traverse_local_handle *traverse;
564 struct ctdb_vacuum_handle *vacuum_handle;
565 char *unhealthy_reason;
566 int pending_requests;
567 struct revokechild_handle *revokechild_active;
568 struct ctdb_persistent_state *persistent_state;
569 struct trbt_tree *delete_queue;
570 struct trbt_tree *sticky_records;
571 int (*ctdb_ltdb_store_fn)(struct ctdb_db_context *ctdb_db,
572 TDB_DATA key,
573 struct ctdb_ltdb_header *header,
574 TDB_DATA data);
576 /* used to track which records we are currently fetching
577 so we can avoid sending duplicate fetch requests
579 struct trbt_tree *deferred_fetch;
580 struct trbt_tree *defer_dmaster;
582 struct ctdb_db_statistics statistics;
584 struct lock_context *lock_current;
585 struct lock_context *lock_pending;
586 int lock_num_current;
590 #define CTDB_NO_MEMORY(ctdb, p) do { if (!(p)) { \
591 DEBUG(0,("Out of memory for %s at %s\n", #p, __location__)); \
592 ctdb_set_error(ctdb, "Out of memory at %s:%d", __FILE__, __LINE__); \
593 return -1; }} while (0)
595 #define CTDB_NO_MEMORY_VOID(ctdb, p) do { if (!(p)) { \
596 DEBUG(0,("Out of memory for %s at %s\n", #p, __location__)); \
597 ctdb_set_error(ctdb, "Out of memory at %s:%d", __FILE__, __LINE__); \
598 return; }} while (0)
600 #define CTDB_NO_MEMORY_NULL(ctdb, p) do { if (!(p)) { \
601 DEBUG(0,("Out of memory for %s at %s\n", #p, __location__)); \
602 ctdb_set_error(ctdb, "Out of memory at %s:%d", __FILE__, __LINE__); \
603 return NULL; }} while (0)
605 #define CTDB_NO_MEMORY_FATAL(ctdb, p) do { if (!(p)) { \
606 DEBUG(0,("Out of memory for %s at %s\n", #p, __location__)); \
607 ctdb_fatal(ctdb, "Out of memory in " __location__ ); \
608 }} while (0)
611 structure passed in set_call control
613 struct ctdb_control_set_call {
614 uint32_t db_id;
615 ctdb_fn_t fn;
616 uint32_t id;
620 struct for kill_tcp control
622 struct ctdb_control_killtcp {
623 ctdb_sock_addr src_addr;
624 ctdb_sock_addr dst_addr;
628 struct holding a ctdb_sock_addr and an interface name,
629 used to add/remove public addresses
631 struct ctdb_control_ip_iface {
632 ctdb_sock_addr addr;
633 uint32_t mask;
634 uint32_t len;
635 char iface[1];
639 struct holding a ctdb_sock_addr and an interface name,
640 used for send_gratious_arp
642 struct ctdb_control_gratious_arp {
643 ctdb_sock_addr addr;
644 uint32_t mask;
645 uint32_t len;
646 char iface[1];
650 persistent store control - update this record on all other nodes
652 struct ctdb_control_persistent_store {
653 uint32_t db_id;
654 uint32_t len;
655 uint8_t data[1];
659 structure used for CTDB_SRVID_NODE_FLAGS_CHANGED
661 struct ctdb_node_flag_change {
662 uint32_t pnn;
663 uint32_t new_flags;
664 uint32_t old_flags;
668 struct for admin setting a ban
670 struct ctdb_ban_info {
671 uint32_t pnn;
672 uint32_t ban_time;
675 enum call_state {CTDB_CALL_WAIT, CTDB_CALL_DONE, CTDB_CALL_ERROR};
677 #define CTDB_LMASTER_ANY 0xffffffff
680 state of a in-progress ctdb call
682 struct ctdb_call_state {
683 struct ctdb_call_state *next, *prev;
684 enum call_state state;
685 uint32_t reqid;
686 struct ctdb_req_call *c;
687 struct ctdb_db_context *ctdb_db;
688 const char *errmsg;
689 struct ctdb_call *call;
690 uint32_t generation;
691 struct {
692 void (*fn)(struct ctdb_call_state *);
693 void *private_data;
694 } async;
698 /* used for fetch_lock */
699 struct ctdb_fetch_handle {
700 struct ctdb_db_context *ctdb_db;
701 TDB_DATA key;
702 TDB_DATA *data;
703 struct ctdb_ltdb_header header;
706 /* internal prototypes */
707 void ctdb_set_error(struct ctdb_context *ctdb, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3);
708 void ctdb_fatal(struct ctdb_context *ctdb, const char *msg);
709 void ctdb_die(struct ctdb_context *ctdb, const char *msg);
710 bool ctdb_set_helper(const char *type, char *helper, size_t size,
711 const char *envvar, const char *dir, const char *file);
712 void ctdb_external_trace(void);
713 bool ctdb_same_address(ctdb_sock_addr *a1, ctdb_sock_addr *a2);
714 int ctdb_parse_address(TALLOC_CTX *mem_ctx, const char *str,
715 ctdb_sock_addr *address);
716 bool ctdb_same_ip(const ctdb_sock_addr *ip1, const ctdb_sock_addr *ip2);
717 bool ctdb_same_sockaddr(const ctdb_sock_addr *ip1, const ctdb_sock_addr *ip2);
718 uint32_t ctdb_hash(const TDB_DATA *key);
719 uint32_t *ctdb_key_to_idkey(TALLOC_CTX *mem_ctx, TDB_DATA key);
721 void ctdb_request_call(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
722 void ctdb_request_dmaster(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
723 void ctdb_request_message(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
724 void ctdb_reply_dmaster(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
725 void ctdb_reply_call(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
726 void ctdb_reply_error(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
728 uint32_t ctdb_lmaster(struct ctdb_context *ctdb, const TDB_DATA *key);
729 int ctdb_ltdb_fetch(struct ctdb_db_context *ctdb_db,
730 TDB_DATA key, struct ctdb_ltdb_header *header,
731 TALLOC_CTX *mem_ctx, TDB_DATA *data);
732 int ctdb_ltdb_store(struct ctdb_db_context *ctdb_db, TDB_DATA key,
733 struct ctdb_ltdb_header *header, TDB_DATA data);
734 int ctdb_ltdb_delete(struct ctdb_db_context *ctdb_db, TDB_DATA key);
735 int ctdb_ltdb_fetch_with_header(struct ctdb_db_context *ctdb_db,
736 TDB_DATA key, struct ctdb_ltdb_header *header,
737 TALLOC_CTX *mem_ctx, TDB_DATA *data);
738 int32_t ctdb_control_start_persistent_update(struct ctdb_context *ctdb,
739 struct ctdb_req_control *c,
740 TDB_DATA recdata);
741 int32_t ctdb_control_cancel_persistent_update(struct ctdb_context *ctdb,
742 struct ctdb_req_control *c,
743 TDB_DATA recdata);
744 void ctdb_queue_packet(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
745 void ctdb_queue_packet_opcode(struct ctdb_context *ctdb, struct ctdb_req_header *hdr, unsigned opcode);
746 int ctdb_ltdb_lock_requeue(struct ctdb_db_context *ctdb_db,
747 TDB_DATA key, struct ctdb_req_header *hdr,
748 void (*recv_pkt)(void *, struct ctdb_req_header *),
749 void *recv_context, bool ignore_generation);
750 int ctdb_ltdb_lock_fetch_requeue(struct ctdb_db_context *ctdb_db,
751 TDB_DATA key, struct ctdb_ltdb_header *header,
752 struct ctdb_req_header *hdr, TDB_DATA *data,
753 void (*recv_pkt)(void *, struct ctdb_req_header *),
754 void *recv_context, bool ignore_generation);
755 void ctdb_input_pkt(struct ctdb_context *ctdb, struct ctdb_req_header *);
757 struct ctdb_call_state *ctdb_call_local_send(struct ctdb_db_context *ctdb_db,
758 struct ctdb_call *call,
759 struct ctdb_ltdb_header *header,
760 TDB_DATA *data);
763 int ctdb_start_daemon(struct ctdb_context *ctdb, bool do_fork);
766 queue a packet for sending
768 int ctdb_queue_send(struct ctdb_queue *queue, uint8_t *data, uint32_t length);
771 setup the fd used by the queue
773 int ctdb_queue_set_fd(struct ctdb_queue *queue, int fd);
776 setup a packet queue on a socket
778 struct ctdb_queue *ctdb_queue_setup(struct ctdb_context *ctdb,
779 TALLOC_CTX *mem_ctx, int fd, int alignment,
781 ctdb_queue_cb_fn_t callback,
782 void *private_data, const char *fmt, ...)
783 PRINTF_ATTRIBUTE(7,8);
786 allocate a packet for use in client<->daemon communication
788 struct ctdb_req_header *_ctdbd_allocate_pkt(struct ctdb_context *ctdb,
789 TALLOC_CTX *mem_ctx,
790 enum ctdb_operation operation,
791 size_t length, size_t slength,
792 const char *type);
793 #define ctdbd_allocate_pkt(ctdb, mem_ctx, operation, length, type) \
794 (type *)_ctdbd_allocate_pkt(ctdb, mem_ctx, operation, length, sizeof(type), #type)
796 struct ctdb_req_header *_ctdb_transport_allocate(struct ctdb_context *ctdb,
797 TALLOC_CTX *mem_ctx,
798 enum ctdb_operation operation,
799 size_t length, size_t slength,
800 const char *type);
801 #define ctdb_transport_allocate(ctdb, mem_ctx, operation, length, type) \
802 (type *)_ctdb_transport_allocate(ctdb, mem_ctx, operation, length, sizeof(type), #type)
804 int ctdb_queue_length(struct ctdb_queue *queue);
807 lock a record in the ltdb, given a key
809 int ctdb_ltdb_lock(struct ctdb_db_context *ctdb_db, TDB_DATA key);
812 unlock a record in the ltdb, given a key
814 int ctdb_ltdb_unlock(struct ctdb_db_context *ctdb_db, TDB_DATA key);
817 int ctdb_client_send_message(struct ctdb_context *ctdb, uint32_t vnn,
818 uint64_t srvid, TDB_DATA data);
821 send a ctdb message
823 int ctdb_daemon_send_message(struct ctdb_context *ctdb, uint32_t pnn,
824 uint64_t srvid, TDB_DATA data);
827 int ctdb_daemon_call_recv(struct ctdb_call_state *state, struct ctdb_call *call);
829 struct ctdb_call_state *ctdb_daemon_call_send_remote(struct ctdb_db_context *ctdb_db,
830 struct ctdb_call *call,
831 struct ctdb_ltdb_header *header);
833 int ctdb_call_local(struct ctdb_db_context *ctdb_db, struct ctdb_call *call,
834 struct ctdb_ltdb_header *header, TALLOC_CTX *mem_ctx,
835 TDB_DATA *data, bool updatetdb);
837 #define ctdb_reqid_find(ctdb, reqid, type) (type *)_ctdb_reqid_find(ctdb, reqid, #type, __location__)
839 int ctdb_socket_connect(struct ctdb_context *ctdb);
840 void ctdb_client_read_cb(uint8_t *data, size_t cnt, void *args);
842 #define CTDB_BAD_REQID ((uint32_t)-1)
843 uint32_t ctdb_reqid_new(struct ctdb_context *ctdb, void *state);
844 void *_ctdb_reqid_find(struct ctdb_context *ctdb, uint32_t reqid, const char *type, const char *location);
845 void ctdb_reqid_remove(struct ctdb_context *ctdb, uint32_t reqid);
847 void ctdb_request_control(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
848 void ctdb_reply_control(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
850 int ctdb_daemon_send_control(struct ctdb_context *ctdb, uint32_t destnode,
851 uint64_t srvid, uint32_t opcode, uint32_t client_id, uint32_t flags,
852 TDB_DATA data,
853 ctdb_control_callback_fn_t callback,
854 void *private_data);
856 int32_t ctdb_control_db_attach(struct ctdb_context *ctdb, TDB_DATA indata,
857 TDB_DATA *outdata, uint64_t tdb_flags,
858 bool persistent, uint32_t client_id,
859 struct ctdb_req_control *c,
860 bool *async_reply);
861 int32_t ctdb_control_db_detach(struct ctdb_context *ctdb, TDB_DATA indata,
862 uint32_t client_id);
864 int ctdb_daemon_set_call(struct ctdb_context *ctdb, uint32_t db_id,
865 ctdb_fn_t fn, int id);
867 int ctdb_control(struct ctdb_context *ctdb, uint32_t destnode, uint64_t srvid,
868 uint32_t opcode, uint32_t flags, TDB_DATA data,
869 TALLOC_CTX *mem_ctx, TDB_DATA *outdata, int32_t *status,
870 struct timeval *timeout, char **errormsg);
871 int ctdb_control_recv(struct ctdb_context *ctdb,
872 struct ctdb_client_control_state *state,
873 TALLOC_CTX *mem_ctx,
874 TDB_DATA *outdata, int32_t *status, char **errormsg);
876 struct ctdb_client_control_state *
877 ctdb_control_send(struct ctdb_context *ctdb,
878 uint32_t destnode, uint64_t srvid,
879 uint32_t opcode, uint32_t flags, TDB_DATA data,
880 TALLOC_CTX *mem_ctx,
881 struct timeval *timeout,
882 char **errormsg);
887 #define CHECK_CONTROL_DATA_SIZE(size) do { \
888 if (indata.dsize != size) { \
889 DEBUG(0,(__location__ " Invalid data size in opcode %u. Got %u expected %u\n", \
890 opcode, (unsigned)indata.dsize, (unsigned)size)); \
891 return -1; \
893 } while (0)
895 #define CHECK_CONTROL_MIN_DATA_SIZE(size) do { \
896 if (indata.dsize < size) { \
897 DEBUG(0,(__location__ " Invalid data size in opcode %u. Got %u expected >= %u\n", \
898 opcode, (unsigned)indata.dsize, (unsigned)size)); \
899 return -1; \
901 } while (0)
903 int ctdb_control_getvnnmap(struct ctdb_context *ctdb, uint32_t opcode, TDB_DATA indata, TDB_DATA *outdata);
904 int ctdb_control_setvnnmap(struct ctdb_context *ctdb, uint32_t opcode, TDB_DATA indata, TDB_DATA *outdata);
905 int ctdb_control_getdbmap(struct ctdb_context *ctdb, uint32_t opcode, TDB_DATA indata, TDB_DATA *outdata);
906 int ctdb_control_getnodemap(struct ctdb_context *ctdb, uint32_t opcode, TDB_DATA indata, TDB_DATA *outdata);
907 int ctdb_control_getnodesfile(struct ctdb_context *ctdb, uint32_t opcode, TDB_DATA indata, TDB_DATA *outdata);
910 /* structure used for pulldb control */
911 struct ctdb_control_pulldb {
912 uint32_t db_id;
913 uint32_t lmaster;
916 /* structure used for sending lists of records */
917 struct ctdb_marshall_buffer {
918 uint32_t db_id;
919 uint32_t count;
920 uint8_t data[1];
924 structure for setting a tunable
926 struct ctdb_control_set_tunable {
927 uint32_t value;
928 uint32_t length;
929 uint8_t name[1];
933 structure for getting a tunable
935 struct ctdb_control_get_tunable {
936 uint32_t length;
937 uint8_t name[1];
941 structure for listing tunables
943 struct ctdb_control_list_tunable {
944 uint32_t length;
945 /* returns a : separated list of tunable names */
946 uint8_t data[1];
950 struct ctdb_control_wipe_database {
951 uint32_t db_id;
952 uint32_t transaction_id;
956 state of a in-progress ctdb call in client
958 struct ctdb_client_call_state {
959 enum call_state state;
960 uint32_t reqid;
961 struct ctdb_db_context *ctdb_db;
962 struct ctdb_call *call;
963 struct {
964 void (*fn)(struct ctdb_client_call_state *);
965 void *private_data;
966 } async;
970 int32_t ctdb_control_traverse_start_ext(struct ctdb_context *ctdb,
971 TDB_DATA indata,
972 TDB_DATA *outdata,
973 uint32_t srcnode,
974 uint32_t client_id);
975 int32_t ctdb_control_traverse_start(struct ctdb_context *ctdb, TDB_DATA indata,
976 TDB_DATA *outdata, uint32_t srcnode, uint32_t client_id);
977 int32_t ctdb_control_traverse_all(struct ctdb_context *ctdb, TDB_DATA data, TDB_DATA *outdata);
978 int32_t ctdb_control_traverse_all_ext(struct ctdb_context *ctdb, TDB_DATA data, TDB_DATA *outdata);
979 int32_t ctdb_control_traverse_data(struct ctdb_context *ctdb, TDB_DATA data, TDB_DATA *outdata);
980 int32_t ctdb_control_traverse_kill(struct ctdb_context *ctdb, TDB_DATA indata,
981 TDB_DATA *outdata, uint32_t srcnode);
983 int ctdb_dispatch_message(struct ctdb_context *ctdb, uint64_t srvid, TDB_DATA data);
984 bool ctdb_check_message_handler(struct ctdb_context *ctdb, uint64_t srvid);
986 int daemon_register_message_handler(struct ctdb_context *ctdb, uint32_t client_id, uint64_t srvid);
987 int ctdb_deregister_message_handler(struct ctdb_context *ctdb, uint64_t srvid, void *private_data);
988 int daemon_deregister_message_handler(struct ctdb_context *ctdb, uint32_t client_id, uint64_t srvid);
989 int daemon_check_srvids(struct ctdb_context *ctdb, TDB_DATA indata,
990 TDB_DATA *outdata);
992 int32_t ctdb_ltdb_enable_seqnum(struct ctdb_context *ctdb, uint32_t db_id);
993 int32_t ctdb_ltdb_update_seqnum(struct ctdb_context *ctdb, uint32_t db_id, uint32_t srcnode);
995 struct ctdb_rec_data *ctdb_marshall_record(TALLOC_CTX *mem_ctx, uint32_t reqid,
996 TDB_DATA key, struct ctdb_ltdb_header *, TDB_DATA data);
998 struct ctdb_rec_data *ctdb_marshall_loop_next(struct ctdb_marshall_buffer *m, struct ctdb_rec_data *r,
999 uint32_t *reqid,
1000 struct ctdb_ltdb_header *header,
1001 TDB_DATA *key, TDB_DATA *data);
1003 int32_t ctdb_control_pull_db(struct ctdb_context *ctdb, TDB_DATA indata, TDB_DATA *outdata);
1004 int32_t ctdb_control_push_db(struct ctdb_context *ctdb, TDB_DATA indata);
1006 int32_t ctdb_control_set_recmode(struct ctdb_context *ctdb,
1007 struct ctdb_req_control *c,
1008 TDB_DATA indata, bool *async_reply,
1009 const char **errormsg);
1010 void ctdb_request_control_reply(struct ctdb_context *ctdb, struct ctdb_req_control *c,
1011 TDB_DATA *outdata, int32_t status, const char *errormsg);
1013 int32_t ctdb_control_freeze(struct ctdb_context *ctdb, struct ctdb_req_control *c, bool *async_reply);
1014 int32_t ctdb_control_thaw(struct ctdb_context *ctdb, uint32_t priority,
1015 bool check_recmode);
1017 int ctdb_start_recoverd(struct ctdb_context *ctdb);
1018 void ctdb_stop_recoverd(struct ctdb_context *ctdb);
1020 uint32_t ctdb_get_num_active_nodes(struct ctdb_context *ctdb);
1022 void ctdb_disable_monitoring(struct ctdb_context *ctdb);
1023 void ctdb_enable_monitoring(struct ctdb_context *ctdb);
1024 void ctdb_stop_monitoring(struct ctdb_context *ctdb);
1025 void ctdb_wait_for_first_recovery(struct ctdb_context *ctdb);
1026 int ctdb_tcp_init(struct ctdb_context *ctdb);
1027 int ctdb_ibw_init(struct ctdb_context *ctdb);
1028 void ctdb_start_tcp_tickle_update(struct ctdb_context *ctdb);
1029 void ctdb_send_keepalive(struct ctdb_context *ctdb, uint32_t destnode);
1030 void ctdb_start_keepalive(struct ctdb_context *ctdb);
1031 void ctdb_stop_keepalive(struct ctdb_context *ctdb);
1032 int32_t ctdb_run_eventscripts(struct ctdb_context *ctdb, struct ctdb_req_control *c, TDB_DATA data, bool *async_reply);
1035 void ctdb_daemon_cancel_controls(struct ctdb_context *ctdb, struct ctdb_node *node);
1036 void ctdb_call_resend_all(struct ctdb_context *ctdb);
1037 void ctdb_node_dead(struct ctdb_node *node);
1038 void ctdb_node_connected(struct ctdb_node *node);
1039 bool ctdb_blocking_freeze(struct ctdb_context *ctdb);
1040 bool set_scheduler(void);
1041 void reset_scheduler(void);
1043 struct tevent_signal *ctdb_init_sigchld(struct ctdb_context *ctdb);
1044 void ctdb_track_child(struct ctdb_context *ctdb, pid_t pid);
1045 pid_t ctdb_fork(struct ctdb_context *ctdb);
1046 void ctdb_set_child_info(TALLOC_CTX *mem_ctx, const char *child_name_fmt, ...);
1047 int ctdb_kill(struct ctdb_context *ctdb, pid_t pid, int signum);
1049 int32_t ctdb_control_takeover_ip(struct ctdb_context *ctdb,
1050 struct ctdb_req_control *c,
1051 TDB_DATA indata,
1052 bool *async_reply);
1053 int32_t ctdb_control_release_ip(struct ctdb_context *ctdb,
1054 struct ctdb_req_control *c,
1055 TDB_DATA indata,
1056 bool *async_reply);
1057 int32_t ctdb_control_ipreallocated(struct ctdb_context *ctdb,
1058 struct ctdb_req_control *c,
1059 bool *async_reply);
1060 int32_t ctdb_control_start_recovery(struct ctdb_context *ctdb,
1061 struct ctdb_req_control *c,
1062 bool *async_reply);
1063 int32_t ctdb_control_end_recovery(struct ctdb_context *ctdb,
1064 struct ctdb_req_control *c,
1065 bool *async_reply);
1067 int ctdb_ctrl_takeover_ip(struct ctdb_context *ctdb, struct timeval timeout,
1068 uint32_t destnode, struct ctdb_public_ip *ip);
1069 int ctdb_ctrl_release_ip(struct ctdb_context *ctdb, struct timeval timeout,
1070 uint32_t destnode, struct ctdb_public_ip *ip);
1072 int32_t ctdb_control_get_public_ips(struct ctdb_context *ctdb,
1073 struct ctdb_req_control *c,
1074 TDB_DATA *outdata);
1075 int ctdb_ctrl_get_public_ips(struct ctdb_context *ctdb,
1076 struct timeval timeout,
1077 uint32_t destnode,
1078 TALLOC_CTX *mem_ctx,
1079 struct ctdb_all_public_ips **ips);
1080 #define CTDB_PUBLIC_IP_FLAGS_ONLY_AVAILABLE 0x00010000
1081 int ctdb_ctrl_get_public_ips_flags(struct ctdb_context *ctdb,
1082 struct timeval timeout, uint32_t destnode,
1083 TALLOC_CTX *mem_ctx,
1084 uint32_t flags,
1085 struct ctdb_all_public_ips **ips);
1087 struct ctdb_control_iface_info {
1088 char name[CTDB_IFACE_SIZE+2];
1089 uint16_t link_state;
1090 uint32_t references;
1093 struct ctdb_control_public_ip_info {
1094 struct ctdb_public_ip ip;
1095 uint32_t active_idx;
1096 uint32_t num;
1097 struct ctdb_control_iface_info ifaces[1];
1100 struct ctdb_control_get_ifaces {
1101 uint32_t num;
1102 struct ctdb_control_iface_info ifaces[1];
1105 int32_t ctdb_control_get_public_ip_info(struct ctdb_context *ctdb,
1106 struct ctdb_req_control *c,
1107 TDB_DATA indata,
1108 TDB_DATA *outdata);
1109 int32_t ctdb_control_get_ifaces(struct ctdb_context *ctdb,
1110 struct ctdb_req_control *c,
1111 TDB_DATA *outdata);
1112 int32_t ctdb_control_set_iface_link(struct ctdb_context *ctdb,
1113 struct ctdb_req_control *c,
1114 TDB_DATA indata);
1115 int ctdb_ctrl_get_public_ip_info(struct ctdb_context *ctdb,
1116 struct timeval timeout, uint32_t destnode,
1117 TALLOC_CTX *mem_ctx,
1118 const ctdb_sock_addr *addr,
1119 struct ctdb_control_public_ip_info **info);
1120 int ctdb_ctrl_get_ifaces(struct ctdb_context *ctdb,
1121 struct timeval timeout, uint32_t destnode,
1122 TALLOC_CTX *mem_ctx,
1123 struct ctdb_control_get_ifaces **ifaces);
1124 int ctdb_ctrl_set_iface_link(struct ctdb_context *ctdb,
1125 struct timeval timeout, uint32_t destnode,
1126 TALLOC_CTX *mem_ctx,
1127 const struct ctdb_control_iface_info *info);
1129 /* from takeover/system.c */
1130 uint32_t uint16_checksum(uint16_t *data, size_t n);
1131 int ctdb_sys_send_arp(const ctdb_sock_addr *addr, const char *iface);
1132 bool ctdb_sys_have_ip(ctdb_sock_addr *addr);
1133 char *ctdb_sys_find_ifname(ctdb_sock_addr *addr);
1134 bool ctdb_sys_check_iface_exists(const char *iface);
1135 int ctdb_get_peer_pid(const int fd, pid_t *peer_pid);
1136 int ctdb_sys_send_tcp(const ctdb_sock_addr *dest,
1137 const ctdb_sock_addr *src,
1138 uint32_t seq, uint32_t ack, int rst);
1140 /* Details of a byte range lock */
1141 struct ctdb_lock_info {
1142 ino_t inode;
1143 off_t start, end;
1144 bool waiting;
1145 bool read_only;
1148 char *ctdb_get_process_name(pid_t pid);
1149 int ctdb_set_process_name(const char *name);
1150 bool ctdb_get_lock_info(pid_t req_pid, struct ctdb_lock_info *lock_info);
1151 bool ctdb_get_blocker_pid(struct ctdb_lock_info *reqlock, pid_t *blocker_pid);
1153 typedef void (*client_async_callback)(struct ctdb_context *ctdb, uint32_t node_pnn, int32_t res, TDB_DATA outdata, void *callback_data);
1155 int ctdb_set_public_addresses(struct ctdb_context *ctdb, bool check_addresses);
1156 int ctdb_set_single_public_ip(struct ctdb_context *ctdb,
1157 const char *iface,
1158 const char *ip);
1159 int ctdb_set_notification_script(struct ctdb_context *ctdb, const char *script);
1160 int ctdb_takeover_run(struct ctdb_context *ctdb, struct ctdb_node_map *nodemap,
1161 uint32_t *force_rebalance_nodes,
1162 client_async_callback fail_callback, void *callback_data);
1164 int32_t ctdb_control_tcp_client(struct ctdb_context *ctdb, uint32_t client_id,
1165 TDB_DATA indata);
1166 int32_t ctdb_control_tcp_add(struct ctdb_context *ctdb, TDB_DATA indata, bool tcp_update_needed);
1167 int32_t ctdb_control_tcp_remove(struct ctdb_context *ctdb, TDB_DATA indata);
1168 int32_t ctdb_control_startup(struct ctdb_context *ctdb, uint32_t vnn);
1169 int32_t ctdb_control_kill_tcp(struct ctdb_context *ctdb, TDB_DATA indata);
1170 int32_t ctdb_control_send_gratious_arp(struct ctdb_context *ctdb, TDB_DATA indata);
1171 int32_t ctdb_control_get_tcp_tickle_list(struct ctdb_context *ctdb, TDB_DATA indata, TDB_DATA *outdata);
1172 int32_t ctdb_control_set_tcp_tickle_list(struct ctdb_context *ctdb, TDB_DATA indata);
1174 void ctdb_takeover_client_destructor_hook(struct ctdb_client *client);
1175 int ctdb_event_script(struct ctdb_context *ctdb, enum ctdb_eventscript_call call);
1176 int ctdb_event_script_args(struct ctdb_context *ctdb, enum ctdb_eventscript_call call,
1177 const char *fmt, ...) PRINTF_ATTRIBUTE(3,4);
1178 int ctdb_event_script_callback(struct ctdb_context *ctdb,
1179 TALLOC_CTX *mem_ctx,
1180 void (*callback)(struct ctdb_context *, int, void *),
1181 void *private_data,
1182 enum ctdb_eventscript_call call,
1183 const char *fmt, ...) PRINTF_ATTRIBUTE(6,7);
1184 void ctdb_release_all_ips(struct ctdb_context *ctdb);
1186 void set_nonblocking(int fd);
1187 void set_close_on_exec(int fd);
1189 bool ctdb_recovery_have_lock(struct ctdb_context *ctdb);
1190 bool ctdb_recovery_lock(struct ctdb_context *ctdb);
1191 void ctdb_recovery_unlock(struct ctdb_context *ctdb);
1193 int ctdb_set_recovery_lock_file(struct ctdb_context *ctdb, const char *file);
1195 int32_t ctdb_control_get_tunable(struct ctdb_context *ctdb, TDB_DATA indata,
1196 TDB_DATA *outdata);
1197 int32_t ctdb_control_set_tunable(struct ctdb_context *ctdb, TDB_DATA indata);
1198 int32_t ctdb_control_list_tunables(struct ctdb_context *ctdb, TDB_DATA *outdata);
1199 int32_t ctdb_control_try_delete_records(struct ctdb_context *ctdb, TDB_DATA indata, TDB_DATA *outdata);
1200 int32_t ctdb_control_receive_records(struct ctdb_context *ctdb, TDB_DATA indata, TDB_DATA *outdata);
1201 int32_t ctdb_control_add_public_address(struct ctdb_context *ctdb, TDB_DATA indata);
1202 int32_t ctdb_control_del_public_address(struct ctdb_context *ctdb,
1203 struct ctdb_req_control *c,
1204 TDB_DATA recdata, bool *async_reply);
1206 void ctdb_tunables_set_defaults(struct ctdb_context *ctdb);
1208 int32_t ctdb_control_modflags(struct ctdb_context *ctdb, TDB_DATA indata);
1210 int ctdb_ctrl_get_all_tunables(struct ctdb_context *ctdb,
1211 struct timeval timeout,
1212 uint32_t destnode,
1213 struct ctdb_tunable *tunables);
1215 void ctdb_start_freeze(struct ctdb_context *ctdb, uint32_t priority);
1217 bool parse_ip_mask(const char *s, const char *iface, ctdb_sock_addr *addr, unsigned *mask);
1218 bool parse_ip_port(const char *s, ctdb_sock_addr *addr);
1219 bool parse_ip(const char *s, const char *iface, unsigned port, ctdb_sock_addr *addr);
1220 bool parse_ipv4(const char *s, unsigned port, struct sockaddr_in *sin);
1223 int ctdb_sys_open_capture_socket(const char *iface, void **private_data);
1224 int ctdb_sys_close_capture_socket(void *private_data);
1225 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);
1227 int ctdb_ctrl_killtcp(struct ctdb_context *ctdb,
1228 struct timeval timeout,
1229 uint32_t destnode,
1230 struct ctdb_control_killtcp *killtcp);
1232 int ctdb_ctrl_add_public_ip(struct ctdb_context *ctdb,
1233 struct timeval timeout,
1234 uint32_t destnode,
1235 struct ctdb_control_ip_iface *pub);
1237 int ctdb_ctrl_del_public_ip(struct ctdb_context *ctdb,
1238 struct timeval timeout,
1239 uint32_t destnode,
1240 struct ctdb_control_ip_iface *pub);
1242 int ctdb_ctrl_gratious_arp(struct ctdb_context *ctdb,
1243 struct timeval timeout,
1244 uint32_t destnode,
1245 ctdb_sock_addr *addr,
1246 const char *ifname);
1248 int ctdb_ctrl_get_tcp_tickles(struct ctdb_context *ctdb,
1249 struct timeval timeout,
1250 uint32_t destnode,
1251 TALLOC_CTX *mem_ctx,
1252 ctdb_sock_addr *addr,
1253 struct ctdb_control_tcp_tickle_list **list);
1256 int32_t ctdb_control_register_server_id(struct ctdb_context *ctdb,
1257 uint32_t client_id,
1258 TDB_DATA indata);
1259 int32_t ctdb_control_check_server_id(struct ctdb_context *ctdb,
1260 TDB_DATA indata);
1261 int32_t ctdb_control_unregister_server_id(struct ctdb_context *ctdb,
1262 TDB_DATA indata);
1263 int32_t ctdb_control_get_server_id_list(struct ctdb_context *ctdb,
1264 TDB_DATA *outdata);
1265 int32_t ctdb_control_uptime(struct ctdb_context *ctdb,
1266 TDB_DATA *outdata);
1268 int ctdb_attach_databases(struct ctdb_context *ctdb);
1270 int32_t ctdb_control_persistent_store(struct ctdb_context *ctdb,
1271 struct ctdb_req_control *c,
1272 TDB_DATA recdata, bool *async_reply);
1273 int32_t ctdb_control_update_record(struct ctdb_context *ctdb,
1274 struct ctdb_req_control *c, TDB_DATA recdata,
1275 bool *async_reply);
1277 int32_t ctdb_control_trans3_commit(struct ctdb_context *ctdb,
1278 struct ctdb_req_control *c,
1279 TDB_DATA recdata, bool *async_reply);
1281 void ctdb_persistent_finish_trans3_commits(struct ctdb_context *ctdb);
1283 int32_t ctdb_control_transaction_start(struct ctdb_context *ctdb, uint32_t id);
1284 int32_t ctdb_control_transaction_commit(struct ctdb_context *ctdb, uint32_t id);
1285 int32_t ctdb_control_transaction_cancel(struct ctdb_context *ctdb);
1286 int32_t ctdb_control_wipe_database(struct ctdb_context *ctdb, TDB_DATA indata);
1287 int32_t ctdb_control_db_set_healthy(struct ctdb_context *ctdb, TDB_DATA indata);
1288 int32_t ctdb_control_db_get_health(struct ctdb_context *ctdb,
1289 TDB_DATA indata,
1290 TDB_DATA *outdata);
1293 int ctdb_repack(struct ctdb_context *ctdb, int argc, const char **argv);
1295 int32_t ctdb_monitoring_mode(struct ctdb_context *ctdb);
1296 bool ctdb_stopped_monitoring(struct ctdb_context *ctdb);
1297 int ctdb_set_child_logging(struct ctdb_context *ctdb);
1298 void lockdown_memory(bool valgrinding);
1300 struct client_async_data {
1301 enum ctdb_controls opcode;
1302 bool dont_log_errors;
1303 uint32_t count;
1304 uint32_t fail_count;
1305 client_async_callback callback;
1306 client_async_callback fail_callback;
1307 void *callback_data;
1309 void ctdb_client_async_add(struct client_async_data *data, struct ctdb_client_control_state *state);
1310 int ctdb_client_async_wait(struct ctdb_context *ctdb, struct client_async_data *data);
1311 int ctdb_client_async_control(struct ctdb_context *ctdb,
1312 enum ctdb_controls opcode,
1313 uint32_t *nodes,
1314 uint64_t srvid,
1315 struct timeval timeout,
1316 bool dont_log_errors,
1317 TDB_DATA data,
1318 client_async_callback client_callback,
1319 client_async_callback fail_callback,
1320 void *callback_data);
1322 struct ctdb_node_map *
1323 ctdb_node_list_to_map(struct ctdb_node **nodes, uint32_t num_nodes,
1324 TALLOC_CTX *mem_ctx);
1325 struct ctdb_node_map *ctdb_read_nodes_file(TALLOC_CTX *mem_ctx,
1326 const char *nlist);
1327 void ctdb_load_nodes_file(struct ctdb_context *ctdb);
1329 int ctdb_control_reload_nodes_file(struct ctdb_context *ctdb, uint32_t opcode);
1331 int32_t ctdb_dump_memory(struct ctdb_context *ctdb, TDB_DATA *outdata);
1332 int32_t ctdb_control_get_capabilities(struct ctdb_context *ctdb, TDB_DATA *outdata);
1334 char *ctdb_addr_to_str(ctdb_sock_addr *addr);
1335 unsigned ctdb_addr_to_port(ctdb_sock_addr *addr);
1336 void ctdb_canonicalize_ip(const ctdb_sock_addr *ip, ctdb_sock_addr *cip);
1338 int32_t ctdb_control_recd_ping(struct ctdb_context *ctdb);
1339 int32_t ctdb_control_set_recmaster(struct ctdb_context *ctdb, uint32_t opcode, TDB_DATA indata);
1341 extern int script_log_level;
1342 extern bool fast_start;
1343 extern const char *ctdbd_pidfile;
1345 int32_t ctdb_control_get_event_script_status(struct ctdb_context *ctdb,
1346 uint32_t call_type,
1347 TDB_DATA *outdata);
1349 int ctdb_ctrl_report_recd_lock_latency(struct ctdb_context *ctdb, struct timeval timeout, double latency);
1351 int32_t ctdb_control_stop_node(struct ctdb_context *ctdb);
1352 int32_t ctdb_control_continue_node(struct ctdb_context *ctdb);
1354 void ctdb_stop_vacuuming(struct ctdb_context *ctdb);
1355 int ctdb_vacuum_init(struct ctdb_db_context *ctdb_db);
1357 int32_t ctdb_control_enable_script(struct ctdb_context *ctdb, TDB_DATA indata);
1358 int32_t ctdb_control_disable_script(struct ctdb_context *ctdb, TDB_DATA indata);
1360 void ctdb_local_node_got_banned(struct ctdb_context *ctdb);
1361 int32_t ctdb_control_set_ban_state(struct ctdb_context *ctdb, TDB_DATA indata);
1362 int32_t ctdb_control_get_ban_state(struct ctdb_context *ctdb, TDB_DATA *outdata);
1363 int32_t ctdb_control_set_db_priority(struct ctdb_context *ctdb, TDB_DATA indata,
1364 uint32_t client_id);
1365 void ctdb_ban_self(struct ctdb_context *ctdb);
1367 int32_t ctdb_control_register_notify(struct ctdb_context *ctdb, uint32_t client_id, TDB_DATA indata);
1369 int32_t ctdb_control_deregister_notify(struct ctdb_context *ctdb, uint32_t client_id, TDB_DATA indata);
1371 struct ctdb_log_state *ctdb_vfork_with_logging(TALLOC_CTX *mem_ctx,
1372 struct ctdb_context *ctdb,
1373 const char *log_prefix,
1374 const char *helper,
1375 int helper_argc,
1376 const char **helper_argv,
1377 void (*logfn)(const char *, uint16_t, void *),
1378 void *logfn_private, pid_t *pid);
1381 int32_t ctdb_control_process_exists(struct ctdb_context *ctdb, pid_t pid);
1382 struct ctdb_client *ctdb_find_client_by_pid(struct ctdb_context *ctdb, pid_t pid);
1384 int32_t ctdb_control_get_db_seqnum(struct ctdb_context *ctdb,
1385 TDB_DATA indata,
1386 TDB_DATA *outdata);
1388 int ctdb_load_persistent_health(struct ctdb_context *ctdb,
1389 struct ctdb_db_context *ctdb_db);
1390 int ctdb_update_persistent_health(struct ctdb_context *ctdb,
1391 struct ctdb_db_context *ctdb_db,
1392 const char *reason,/* NULL means healthy */
1393 int num_healthy_nodes);
1394 int ctdb_recheck_persistent_health(struct ctdb_context *ctdb);
1396 void ctdb_run_notification_script(struct ctdb_context *ctdb, const char *event);
1398 int verify_remote_ip_allocation(struct ctdb_context *ctdb,
1399 struct ctdb_all_public_ips *ips,
1400 uint32_t pnn);
1401 int update_ip_assignment_tree(struct ctdb_context *ctdb,
1402 struct ctdb_public_ip *ip);
1404 int ctdb_init_tevent_logging(struct ctdb_context *ctdb);
1406 int ctdb_statistics_init(struct ctdb_context *ctdb);
1408 int32_t ctdb_control_get_stat_history(struct ctdb_context *ctdb,
1409 struct ctdb_req_control *c,
1410 TDB_DATA *outdata);
1412 int ctdb_deferred_drop_all_ips(struct ctdb_context *ctdb);
1414 int ctdb_process_deferred_attach(struct ctdb_context *ctdb);
1417 * structure to pass to a schedule_for_deletion_control
1419 struct ctdb_control_schedule_for_deletion {
1420 uint32_t db_id;
1421 struct ctdb_ltdb_header hdr;
1422 uint32_t keylen;
1423 uint8_t key[1]; /* key[] */
1426 int32_t ctdb_control_schedule_for_deletion(struct ctdb_context *ctdb,
1427 TDB_DATA indata);
1430 int32_t ctdb_local_schedule_for_deletion(struct ctdb_db_context *ctdb_db,
1431 const struct ctdb_ltdb_header *hdr,
1432 TDB_DATA key);
1434 void ctdb_local_remove_from_delete_queue(struct ctdb_db_context *ctdb_db,
1435 const struct ctdb_ltdb_header *hdr,
1436 const TDB_DATA key);
1438 struct ctdb_ltdb_header *ctdb_header_from_record_handle(struct ctdb_record_handle *h);
1440 int ctdb_trackingdb_add_pnn(struct ctdb_context *ctdb, TDB_DATA *data, uint32_t pnn);
1442 typedef void (*ctdb_trackingdb_cb)(struct ctdb_context *ctdb, uint32_t pnn, void *private_data);
1444 void ctdb_trackingdb_traverse(struct ctdb_context *ctdb, TDB_DATA data, ctdb_trackingdb_cb cb, void *private_data);
1446 int ctdb_start_revoke_ro_record(struct ctdb_context *ctdb, struct ctdb_db_context *ctdb_db, TDB_DATA key, struct ctdb_ltdb_header *header, TDB_DATA data);
1448 typedef void (*deferred_requeue_fn)(void *call_context, struct ctdb_req_header *hdr);
1450 int ctdb_add_revoke_deferred_call(struct ctdb_context *ctdb, struct ctdb_db_context *ctdb_db, TDB_DATA key, struct ctdb_req_header *hdr, deferred_requeue_fn fn, void *call_context);
1452 int ctdb_set_db_readonly(struct ctdb_context *ctdb, struct ctdb_db_context *ctdb_db);
1454 int ctdb_null_func(struct ctdb_call_info *call);
1456 int ctdb_fetch_func(struct ctdb_call_info *call);
1458 int ctdb_fetch_with_header_func(struct ctdb_call_info *call);
1460 int32_t ctdb_control_get_db_statistics(struct ctdb_context *ctdb,
1461 uint32_t db_id,
1462 TDB_DATA *outdata);
1464 int ctdb_set_db_sticky(struct ctdb_context *ctdb, struct ctdb_db_context *ctdb_db);
1467 description for a message to reload all ips via recovery master/daemon
1469 struct reloadips_all_reply {
1470 uint32_t pnn;
1471 uint64_t srvid;
1474 int32_t ctdb_control_reload_public_ips(struct ctdb_context *ctdb, struct ctdb_req_control *c, bool *async_reply);
1476 /* from server/ctdb_lock.c */
1477 struct lock_request;
1479 int ctdb_lockall_mark_prio(struct ctdb_context *ctdb, uint32_t priority);
1480 int ctdb_lockall_unmark_prio(struct ctdb_context *ctdb, uint32_t priority);
1482 struct lock_request *ctdb_lock_record(TALLOC_CTX *mem_ctx,
1483 struct ctdb_db_context *ctdb_db,
1484 TDB_DATA key,
1485 bool auto_mark,
1486 void (*callback)(void *, bool),
1487 void *private_data);
1489 struct lock_request *ctdb_lock_db(TALLOC_CTX *mem_ctx,
1490 struct ctdb_db_context *ctdb_db,
1491 bool auto_mark,
1492 void (*callback)(void *, bool),
1493 void *private_data);
1495 struct lock_request *ctdb_lock_alldb_prio(TALLOC_CTX *mem_ctx,
1496 struct ctdb_context *ctdb,
1497 uint32_t priority,
1498 bool auto_mark,
1499 void (*callback)(void *, bool),
1500 void *private_data);
1502 struct lock_request *ctdb_lock_alldb(TALLOC_CTX *mem_ctx,
1503 struct ctdb_context *ctdb,
1504 bool auto_mark,
1505 void (*callback)(void *, bool),
1506 void *private_data);
1508 int mkdir_p(const char *dir, int mode);
1509 void mkdir_p_or_die(const char *dir, int mode);
1511 ssize_t sys_read(int fd, void *buf, size_t count);
1512 ssize_t sys_write(int fd, const void *buf, size_t count);
1514 #endif