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 array of tcp connections
29 struct ctdb_tcp_array {
31 struct ctdb_connection *connections;
35 an installed ctdb remote call
37 struct ctdb_registered_call {
38 struct ctdb_registered_call *next, *prev;
44 check that a pnn is valid
46 #define ctdb_validate_pnn(ctdb, pnn) (((uint32_t)(pnn)) < (ctdb)->num_nodes)
49 /* called from the queue code when a packet comes in. Called with data==NULL
51 typedef void (*ctdb_queue_cb_fn_t)(uint8_t *data, size_t length,
54 /* used for callbacks in ctdb_control requests */
55 typedef void (*ctdb_control_callback_fn_t)(struct ctdb_context *,
56 int32_t status, TDB_DATA data,
60 structure describing a connected client in the daemon
63 struct ctdb_context *ctdb;
65 struct ctdb_queue *queue;
68 struct ctdb_tcp_list *tcp_list;
70 uint32_t num_persistent_updates;
71 struct ctdb_client_notify_list *notify;
74 /* state associated with a public ip address */
76 struct ctdb_vnn *prev, *next;
78 struct ctdb_interface *iface;
80 ctdb_sock_addr public_address;
81 uint8_t public_netmask_bits;
83 /* the node number that is serving this public address, if any.
84 If no node serves this ip it is set to -1 */
87 /* List of clients to tickle for this public address */
88 struct ctdb_tcp_array *tcp_array;
90 /* whether we need to update the other nodes with changes to our list
91 of connected clients */
92 bool tcp_update_needed;
94 /* a context to hang sending gratious arp events off */
95 TALLOC_CTX *takeover_ctx;
97 struct ctdb_kill_tcp *killtcp;
99 /* Set to true any time an update to this VNN is in flight.
100 This helps to avoid races. */
101 bool update_in_flight;
103 /* If CTDB_CONTROL_DEL_PUBLIC_IP is received for this IP
104 * address then this flag is set. It will be deleted in the
105 * release IP callback. */
110 state associated with one node
113 struct ctdb_context *ctdb;
114 ctdb_sock_addr address;
115 const char *name; /* for debug messages */
116 void *private_data; /* private to transport */
120 /* used by the dead node monitoring */
125 /* a list of controls pending to this node, so we can time them out quickly
126 if the node becomes disconnected */
127 struct daemon_control_state *pending_controls;
129 /* used by the recovery dameon to track when a node should be banned */
130 struct ctdb_banning_state *ban_state;
134 transport specific methods
136 struct ctdb_methods {
137 int (*initialise)(struct ctdb_context *); /* initialise transport structures */
138 int (*start)(struct ctdb_context *); /* start the transport */
139 int (*add_node)(struct ctdb_node *); /* setup a new node */
140 int (*connect_node)(struct ctdb_node *); /* connect to node */
141 int (*queue_pkt)(struct ctdb_node *, uint8_t *data, uint32_t length);
142 void *(*allocate_pkt)(TALLOC_CTX *mem_ctx, size_t );
143 void (*shutdown)(struct ctdb_context *); /* shutdown transport */
144 void (*restart)(struct ctdb_node *); /* stop and restart the connection */
148 transport calls up to the ctdb layer
150 struct ctdb_upcalls {
151 /* recv_pkt is called when a packet comes in */
152 void (*recv_pkt)(struct ctdb_context *, uint8_t *data, uint32_t length);
154 /* node_dead is called when an attempt to send to a node fails */
155 void (*node_dead)(struct ctdb_node *);
157 /* node_connected is called when a connection to a node is established */
158 void (*node_connected)(struct ctdb_node *);
161 /* additional data required for the daemon mode */
162 struct ctdb_daemon_data {
165 struct ctdb_queue *queue;
169 #define CTDB_UPDATE_STAT(ctdb, counter, value) \
171 if (value > ctdb->statistics.counter) { \
172 ctdb->statistics.counter = c->hopcount; \
174 if (value > ctdb->statistics_current.counter) { \
175 ctdb->statistics_current.counter = c->hopcount; \
179 #define CTDB_INCREMENT_STAT(ctdb, counter) \
181 ctdb->statistics.counter++; \
182 ctdb->statistics_current.counter++; \
185 #define CTDB_DECREMENT_STAT(ctdb, counter) \
187 if (ctdb->statistics.counter > 0) \
188 ctdb->statistics.counter--; \
189 if (ctdb->statistics_current.counter > 0) \
190 ctdb->statistics_current.counter--; \
193 #define CTDB_INCREMENT_DB_STAT(ctdb_db, counter) \
195 ctdb_db->statistics.counter++; \
198 #define CTDB_DECREMENT_DB_STAT(ctdb_db, counter) \
200 if (ctdb_db->statistics.counter > 0) \
201 ctdb_db->statistics.counter--; \
204 #define CTDB_UPDATE_RECLOCK_LATENCY(ctdb, name, counter, value) \
206 if (value > ctdb->statistics.counter.max) \
207 ctdb->statistics.counter.max = value; \
208 if (value > ctdb->statistics_current.counter.max) \
209 ctdb->statistics_current.counter.max = value; \
211 if (ctdb->statistics.counter.num == 0 || \
212 value < ctdb->statistics.counter.min) \
213 ctdb->statistics.counter.min = value; \
214 if (ctdb->statistics_current.counter.num == 0 || \
215 value < ctdb->statistics_current.counter.min) \
216 ctdb->statistics_current.counter.min = value; \
218 ctdb->statistics.counter.total += value; \
219 ctdb->statistics_current.counter.total += value; \
221 ctdb->statistics.counter.num++; \
222 ctdb->statistics_current.counter.num++; \
224 if (ctdb->tunable.reclock_latency_ms != 0) { \
225 if (value*1000 > ctdb->tunable.reclock_latency_ms) { \
227 ("High RECLOCK latency %fs for operation %s\n", \
233 #define CTDB_UPDATE_DB_LATENCY(ctdb_db, operation, counter, value) \
235 if (value > ctdb_db->statistics.counter.max) \
236 ctdb_db->statistics.counter.max = value; \
237 if (ctdb_db->statistics.counter.num == 0 || \
238 value < ctdb_db->statistics.counter.min) \
239 ctdb_db->statistics.counter.min = value; \
241 ctdb_db->statistics.counter.total += value; \
242 ctdb_db->statistics.counter.num++; \
244 if (ctdb_db->ctdb->tunable.log_latency_ms != 0) { \
245 if (value*1000 > ctdb_db->ctdb->tunable.log_latency_ms) { \
247 ("High latency %.6fs for operation %s on database %s\n",\
248 value, operation, ctdb_db->db_name)); \
253 #define CTDB_UPDATE_LATENCY(ctdb, db, operation, counter, t) \
255 double l = timeval_elapsed(&t); \
257 if (l > ctdb->statistics.counter.max) \
258 ctdb->statistics.counter.max = l; \
259 if (l > ctdb->statistics_current.counter.max) \
260 ctdb->statistics_current.counter.max = l; \
262 if (ctdb->statistics.counter.num == 0 || \
263 l < ctdb->statistics.counter.min) \
264 ctdb->statistics.counter.min = l; \
265 if (ctdb->statistics_current.counter.num == 0 || \
266 l < ctdb->statistics_current.counter.min) \
267 ctdb->statistics_current.counter.min = l; \
269 ctdb->statistics.counter.total += l; \
270 ctdb->statistics_current.counter.total += l; \
272 ctdb->statistics.counter.num++; \
273 ctdb->statistics_current.counter.num++; \
275 if (ctdb->tunable.log_latency_ms != 0) { \
276 if (l*1000 > ctdb->tunable.log_latency_ms) { \
277 DEBUG(DEBUG_WARNING, \
278 ("High latency %.6fs for operation %s on database %s\n",\
279 l, operation, db->db_name)); \
285 enum ctdb_freeze_mode {CTDB_FREEZE_NONE, CTDB_FREEZE_PENDING, CTDB_FREEZE_FROZEN};
287 #define NUM_DB_PRIORITIES 3
288 /* main state of the ctdb daemon */
289 struct ctdb_context {
290 struct tevent_context *ev;
291 struct timeval ctdbd_start_time;
292 struct timeval last_recovery_started;
293 struct timeval last_recovery_finished;
294 uint32_t recovery_mode;
295 TALLOC_CTX *tickle_update_context;
296 TALLOC_CTX *keepalive_ctx;
297 TALLOC_CTX *check_public_ifaces_ctx;
298 struct ctdb_tunable_list tunable;
299 enum ctdb_freeze_mode freeze_mode[NUM_DB_PRIORITIES+1];
300 struct ctdb_freeze_handle *freeze_handles[NUM_DB_PRIORITIES+1];
301 bool freeze_transaction_started;
302 uint32_t freeze_transaction_id;
303 ctdb_sock_addr *address;
305 const char *db_directory;
306 const char *db_directory_persistent;
307 const char *db_directory_state;
308 struct tdb_wrap *db_persistent_health;
309 uint32_t db_persistent_startup_generation;
310 uint64_t db_persistent_check_errors;
311 uint64_t max_persistent_check_errors;
312 const char *transport;
313 char *recovery_lock_file;
314 int recovery_lock_fd;
315 uint32_t pnn; /* our own pnn */
317 uint32_t num_connected;
319 uint32_t capabilities;
320 struct reqid_context *idr;
321 struct ctdb_node **nodes; /* array of nodes in the cluster - indexed by vnn */
322 struct ctdb_vnn *vnn; /* list of public ip addresses and interfaces */
323 struct ctdb_vnn *single_ip_vnn; /* a structure for the single ip */
324 struct ctdb_interface *ifaces; /* list of local interfaces */
326 const struct ctdb_methods *methods; /* transport methods */
327 const struct ctdb_upcalls *upcalls; /* transport upcalls */
328 void *private_data; /* private to transport */
329 struct ctdb_db_context *db_list;
330 struct srvid_context *srv;
331 struct ctdb_daemon_data daemon;
332 struct ctdb_statistics statistics;
333 struct ctdb_statistics statistics_current;
334 #define MAX_STAT_HISTORY 100
335 struct ctdb_statistics statistics_history[MAX_STAT_HISTORY];
336 struct ctdb_vnn_map *vnn_map;
337 uint32_t num_clients;
338 uint32_t recovery_master;
339 struct ctdb_client_ip *client_ip_list;
340 bool do_checkpublicip;
341 struct trbt_tree *server_ids;
343 const char *event_script_dir;
344 const char *notification_script;
345 const char *default_public_interface;
348 enum ctdb_runstate runstate;
349 struct ctdb_monitor_state *monitor;
350 int start_as_disabled;
351 int start_as_stopped;
353 uint32_t *recd_ping_count;
354 TALLOC_CTX *recd_ctx; /* a context used to track recoverd monitoring events */
355 TALLOC_CTX *release_ips_ctx; /* a context used to automatically drop all IPs if we fail to recover the node */
357 TALLOC_CTX *event_script_ctx;
360 struct ctdb_event_script_state *current_monitor;
361 struct ctdb_script_list_old *last_status[CTDB_EVENT_MAX];
363 TALLOC_CTX *banning_ctx;
365 struct ctdb_vacuum_child_context *vacuumers;
367 /* mapping from pid to ctdb_client * */
368 struct ctdb_client_pid_list *client_pids;
370 /* used in the recovery daemon to remember the ip allocation */
371 struct trbt_tree *ip_tree;
373 /* Used to defer db attach requests while in recovery mode */
374 struct ctdb_deferred_attach_context *deferred_attach;
376 /* if we are a child process, do we have a domain socket to send controls on */
377 bool can_send_controls;
379 /* list of event script callback functions that are active */
380 struct event_script_callback *script_callbacks;
382 struct ctdb_reloadips_handle *reload_ips;
384 const char *nodes_file;
385 const char *public_addresses_file;
386 struct trbt_tree *child_processes;
388 /* Used for locking record/db/alldb */
389 struct lock_context *lock_current;
390 struct lock_context *lock_pending;
393 struct ctdb_db_context {
394 struct ctdb_db_context *next, *prev;
395 struct ctdb_context *ctdb;
399 bool readonly; /* Do we support read-only delegations ? */
400 bool sticky; /* Do we support sticky records ? */
403 struct tdb_wrap *ltdb;
404 struct tdb_context *rottdb; /* ReadOnly tracking TDB */
405 struct ctdb_registered_call *calls; /* list of registered calls */
407 struct tevent_timer *seqnum_update;
408 struct ctdb_traverse_local_handle *traverse;
409 struct ctdb_vacuum_handle *vacuum_handle;
410 char *unhealthy_reason;
411 int pending_requests;
412 struct revokechild_handle *revokechild_active;
413 struct ctdb_persistent_state *persistent_state;
414 struct trbt_tree *delete_queue;
415 struct trbt_tree *sticky_records;
416 int (*ctdb_ltdb_store_fn)(struct ctdb_db_context *ctdb_db,
418 struct ctdb_ltdb_header *header,
421 /* used to track which records we are currently fetching
422 so we can avoid sending duplicate fetch requests
424 struct trbt_tree *deferred_fetch;
425 struct trbt_tree *defer_dmaster;
427 struct ctdb_db_statistics_old statistics;
429 struct lock_context *lock_current;
430 struct lock_context *lock_pending;
431 int lock_num_current;
433 struct ctdb_call_state *pending_calls;
435 enum ctdb_freeze_mode freeze_mode;
436 struct ctdb_db_freeze_handle *freeze_handle;
437 bool freeze_transaction_started;
438 uint32_t freeze_transaction_id;
443 #define CTDB_NO_MEMORY(ctdb, p) do { if (!(p)) { \
444 DEBUG(0,("Out of memory for %s at %s\n", #p, __location__)); \
445 ctdb_set_error(ctdb, "Out of memory at %s:%d", __FILE__, __LINE__); \
446 return -1; }} while (0)
448 #define CTDB_NO_MEMORY_VOID(ctdb, p) do { if (!(p)) { \
449 DEBUG(0,("Out of memory for %s at %s\n", #p, __location__)); \
450 ctdb_set_error(ctdb, "Out of memory at %s:%d", __FILE__, __LINE__); \
453 #define CTDB_NO_MEMORY_NULL(ctdb, p) do { if (!(p)) { \
454 DEBUG(0,("Out of memory for %s at %s\n", #p, __location__)); \
455 ctdb_set_error(ctdb, "Out of memory at %s:%d", __FILE__, __LINE__); \
456 return NULL; }} while (0)
458 #define CTDB_NO_MEMORY_FATAL(ctdb, p) do { if (!(p)) { \
459 DEBUG(0,("Out of memory for %s at %s\n", #p, __location__)); \
460 ctdb_fatal(ctdb, "Out of memory in " __location__ ); \
464 enum call_state {CTDB_CALL_WAIT, CTDB_CALL_DONE, CTDB_CALL_ERROR};
467 state of a in-progress ctdb call
469 struct ctdb_call_state {
470 struct ctdb_call_state *next, *prev;
471 enum call_state state;
473 struct ctdb_req_call_old *c;
474 struct ctdb_db_context *ctdb_db;
476 struct ctdb_call *call;
479 void (*fn)(struct ctdb_call_state *);
484 /* internal prototypes */
486 #define CHECK_CONTROL_DATA_SIZE(size) do { \
487 if (indata.dsize != size) { \
488 DEBUG(0,(__location__ " Invalid data size in opcode %u. Got %u expected %u\n", \
489 opcode, (unsigned)indata.dsize, (unsigned)size)); \
494 #define CHECK_CONTROL_MIN_DATA_SIZE(size) do { \
495 if (indata.dsize < size) { \
496 DEBUG(0,(__location__ " Invalid data size in opcode %u. Got %u expected >= %u\n", \
497 opcode, (unsigned)indata.dsize, (unsigned)size)); \
503 state of a in-progress ctdb call in client
505 struct ctdb_client_call_state {
506 enum call_state state;
508 struct ctdb_db_context *ctdb_db;
509 struct ctdb_call *call;
511 void (*fn)(struct ctdb_client_call_state *);
516 extern int script_log_level;
517 extern bool fast_start;
518 extern const char *ctdbd_pidfile;
520 typedef void (*deferred_requeue_fn)(void *call_context, struct ctdb_req_header *hdr);
523 /* from tcp/ and ib/ */
525 int ctdb_tcp_init(struct ctdb_context *ctdb);
526 int ctdb_ibw_init(struct ctdb_context *ctdb);
528 /* from ctdb_banning.c */
530 void ctdb_local_node_got_banned(struct ctdb_context *ctdb);
531 int32_t ctdb_control_set_ban_state(struct ctdb_context *ctdb, TDB_DATA indata);
532 int32_t ctdb_control_get_ban_state(struct ctdb_context *ctdb, TDB_DATA *outdata);
533 void ctdb_ban_self(struct ctdb_context *ctdb);
535 /* from ctdb_call.c */
537 struct ctdb_db_context *find_ctdb_db(struct ctdb_context *ctdb, uint32_t id);
539 void ctdb_request_dmaster(struct ctdb_context *ctdb,
540 struct ctdb_req_header *hdr);
541 void ctdb_reply_dmaster(struct ctdb_context *ctdb,
542 struct ctdb_req_header *hdr);
543 void ctdb_request_call(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
544 void ctdb_reply_call(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
545 void ctdb_reply_error(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
547 void ctdb_call_resend_db(struct ctdb_db_context *ctdb);
548 void ctdb_call_resend_all(struct ctdb_context *ctdb);
550 struct ctdb_call_state *ctdb_call_local_send(struct ctdb_db_context *ctdb_db,
551 struct ctdb_call *call,
552 struct ctdb_ltdb_header *header,
555 struct ctdb_call_state *ctdb_daemon_call_send_remote(
556 struct ctdb_db_context *ctdb_db,
557 struct ctdb_call *call,
558 struct ctdb_ltdb_header *header);
559 int ctdb_daemon_call_recv(struct ctdb_call_state *state,
560 struct ctdb_call *call);
562 void ctdb_send_keepalive(struct ctdb_context *ctdb, uint32_t destnode);
564 int ctdb_start_revoke_ro_record(struct ctdb_context *ctdb,
565 struct ctdb_db_context *ctdb_db,
566 TDB_DATA key, struct ctdb_ltdb_header *header,
569 int ctdb_add_revoke_deferred_call(struct ctdb_context *ctdb,
570 struct ctdb_db_context *ctdb_db,
571 TDB_DATA key, struct ctdb_req_header *hdr,
572 deferred_requeue_fn fn, void *call_context);
574 /* from server/ctdb_control.c */
576 int32_t ctdb_dump_memory(struct ctdb_context *ctdb, TDB_DATA *outdata);
578 void ctdb_request_control_reply(struct ctdb_context *ctdb,
579 struct ctdb_req_control_old *c,
580 TDB_DATA *outdata, int32_t status,
581 const char *errormsg);
583 void ctdb_request_control(struct ctdb_context *ctdb,
584 struct ctdb_req_header *hdr);
585 void ctdb_reply_control(struct ctdb_context *ctdb,
586 struct ctdb_req_header *hdr);
588 int ctdb_daemon_send_control(struct ctdb_context *ctdb, uint32_t destnode,
589 uint64_t srvid, uint32_t opcode,
590 uint32_t client_id, uint32_t flags,
592 ctdb_control_callback_fn_t callback,
595 /* from server/ctdb_daemon.c */
597 int daemon_register_message_handler(struct ctdb_context *ctdb,
598 uint32_t client_id, uint64_t srvid);
599 int daemon_deregister_message_handler(struct ctdb_context *ctdb,
600 uint32_t client_id, uint64_t srvid);
601 int daemon_check_srvids(struct ctdb_context *ctdb, TDB_DATA indata,
604 int ctdb_start_daemon(struct ctdb_context *ctdb, bool do_fork);
606 struct ctdb_req_header *_ctdb_transport_allocate(struct ctdb_context *ctdb,
608 enum ctdb_operation operation,
609 size_t length, size_t slength,
612 #define ctdb_transport_allocate(ctdb, mem_ctx, operation, length, type) \
613 (type *)_ctdb_transport_allocate(ctdb, mem_ctx, operation, length, \
616 void ctdb_daemon_cancel_controls(struct ctdb_context *ctdb,
617 struct ctdb_node *node);
619 int ctdb_daemon_set_call(struct ctdb_context *ctdb, uint32_t db_id,
620 ctdb_fn_t fn, int id);
622 int ctdb_daemon_send_message(struct ctdb_context *ctdb, uint32_t pnn,
623 uint64_t srvid, TDB_DATA data);
625 int32_t ctdb_control_register_notify(struct ctdb_context *ctdb,
626 uint32_t client_id, TDB_DATA indata);
627 int32_t ctdb_control_deregister_notify(struct ctdb_context *ctdb,
628 uint32_t client_id, TDB_DATA indata);
630 struct ctdb_client *ctdb_find_client_by_pid(struct ctdb_context *ctdb,
633 int32_t ctdb_control_process_exists(struct ctdb_context *ctdb, pid_t pid);
635 int ctdb_control_getnodesfile(struct ctdb_context *ctdb, uint32_t opcode,
636 TDB_DATA indata, TDB_DATA *outdata);
638 void ctdb_shutdown_sequence(struct ctdb_context *ctdb, int exit_code);
640 int switch_from_server_to_client(struct ctdb_context *ctdb,
641 const char *fmt, ...);
643 /* From server/ctdb_fork.c */
645 void ctdb_set_child_info(TALLOC_CTX *mem_ctx, const char *child_name_fmt, ...);
647 void ctdb_track_child(struct ctdb_context *ctdb, pid_t pid);
649 pid_t ctdb_fork(struct ctdb_context *ctdb);
651 struct tevent_signal *ctdb_init_sigchld(struct ctdb_context *ctdb);
653 int ctdb_kill(struct ctdb_context *ctdb, pid_t pid, int signum);
655 /* from server/ctdb_freeze.c */
657 int32_t ctdb_control_db_freeze(struct ctdb_context *ctdb,
658 struct ctdb_req_control_old *c,
659 uint32_t db_id, bool *async_reply);
660 int32_t ctdb_control_db_thaw(struct ctdb_context *ctdb, uint32_t db_id);
662 int32_t ctdb_control_freeze(struct ctdb_context *ctdb,
663 struct ctdb_req_control_old *c, bool *async_reply);
664 int32_t ctdb_control_thaw(struct ctdb_context *ctdb, uint32_t priority,
667 bool ctdb_blocking_freeze(struct ctdb_context *ctdb);
669 int32_t ctdb_control_db_transaction_start(struct ctdb_context *ctdb,
671 int32_t ctdb_control_db_transaction_cancel(struct ctdb_context *ctdb,
673 int32_t ctdb_control_db_transaction_commit(struct ctdb_context *ctdb,
676 int32_t ctdb_control_transaction_start(struct ctdb_context *ctdb, uint32_t id);
677 int32_t ctdb_control_transaction_cancel(struct ctdb_context *ctdb);
678 int32_t ctdb_control_transaction_commit(struct ctdb_context *ctdb, uint32_t id);
680 int32_t ctdb_control_wipe_database(struct ctdb_context *ctdb, TDB_DATA indata);
682 bool ctdb_db_frozen(struct ctdb_db_context *ctdb_db);
683 bool ctdb_db_prio_frozen(struct ctdb_context *ctdb, uint32_t priority);
684 bool ctdb_db_all_frozen(struct ctdb_context *ctdb);
686 /* from server/ctdb_keepalive.c */
688 void ctdb_start_keepalive(struct ctdb_context *ctdb);
689 void ctdb_stop_keepalive(struct ctdb_context *ctdb);
691 /* from server/ctdb_lock.c */
695 typedef int (*ctdb_db_handler_t)(struct ctdb_db_context *ctdb_db,
698 int ctdb_db_prio_iterator(struct ctdb_context *ctdb, uint32_t priority,
699 ctdb_db_handler_t handler, void *private_data);
700 int ctdb_db_iterator(struct ctdb_context *ctdb, ctdb_db_handler_t handler,
703 int ctdb_lockdb_mark(struct ctdb_db_context *ctdb_db);
704 int ctdb_lockall_mark_prio(struct ctdb_context *ctdb, uint32_t priority);
706 int ctdb_lockdb_unmark(struct ctdb_db_context *ctdb_db);
707 int ctdb_lockall_unmark_prio(struct ctdb_context *ctdb, uint32_t priority);
709 struct lock_request *ctdb_lock_record(TALLOC_CTX *mem_ctx,
710 struct ctdb_db_context *ctdb_db,
713 void (*callback)(void *, bool),
716 struct lock_request *ctdb_lock_db(TALLOC_CTX *mem_ctx,
717 struct ctdb_db_context *ctdb_db,
719 void (*callback)(void *, bool),
722 struct lock_request *ctdb_lock_alldb_prio(TALLOC_CTX *mem_ctx,
723 struct ctdb_context *ctdb,
726 void (*callback)(void *, bool),
729 struct lock_request *ctdb_lock_alldb(TALLOC_CTX *mem_ctx,
730 struct ctdb_context *ctdb,
732 void (*callback)(void *, bool),
735 /* from ctdb_logging.c */
737 extern const char *debug_extra;
739 typedef int (*ctdb_log_setup_fn_t)(TALLOC_CTX *mem_ctx,
741 const char *app_name);
743 void ctdb_log_register_backend(const char *prefix, ctdb_log_setup_fn_t init);
745 bool ctdb_logging_init(TALLOC_CTX *mem_ctx, const char *logging);
747 struct ctdb_log_state *ctdb_vfork_with_logging(TALLOC_CTX *mem_ctx,
748 struct ctdb_context *ctdb,
749 const char *log_prefix,
752 const char **helper_argv,
753 void (*logfn)(const char *,
755 void *logfn_private, pid_t *pid);
757 int ctdb_set_child_logging(struct ctdb_context *ctdb);
758 int ctdb_init_tevent_logging(struct ctdb_context *ctdb);
760 /* from ctdb_logging_file.c */
762 void ctdb_log_init_file(void);
764 /* from ctdb_logging_syslog.c */
766 void ctdb_log_init_syslog(void);
768 /* from ctdb_ltdb_server.c */
770 int ctdb_ltdb_lock_requeue(struct ctdb_db_context *ctdb_db,
771 TDB_DATA key, struct ctdb_req_header *hdr,
772 void (*recv_pkt)(void *, struct ctdb_req_header *),
773 void *recv_context, bool ignore_generation);
775 int ctdb_ltdb_lock_fetch_requeue(struct ctdb_db_context *ctdb_db,
776 TDB_DATA key, struct ctdb_ltdb_header *header,
777 struct ctdb_req_header *hdr, TDB_DATA *data,
778 void (*recv_pkt)(void *, struct ctdb_req_header *),
779 void *recv_context, bool ignore_generation);
781 int ctdb_load_persistent_health(struct ctdb_context *ctdb,
782 struct ctdb_db_context *ctdb_db);
783 int ctdb_update_persistent_health(struct ctdb_context *ctdb,
784 struct ctdb_db_context *ctdb_db,
785 const char *reason,/* NULL means healthy */
786 int num_healthy_nodes);
787 int ctdb_recheck_persistent_health(struct ctdb_context *ctdb);
789 int32_t ctdb_control_db_set_healthy(struct ctdb_context *ctdb,
791 int32_t ctdb_control_db_get_health(struct ctdb_context *ctdb,
792 TDB_DATA indata, TDB_DATA *outdata);
794 int ctdb_set_db_readonly(struct ctdb_context *ctdb,
795 struct ctdb_db_context *ctdb_db);
797 int ctdb_process_deferred_attach(struct ctdb_context *ctdb);
799 int32_t ctdb_control_db_attach(struct ctdb_context *ctdb, TDB_DATA indata,
800 TDB_DATA *outdata, uint64_t tdb_flags,
801 bool persistent, uint32_t client_id,
802 struct ctdb_req_control_old *c,
804 int32_t ctdb_control_db_detach(struct ctdb_context *ctdb, TDB_DATA indata,
807 int ctdb_attach_databases(struct ctdb_context *ctdb);
809 int32_t ctdb_ltdb_update_seqnum(struct ctdb_context *ctdb, uint32_t db_id,
811 int32_t ctdb_ltdb_enable_seqnum(struct ctdb_context *ctdb, uint32_t db_id);
813 int32_t ctdb_control_set_db_priority(struct ctdb_context *ctdb, TDB_DATA indata,
816 int ctdb_set_db_sticky(struct ctdb_context *ctdb,
817 struct ctdb_db_context *ctdb_db);
819 void ctdb_db_statistics_reset(struct ctdb_db_context *ctdb_db);
821 int32_t ctdb_control_get_db_statistics(struct ctdb_context *ctdb,
822 uint32_t db_id, TDB_DATA *outdata);
824 /* from ctdb_monitor.c */
826 int ctdb_set_notification_script(struct ctdb_context *ctdb, const char *script);
827 void ctdb_run_notification_script(struct ctdb_context *ctdb, const char *event);
829 void ctdb_disable_monitoring(struct ctdb_context *ctdb);
830 void ctdb_enable_monitoring(struct ctdb_context *ctdb);
831 void ctdb_stop_monitoring(struct ctdb_context *ctdb);
833 void ctdb_wait_for_first_recovery(struct ctdb_context *ctdb);
835 int32_t ctdb_control_modflags(struct ctdb_context *ctdb, TDB_DATA indata);
837 int32_t ctdb_monitoring_mode(struct ctdb_context *ctdb);
838 bool ctdb_stopped_monitoring(struct ctdb_context *ctdb);
840 /* from ctdb_persistent.c */
842 void ctdb_persistent_finish_trans3_commits(struct ctdb_context *ctdb);
844 int32_t ctdb_control_trans3_commit(struct ctdb_context *ctdb,
845 struct ctdb_req_control_old *c,
846 TDB_DATA recdata, bool *async_reply);
848 int32_t ctdb_control_start_persistent_update(struct ctdb_context *ctdb,
849 struct ctdb_req_control_old *c,
851 int32_t ctdb_control_cancel_persistent_update(struct ctdb_context *ctdb,
852 struct ctdb_req_control_old *c,
855 int32_t ctdb_control_get_db_seqnum(struct ctdb_context *ctdb,
856 TDB_DATA indata, TDB_DATA *outdata);
858 /* from ctdb_recover.c */
860 int ctdb_control_getvnnmap(struct ctdb_context *ctdb, uint32_t opcode,
861 TDB_DATA indata, TDB_DATA *outdata);
862 int ctdb_control_setvnnmap(struct ctdb_context *ctdb, uint32_t opcode,
863 TDB_DATA indata, TDB_DATA *outdata);
865 int ctdb_control_getdbmap(struct ctdb_context *ctdb, uint32_t opcode,
866 TDB_DATA indata, TDB_DATA *outdata);
867 int ctdb_control_getnodemap(struct ctdb_context *ctdb, uint32_t opcode,
868 TDB_DATA indata, TDB_DATA *outdata);
870 int ctdb_control_reload_nodes_file(struct ctdb_context *ctdb, uint32_t opcode);
872 int32_t ctdb_control_pull_db(struct ctdb_context *ctdb, TDB_DATA indata,
874 int32_t ctdb_control_push_db(struct ctdb_context *ctdb, TDB_DATA indata);
876 int ctdb_deferred_drop_all_ips(struct ctdb_context *ctdb);
878 int32_t ctdb_control_set_recmode(struct ctdb_context *ctdb,
879 struct ctdb_req_control_old *c,
880 TDB_DATA indata, bool *async_reply,
881 const char **errormsg);
883 bool ctdb_recovery_have_lock(struct ctdb_context *ctdb);
884 bool ctdb_recovery_lock(struct ctdb_context *ctdb);
885 void ctdb_recovery_unlock(struct ctdb_context *ctdb);
887 int32_t ctdb_control_end_recovery(struct ctdb_context *ctdb,
888 struct ctdb_req_control_old *c,
890 int32_t ctdb_control_start_recovery(struct ctdb_context *ctdb,
891 struct ctdb_req_control_old *c,
894 int32_t ctdb_control_try_delete_records(struct ctdb_context *ctdb,
895 TDB_DATA indata, TDB_DATA *outdata);
896 int32_t ctdb_control_receive_records(struct ctdb_context *ctdb,
897 TDB_DATA indata, TDB_DATA *outdata);
899 int32_t ctdb_control_get_capabilities(struct ctdb_context *ctdb,
902 int32_t ctdb_control_recd_ping(struct ctdb_context *ctdb);
903 int32_t ctdb_control_set_recmaster(struct ctdb_context *ctdb,
904 uint32_t opcode, TDB_DATA indata);
906 int32_t ctdb_control_stop_node(struct ctdb_context *ctdb);
907 int32_t ctdb_control_continue_node(struct ctdb_context *ctdb);
909 /* from ctdb_recoverd.c */
911 int ctdb_start_recoverd(struct ctdb_context *ctdb);
912 void ctdb_stop_recoverd(struct ctdb_context *ctdb);
914 /* from ctdb_server.c */
916 int ctdb_set_transport(struct ctdb_context *ctdb, const char *transport);
918 int ctdb_ip_to_nodeid(struct ctdb_context *ctdb, const ctdb_sock_addr *nodeip);
920 int ctdb_set_recovery_lock_file(struct ctdb_context *ctdb, const char *file);
922 void ctdb_load_nodes_file(struct ctdb_context *ctdb);
924 int ctdb_set_address(struct ctdb_context *ctdb, const char *address);
926 uint32_t ctdb_get_num_active_nodes(struct ctdb_context *ctdb);
928 void ctdb_input_pkt(struct ctdb_context *ctdb, struct ctdb_req_header *);
930 void ctdb_node_dead(struct ctdb_node *node);
931 void ctdb_node_connected(struct ctdb_node *node);
933 void ctdb_queue_packet(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
934 void ctdb_queue_packet_opcode(struct ctdb_context *ctdb,
935 struct ctdb_req_header *hdr, unsigned opcode);
937 /* from ctdb_serverids.c */
939 int32_t ctdb_control_register_server_id(struct ctdb_context *ctdb,
940 uint32_t client_id, TDB_DATA indata);
941 int32_t ctdb_control_check_server_id(struct ctdb_context *ctdb,
943 int32_t ctdb_control_unregister_server_id(struct ctdb_context *ctdb,
945 int32_t ctdb_control_get_server_id_list(struct ctdb_context *ctdb,
948 /* from ctdb_statistics.c */
950 int ctdb_statistics_init(struct ctdb_context *ctdb);
952 int32_t ctdb_control_get_stat_history(struct ctdb_context *ctdb,
953 struct ctdb_req_control_old *c,
956 /* from ctdb_takeover.c */
958 int32_t ctdb_control_takeover_ip(struct ctdb_context *ctdb,
959 struct ctdb_req_control_old *c,
962 int32_t ctdb_control_release_ip(struct ctdb_context *ctdb,
963 struct ctdb_req_control_old *c,
966 int32_t ctdb_control_ipreallocated(struct ctdb_context *ctdb,
967 struct ctdb_req_control_old *c,
970 int ctdb_set_public_addresses(struct ctdb_context *ctdb, bool check_addresses);
971 int ctdb_set_single_public_ip(struct ctdb_context *ctdb, const char *iface,
974 int ctdb_takeover_run(struct ctdb_context *ctdb, struct ctdb_node_map_old *nodemap,
975 uint32_t *force_rebalance_nodes,
976 client_async_callback fail_callback, void *callback_data);
978 int32_t ctdb_control_tcp_client(struct ctdb_context *ctdb, uint32_t client_id,
980 int32_t ctdb_control_tcp_add(struct ctdb_context *ctdb, TDB_DATA indata,
981 bool tcp_update_needed);
982 int32_t ctdb_control_tcp_remove(struct ctdb_context *ctdb, TDB_DATA indata);
983 int32_t ctdb_control_startup(struct ctdb_context *ctdb, uint32_t vnn);
985 void ctdb_takeover_client_destructor_hook(struct ctdb_client *client);
987 void ctdb_release_all_ips(struct ctdb_context *ctdb);
989 int32_t ctdb_control_get_public_ips(struct ctdb_context *ctdb,
990 struct ctdb_req_control_old *c,
992 int32_t ctdb_control_get_public_ip_info(struct ctdb_context *ctdb,
993 struct ctdb_req_control_old *c,
994 TDB_DATA indata, TDB_DATA *outdata);
996 int32_t ctdb_control_get_ifaces(struct ctdb_context *ctdb,
997 struct ctdb_req_control_old *c,
999 int32_t ctdb_control_set_iface_link(struct ctdb_context *ctdb,
1000 struct ctdb_req_control_old *c,
1003 int32_t ctdb_control_kill_tcp(struct ctdb_context *ctdb, TDB_DATA indata);
1004 int32_t ctdb_control_set_tcp_tickle_list(struct ctdb_context *ctdb,
1006 int32_t ctdb_control_get_tcp_tickle_list(struct ctdb_context *ctdb,
1007 TDB_DATA indata, TDB_DATA *outdata);
1009 void ctdb_start_tcp_tickle_update(struct ctdb_context *ctdb);
1011 int32_t ctdb_control_send_gratious_arp(struct ctdb_context *ctdb,
1014 int32_t ctdb_control_add_public_address(struct ctdb_context *ctdb,
1016 int32_t ctdb_control_del_public_address(struct ctdb_context *ctdb,
1017 struct ctdb_req_control_old *c,
1018 TDB_DATA recdata, bool *async_reply);
1020 int update_ip_assignment_tree(struct ctdb_context *ctdb,
1021 struct ctdb_public_ip *ip);
1022 void clear_ip_assignment_tree(struct ctdb_context *ctdb);
1024 int32_t ctdb_control_reload_public_ips(struct ctdb_context *ctdb,
1025 struct ctdb_req_control_old *c,
1028 /* from ctdb_traverse.c */
1030 int32_t ctdb_control_traverse_all_ext(struct ctdb_context *ctdb,
1031 TDB_DATA data, TDB_DATA *outdata);
1032 int32_t ctdb_control_traverse_all(struct ctdb_context *ctdb,
1033 TDB_DATA data, TDB_DATA *outdata);
1034 int32_t ctdb_control_traverse_data(struct ctdb_context *ctdb,
1035 TDB_DATA data, TDB_DATA *outdata);
1036 int32_t ctdb_control_traverse_kill(struct ctdb_context *ctdb, TDB_DATA indata,
1037 TDB_DATA *outdata, uint32_t srcnode);
1039 int32_t ctdb_control_traverse_start_ext(struct ctdb_context *ctdb,
1040 TDB_DATA indata, TDB_DATA *outdata,
1041 uint32_t srcnode, uint32_t client_id);
1042 int32_t ctdb_control_traverse_start(struct ctdb_context *ctdb,
1043 TDB_DATA indata, TDB_DATA *outdata,
1044 uint32_t srcnode, uint32_t client_id);
1046 /* from ctdb_tunables.c */
1048 void ctdb_tunables_set_defaults(struct ctdb_context *ctdb);
1050 int32_t ctdb_control_get_tunable(struct ctdb_context *ctdb, TDB_DATA indata,
1052 int32_t ctdb_control_set_tunable(struct ctdb_context *ctdb, TDB_DATA indata);
1053 int32_t ctdb_control_list_tunables(struct ctdb_context *ctdb,
1056 /* from ctdb_update_record.c */
1058 int32_t ctdb_control_update_record(struct ctdb_context *ctdb,
1059 struct ctdb_req_control_old *c,
1060 TDB_DATA recdata, bool *async_reply);
1062 /* from ctdb_uptime.c */
1064 int32_t ctdb_control_uptime(struct ctdb_context *ctdb, TDB_DATA *outdata);
1066 /* from ctdb_vacuum.c */
1068 void ctdb_stop_vacuuming(struct ctdb_context *ctdb);
1069 int ctdb_vacuum_init(struct ctdb_db_context *ctdb_db);
1071 int32_t ctdb_control_schedule_for_deletion(struct ctdb_context *ctdb,
1073 int32_t ctdb_local_schedule_for_deletion(struct ctdb_db_context *ctdb_db,
1074 const struct ctdb_ltdb_header *hdr,
1077 void ctdb_local_remove_from_delete_queue(struct ctdb_db_context *ctdb_db,
1078 const struct ctdb_ltdb_header *hdr,
1079 const TDB_DATA key);
1081 /* from eventscript.c */
1083 int32_t ctdb_control_get_event_script_status(struct ctdb_context *ctdb,
1087 int ctdb_event_script_callback(struct ctdb_context *ctdb,
1088 TALLOC_CTX *mem_ctx,
1089 void (*callback)(struct ctdb_context *,
1092 enum ctdb_event call,
1093 const char *fmt, ...) PRINTF_ATTRIBUTE(6,7);
1095 int ctdb_event_script_args(struct ctdb_context *ctdb,
1096 enum ctdb_event call,
1097 const char *fmt, ...) PRINTF_ATTRIBUTE(3,4);
1099 int ctdb_event_script(struct ctdb_context *ctdb,
1100 enum ctdb_event call);
1102 int32_t ctdb_run_eventscripts(struct ctdb_context *ctdb,
1103 struct ctdb_req_control_old *c,
1104 TDB_DATA data, bool *async_reply);
1106 int32_t ctdb_control_enable_script(struct ctdb_context *ctdb, TDB_DATA indata);
1107 int32_t ctdb_control_disable_script(struct ctdb_context *ctdb, TDB_DATA indata);