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
{
34 struct srvid_request_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
{
52 struct ctdb_tcp_connection connections
[1];
55 /* the list of tcp tickles used by get/set tcp tickle list */
56 struct ctdb_control_tcp_tickle_list
{
58 struct ctdb_tcp_wire_array tickles
;
62 array of tcp connections
64 struct ctdb_tcp_array
{
66 struct ctdb_tcp_connection
*connections
;
70 /* all tunable variables go in here */
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
;
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
;
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
149 typedef void (*ctdb_queue_cb_fn_t
)(uint8_t *data
, size_t length
,
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
,
158 structure describing a connected client in the daemon
161 struct ctdb_context
*ctdb
;
163 struct ctdb_queue
*queue
;
166 struct ctdb_tcp_list
*tcp_list
;
168 uint32_t num_persistent_updates
;
169 struct ctdb_client_notify_list
*notify
;
174 /* state associated with a public ip address */
176 struct ctdb_vnn
*prev
, *next
;
178 struct ctdb_iface
*iface
;
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 */
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. */
210 state associated with one 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 */
220 /* used by the dead node monitoring */
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
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
;
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
{
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) { \
348 ("High RECLOCK latency %fs for operation %s\n", \
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) { \
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
410 struct ctdb_write_record
{
414 unsigned char blob
[1];
417 enum ctdb_freeze_mode
{CTDB_FREEZE_NONE
, CTDB_FREEZE_PENDING
, CTDB_FREEZE_FROZEN
};
420 CTDB_RUNSTATE_UNKNOWN
,
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
;
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 */
468 uint32_t num_connected
;
470 uint32_t capabilities
;
471 struct idr_context
*idr
;
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 */
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
;
497 const char *event_script_dir
;
498 const char *notification_script
;
499 const char *default_public_interface
;
502 enum ctdb_runstate runstate
;
503 struct ctdb_monitor_state
*monitor
;
504 int start_as_disabled
;
505 int start_as_stopped
;
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
;
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
;
554 bool readonly
; /* Do we support read-only delegations ? */
555 bool sticky
; /* Do we support sticky records ? */
558 struct tdb_wrap
*ltdb
;
559 struct tdb_context
*rottdb
; /* ReadOnly tracking TDB */
560 struct ctdb_registered_call
*calls
; /* list of registered calls */
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
,
573 struct ctdb_ltdb_header
*header
,
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__); \
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__ ); \
611 struct for kill_tcp control
613 struct ctdb_control_killtcp
{
614 ctdb_sock_addr src_addr
;
615 ctdb_sock_addr dst_addr
;
619 struct holding a ctdb_sock_addr and an interface name,
620 used to add/remove public addresses
622 struct ctdb_control_ip_iface
{
630 struct holding a ctdb_sock_addr and an interface name,
631 used for send_gratious_arp
633 struct ctdb_control_gratious_arp
{
641 persistent store control - update this record on all other nodes
643 struct ctdb_control_persistent_store
{
650 structure used for CTDB_SRVID_NODE_FLAGS_CHANGED
652 struct ctdb_node_flag_change
{
659 struct for admin setting a ban
661 struct ctdb_ban_info
{
666 enum call_state
{CTDB_CALL_WAIT
, CTDB_CALL_DONE
, CTDB_CALL_ERROR
};
668 #define CTDB_LMASTER_ANY 0xffffffff
671 state of a in-progress ctdb call
673 struct ctdb_call_state
{
674 struct ctdb_call_state
*next
, *prev
;
675 enum call_state state
;
677 struct ctdb_req_call
*c
;
678 struct ctdb_db_context
*ctdb_db
;
680 struct ctdb_call
*call
;
683 void (*fn
)(struct ctdb_call_state
*);
689 /* used for fetch_lock */
690 struct ctdb_fetch_handle
{
691 struct ctdb_db_context
*ctdb_db
;
694 struct ctdb_ltdb_header header
;
697 /* internal prototypes */
698 void ctdb_set_error(struct ctdb_context
*ctdb
, const char *fmt
, ...) PRINTF_ATTRIBUTE(2,3);
699 void ctdb_fatal(struct ctdb_context
*ctdb
, const char *msg
);
700 void ctdb_die(struct ctdb_context
*ctdb
, const char *msg
);
701 bool ctdb_set_helper(const char *type
, char *helper
, size_t size
,
702 const char *envvar
, const char *dir
, const char *file
);
703 void ctdb_external_trace(void);
704 bool ctdb_same_address(ctdb_sock_addr
*a1
, ctdb_sock_addr
*a2
);
705 int ctdb_parse_address(TALLOC_CTX
*mem_ctx
, const char *str
,
706 ctdb_sock_addr
*address
);
707 bool ctdb_same_ip(const ctdb_sock_addr
*ip1
, const ctdb_sock_addr
*ip2
);
708 bool ctdb_same_sockaddr(const ctdb_sock_addr
*ip1
, const ctdb_sock_addr
*ip2
);
709 uint32_t ctdb_hash(const TDB_DATA
*key
);
710 uint32_t *ctdb_key_to_idkey(TALLOC_CTX
*mem_ctx
, TDB_DATA key
);
712 void ctdb_request_call(struct ctdb_context
*ctdb
, struct ctdb_req_header
*hdr
);
713 void ctdb_request_dmaster(struct ctdb_context
*ctdb
, struct ctdb_req_header
*hdr
);
714 void ctdb_request_message(struct ctdb_context
*ctdb
, struct ctdb_req_header
*hdr
);
715 void ctdb_reply_dmaster(struct ctdb_context
*ctdb
, struct ctdb_req_header
*hdr
);
716 void ctdb_reply_call(struct ctdb_context
*ctdb
, struct ctdb_req_header
*hdr
);
717 void ctdb_reply_error(struct ctdb_context
*ctdb
, struct ctdb_req_header
*hdr
);
719 uint32_t ctdb_lmaster(struct ctdb_context
*ctdb
, const TDB_DATA
*key
);
720 int ctdb_ltdb_fetch(struct ctdb_db_context
*ctdb_db
,
721 TDB_DATA key
, struct ctdb_ltdb_header
*header
,
722 TALLOC_CTX
*mem_ctx
, TDB_DATA
*data
);
723 int ctdb_ltdb_store(struct ctdb_db_context
*ctdb_db
, TDB_DATA key
,
724 struct ctdb_ltdb_header
*header
, TDB_DATA data
);
725 int ctdb_ltdb_delete(struct ctdb_db_context
*ctdb_db
, TDB_DATA key
);
726 int ctdb_ltdb_fetch_with_header(struct ctdb_db_context
*ctdb_db
,
727 TDB_DATA key
, struct ctdb_ltdb_header
*header
,
728 TALLOC_CTX
*mem_ctx
, TDB_DATA
*data
);
729 int32_t ctdb_control_start_persistent_update(struct ctdb_context
*ctdb
,
730 struct ctdb_req_control
*c
,
732 int32_t ctdb_control_cancel_persistent_update(struct ctdb_context
*ctdb
,
733 struct ctdb_req_control
*c
,
735 void ctdb_queue_packet(struct ctdb_context
*ctdb
, struct ctdb_req_header
*hdr
);
736 void ctdb_queue_packet_opcode(struct ctdb_context
*ctdb
, struct ctdb_req_header
*hdr
, unsigned opcode
);
737 int ctdb_ltdb_lock_requeue(struct ctdb_db_context
*ctdb_db
,
738 TDB_DATA key
, struct ctdb_req_header
*hdr
,
739 void (*recv_pkt
)(void *, struct ctdb_req_header
*),
740 void *recv_context
, bool ignore_generation
);
741 int ctdb_ltdb_lock_fetch_requeue(struct ctdb_db_context
*ctdb_db
,
742 TDB_DATA key
, struct ctdb_ltdb_header
*header
,
743 struct ctdb_req_header
*hdr
, TDB_DATA
*data
,
744 void (*recv_pkt
)(void *, struct ctdb_req_header
*),
745 void *recv_context
, bool ignore_generation
);
746 void ctdb_input_pkt(struct ctdb_context
*ctdb
, struct ctdb_req_header
*);
748 struct ctdb_call_state
*ctdb_call_local_send(struct ctdb_db_context
*ctdb_db
,
749 struct ctdb_call
*call
,
750 struct ctdb_ltdb_header
*header
,
754 int ctdb_start_daemon(struct ctdb_context
*ctdb
, bool do_fork
);
757 queue a packet for sending
759 int ctdb_queue_send(struct ctdb_queue
*queue
, uint8_t *data
, uint32_t length
);
762 setup the fd used by the queue
764 int ctdb_queue_set_fd(struct ctdb_queue
*queue
, int fd
);
767 setup a packet queue on a socket
769 struct ctdb_queue
*ctdb_queue_setup(struct ctdb_context
*ctdb
,
770 TALLOC_CTX
*mem_ctx
, int fd
, int alignment
,
772 ctdb_queue_cb_fn_t callback
,
773 void *private_data
, const char *fmt
, ...)
774 PRINTF_ATTRIBUTE(7,8);
777 allocate a packet for use in client<->daemon communication
779 struct ctdb_req_header
*_ctdbd_allocate_pkt(struct ctdb_context
*ctdb
,
781 enum ctdb_operation operation
,
782 size_t length
, size_t slength
,
784 #define ctdbd_allocate_pkt(ctdb, mem_ctx, operation, length, type) \
785 (type *)_ctdbd_allocate_pkt(ctdb, mem_ctx, operation, length, sizeof(type), #type)
787 struct ctdb_req_header
*_ctdb_transport_allocate(struct ctdb_context
*ctdb
,
789 enum ctdb_operation operation
,
790 size_t length
, size_t slength
,
792 #define ctdb_transport_allocate(ctdb, mem_ctx, operation, length, type) \
793 (type *)_ctdb_transport_allocate(ctdb, mem_ctx, operation, length, sizeof(type), #type)
795 int ctdb_queue_length(struct ctdb_queue
*queue
);
798 lock a record in the ltdb, given a key
800 int ctdb_ltdb_lock(struct ctdb_db_context
*ctdb_db
, TDB_DATA key
);
803 unlock a record in the ltdb, given a key
805 int ctdb_ltdb_unlock(struct ctdb_db_context
*ctdb_db
, TDB_DATA key
);
808 int ctdb_client_send_message(struct ctdb_context
*ctdb
, uint32_t vnn
,
809 uint64_t srvid
, TDB_DATA data
);
814 int ctdb_daemon_send_message(struct ctdb_context
*ctdb
, uint32_t pnn
,
815 uint64_t srvid
, TDB_DATA data
);
818 int ctdb_daemon_call_recv(struct ctdb_call_state
*state
, struct ctdb_call
*call
);
820 struct ctdb_call_state
*ctdb_daemon_call_send_remote(struct ctdb_db_context
*ctdb_db
,
821 struct ctdb_call
*call
,
822 struct ctdb_ltdb_header
*header
);
824 int ctdb_call_local(struct ctdb_db_context
*ctdb_db
, struct ctdb_call
*call
,
825 struct ctdb_ltdb_header
*header
, TALLOC_CTX
*mem_ctx
,
826 TDB_DATA
*data
, bool updatetdb
);
828 #define ctdb_reqid_find(ctdb, reqid, type) (type *)_ctdb_reqid_find(ctdb, reqid, #type, __location__)
830 int ctdb_socket_connect(struct ctdb_context
*ctdb
);
831 void ctdb_client_read_cb(uint8_t *data
, size_t cnt
, void *args
);
833 #define CTDB_BAD_REQID ((uint32_t)-1)
834 uint32_t ctdb_reqid_new(struct ctdb_context
*ctdb
, void *state
);
835 void *_ctdb_reqid_find(struct ctdb_context
*ctdb
, uint32_t reqid
, const char *type
, const char *location
);
836 void ctdb_reqid_remove(struct ctdb_context
*ctdb
, uint32_t reqid
);
838 void ctdb_request_control(struct ctdb_context
*ctdb
, struct ctdb_req_header
*hdr
);
839 void ctdb_reply_control(struct ctdb_context
*ctdb
, struct ctdb_req_header
*hdr
);
841 int ctdb_daemon_send_control(struct ctdb_context
*ctdb
, uint32_t destnode
,
842 uint64_t srvid
, uint32_t opcode
, uint32_t client_id
, uint32_t flags
,
844 ctdb_control_callback_fn_t callback
,
847 int32_t ctdb_control_db_attach(struct ctdb_context
*ctdb
, TDB_DATA indata
,
848 TDB_DATA
*outdata
, uint64_t tdb_flags
,
849 bool persistent
, uint32_t client_id
,
850 struct ctdb_req_control
*c
,
852 int32_t ctdb_control_db_detach(struct ctdb_context
*ctdb
, TDB_DATA indata
,
855 int ctdb_daemon_set_call(struct ctdb_context
*ctdb
, uint32_t db_id
,
856 ctdb_fn_t fn
, int id
);
858 int ctdb_control(struct ctdb_context
*ctdb
, uint32_t destnode
, uint64_t srvid
,
859 uint32_t opcode
, uint32_t flags
, TDB_DATA data
,
860 TALLOC_CTX
*mem_ctx
, TDB_DATA
*outdata
, int32_t *status
,
861 struct timeval
*timeout
, char **errormsg
);
862 int ctdb_control_recv(struct ctdb_context
*ctdb
,
863 struct ctdb_client_control_state
*state
,
865 TDB_DATA
*outdata
, int32_t *status
, char **errormsg
);
867 struct ctdb_client_control_state
*
868 ctdb_control_send(struct ctdb_context
*ctdb
,
869 uint32_t destnode
, uint64_t srvid
,
870 uint32_t opcode
, uint32_t flags
, TDB_DATA data
,
872 struct timeval
*timeout
,
878 #define CHECK_CONTROL_DATA_SIZE(size) do { \
879 if (indata.dsize != size) { \
880 DEBUG(0,(__location__ " Invalid data size in opcode %u. Got %u expected %u\n", \
881 opcode, (unsigned)indata.dsize, (unsigned)size)); \
886 #define CHECK_CONTROL_MIN_DATA_SIZE(size) do { \
887 if (indata.dsize < size) { \
888 DEBUG(0,(__location__ " Invalid data size in opcode %u. Got %u expected >= %u\n", \
889 opcode, (unsigned)indata.dsize, (unsigned)size)); \
894 int ctdb_control_getvnnmap(struct ctdb_context
*ctdb
, uint32_t opcode
, TDB_DATA indata
, TDB_DATA
*outdata
);
895 int ctdb_control_setvnnmap(struct ctdb_context
*ctdb
, uint32_t opcode
, TDB_DATA indata
, TDB_DATA
*outdata
);
896 int ctdb_control_getdbmap(struct ctdb_context
*ctdb
, uint32_t opcode
, TDB_DATA indata
, TDB_DATA
*outdata
);
897 int ctdb_control_getnodemap(struct ctdb_context
*ctdb
, uint32_t opcode
, TDB_DATA indata
, TDB_DATA
*outdata
);
898 int ctdb_control_getnodesfile(struct ctdb_context
*ctdb
, uint32_t opcode
, TDB_DATA indata
, TDB_DATA
*outdata
);
901 /* structure used for pulldb control */
902 struct ctdb_control_pulldb
{
907 /* structure used for sending lists of records */
908 struct ctdb_marshall_buffer
{
915 structure for setting a tunable
917 struct ctdb_control_set_tunable
{
924 structure for getting a tunable
926 struct ctdb_control_get_tunable
{
932 structure for listing tunables
934 struct ctdb_control_list_tunable
{
936 /* returns a : separated list of tunable names */
941 struct ctdb_control_wipe_database
{
943 uint32_t transaction_id
;
947 state of a in-progress ctdb call in client
949 struct ctdb_client_call_state
{
950 enum call_state state
;
952 struct ctdb_db_context
*ctdb_db
;
953 struct ctdb_call
*call
;
955 void (*fn
)(struct ctdb_client_call_state
*);
961 int32_t ctdb_control_traverse_start_ext(struct ctdb_context
*ctdb
,
966 int32_t ctdb_control_traverse_start(struct ctdb_context
*ctdb
, TDB_DATA indata
,
967 TDB_DATA
*outdata
, uint32_t srcnode
, uint32_t client_id
);
968 int32_t ctdb_control_traverse_all(struct ctdb_context
*ctdb
, TDB_DATA data
, TDB_DATA
*outdata
);
969 int32_t ctdb_control_traverse_all_ext(struct ctdb_context
*ctdb
, TDB_DATA data
, TDB_DATA
*outdata
);
970 int32_t ctdb_control_traverse_data(struct ctdb_context
*ctdb
, TDB_DATA data
, TDB_DATA
*outdata
);
971 int32_t ctdb_control_traverse_kill(struct ctdb_context
*ctdb
, TDB_DATA indata
,
972 TDB_DATA
*outdata
, uint32_t srcnode
);
974 int ctdb_dispatch_message(struct ctdb_context
*ctdb
, uint64_t srvid
, TDB_DATA data
);
975 bool ctdb_check_message_handler(struct ctdb_context
*ctdb
, uint64_t srvid
);
977 int daemon_register_message_handler(struct ctdb_context
*ctdb
, uint32_t client_id
, uint64_t srvid
);
978 int ctdb_deregister_message_handler(struct ctdb_context
*ctdb
, uint64_t srvid
, void *private_data
);
979 int daemon_deregister_message_handler(struct ctdb_context
*ctdb
, uint32_t client_id
, uint64_t srvid
);
980 int daemon_check_srvids(struct ctdb_context
*ctdb
, TDB_DATA indata
,
983 int32_t ctdb_ltdb_enable_seqnum(struct ctdb_context
*ctdb
, uint32_t db_id
);
984 int32_t ctdb_ltdb_update_seqnum(struct ctdb_context
*ctdb
, uint32_t db_id
, uint32_t srcnode
);
986 struct ctdb_rec_data
*ctdb_marshall_record(TALLOC_CTX
*mem_ctx
, uint32_t reqid
,
987 TDB_DATA key
, struct ctdb_ltdb_header
*, TDB_DATA data
);
989 struct ctdb_rec_data
*ctdb_marshall_loop_next(struct ctdb_marshall_buffer
*m
, struct ctdb_rec_data
*r
,
991 struct ctdb_ltdb_header
*header
,
992 TDB_DATA
*key
, TDB_DATA
*data
);
994 int32_t ctdb_control_pull_db(struct ctdb_context
*ctdb
, TDB_DATA indata
, TDB_DATA
*outdata
);
995 int32_t ctdb_control_push_db(struct ctdb_context
*ctdb
, TDB_DATA indata
);
997 int32_t ctdb_control_set_recmode(struct ctdb_context
*ctdb
,
998 struct ctdb_req_control
*c
,
999 TDB_DATA indata
, bool *async_reply
,
1000 const char **errormsg
);
1001 void ctdb_request_control_reply(struct ctdb_context
*ctdb
, struct ctdb_req_control
*c
,
1002 TDB_DATA
*outdata
, int32_t status
, const char *errormsg
);
1004 int32_t ctdb_control_freeze(struct ctdb_context
*ctdb
, struct ctdb_req_control
*c
, bool *async_reply
);
1005 int32_t ctdb_control_thaw(struct ctdb_context
*ctdb
, uint32_t priority
,
1006 bool check_recmode
);
1008 int ctdb_start_recoverd(struct ctdb_context
*ctdb
);
1009 void ctdb_stop_recoverd(struct ctdb_context
*ctdb
);
1011 uint32_t ctdb_get_num_active_nodes(struct ctdb_context
*ctdb
);
1013 void ctdb_disable_monitoring(struct ctdb_context
*ctdb
);
1014 void ctdb_enable_monitoring(struct ctdb_context
*ctdb
);
1015 void ctdb_stop_monitoring(struct ctdb_context
*ctdb
);
1016 void ctdb_wait_for_first_recovery(struct ctdb_context
*ctdb
);
1017 int ctdb_tcp_init(struct ctdb_context
*ctdb
);
1018 int ctdb_ibw_init(struct ctdb_context
*ctdb
);
1019 void ctdb_start_tcp_tickle_update(struct ctdb_context
*ctdb
);
1020 void ctdb_send_keepalive(struct ctdb_context
*ctdb
, uint32_t destnode
);
1021 void ctdb_start_keepalive(struct ctdb_context
*ctdb
);
1022 void ctdb_stop_keepalive(struct ctdb_context
*ctdb
);
1023 int32_t ctdb_run_eventscripts(struct ctdb_context
*ctdb
, struct ctdb_req_control
*c
, TDB_DATA data
, bool *async_reply
);
1026 void ctdb_daemon_cancel_controls(struct ctdb_context
*ctdb
, struct ctdb_node
*node
);
1027 void ctdb_call_resend_all(struct ctdb_context
*ctdb
);
1028 void ctdb_node_dead(struct ctdb_node
*node
);
1029 void ctdb_node_connected(struct ctdb_node
*node
);
1030 bool ctdb_blocking_freeze(struct ctdb_context
*ctdb
);
1031 bool set_scheduler(void);
1032 void reset_scheduler(void);
1034 struct tevent_signal
*ctdb_init_sigchld(struct ctdb_context
*ctdb
);
1035 void ctdb_track_child(struct ctdb_context
*ctdb
, pid_t pid
);
1036 pid_t
ctdb_fork(struct ctdb_context
*ctdb
);
1037 void ctdb_set_child_info(TALLOC_CTX
*mem_ctx
, const char *child_name_fmt
, ...);
1038 int ctdb_kill(struct ctdb_context
*ctdb
, pid_t pid
, int signum
);
1040 int32_t ctdb_control_takeover_ip(struct ctdb_context
*ctdb
,
1041 struct ctdb_req_control
*c
,
1044 int32_t ctdb_control_release_ip(struct ctdb_context
*ctdb
,
1045 struct ctdb_req_control
*c
,
1048 int32_t ctdb_control_ipreallocated(struct ctdb_context
*ctdb
,
1049 struct ctdb_req_control
*c
,
1051 int32_t ctdb_control_start_recovery(struct ctdb_context
*ctdb
,
1052 struct ctdb_req_control
*c
,
1054 int32_t ctdb_control_end_recovery(struct ctdb_context
*ctdb
,
1055 struct ctdb_req_control
*c
,
1058 int ctdb_ctrl_takeover_ip(struct ctdb_context
*ctdb
, struct timeval timeout
,
1059 uint32_t destnode
, struct ctdb_public_ip
*ip
);
1060 int ctdb_ctrl_release_ip(struct ctdb_context
*ctdb
, struct timeval timeout
,
1061 uint32_t destnode
, struct ctdb_public_ip
*ip
);
1063 int32_t ctdb_control_get_public_ips(struct ctdb_context
*ctdb
,
1064 struct ctdb_req_control
*c
,
1066 int ctdb_ctrl_get_public_ips(struct ctdb_context
*ctdb
,
1067 struct timeval timeout
,
1069 TALLOC_CTX
*mem_ctx
,
1070 struct ctdb_all_public_ips
**ips
);
1071 #define CTDB_PUBLIC_IP_FLAGS_ONLY_AVAILABLE 0x00010000
1072 int ctdb_ctrl_get_public_ips_flags(struct ctdb_context
*ctdb
,
1073 struct timeval timeout
, uint32_t destnode
,
1074 TALLOC_CTX
*mem_ctx
,
1076 struct ctdb_all_public_ips
**ips
);
1078 struct ctdb_control_iface_info
{
1079 char name
[CTDB_IFACE_SIZE
+2];
1080 uint16_t link_state
;
1081 uint32_t references
;
1084 struct ctdb_control_public_ip_info
{
1085 struct ctdb_public_ip ip
;
1086 uint32_t active_idx
;
1088 struct ctdb_control_iface_info ifaces
[1];
1091 struct ctdb_control_get_ifaces
{
1093 struct ctdb_control_iface_info ifaces
[1];
1096 int32_t ctdb_control_get_public_ip_info(struct ctdb_context
*ctdb
,
1097 struct ctdb_req_control
*c
,
1100 int32_t ctdb_control_get_ifaces(struct ctdb_context
*ctdb
,
1101 struct ctdb_req_control
*c
,
1103 int32_t ctdb_control_set_iface_link(struct ctdb_context
*ctdb
,
1104 struct ctdb_req_control
*c
,
1106 int ctdb_ctrl_get_public_ip_info(struct ctdb_context
*ctdb
,
1107 struct timeval timeout
, uint32_t destnode
,
1108 TALLOC_CTX
*mem_ctx
,
1109 const ctdb_sock_addr
*addr
,
1110 struct ctdb_control_public_ip_info
**info
);
1111 int ctdb_ctrl_get_ifaces(struct ctdb_context
*ctdb
,
1112 struct timeval timeout
, uint32_t destnode
,
1113 TALLOC_CTX
*mem_ctx
,
1114 struct ctdb_control_get_ifaces
**ifaces
);
1115 int ctdb_ctrl_set_iface_link(struct ctdb_context
*ctdb
,
1116 struct timeval timeout
, uint32_t destnode
,
1117 TALLOC_CTX
*mem_ctx
,
1118 const struct ctdb_control_iface_info
*info
);
1120 /* from takeover/system.c */
1121 uint32_t uint16_checksum(uint16_t *data
, size_t n
);
1122 int ctdb_sys_send_arp(const ctdb_sock_addr
*addr
, const char *iface
);
1123 bool ctdb_sys_have_ip(ctdb_sock_addr
*addr
);
1124 char *ctdb_sys_find_ifname(ctdb_sock_addr
*addr
);
1125 bool ctdb_sys_check_iface_exists(const char *iface
);
1126 int ctdb_get_peer_pid(const int fd
, pid_t
*peer_pid
);
1127 int ctdb_sys_send_tcp(const ctdb_sock_addr
*dest
,
1128 const ctdb_sock_addr
*src
,
1129 uint32_t seq
, uint32_t ack
, int rst
);
1131 /* Details of a byte range lock */
1132 struct ctdb_lock_info
{
1139 int ctdb_set_process_name(const char *name
);
1141 typedef void (*client_async_callback
)(struct ctdb_context
*ctdb
, uint32_t node_pnn
, int32_t res
, TDB_DATA outdata
, void *callback_data
);
1143 int ctdb_set_public_addresses(struct ctdb_context
*ctdb
, bool check_addresses
);
1144 int ctdb_set_single_public_ip(struct ctdb_context
*ctdb
,
1147 int ctdb_set_notification_script(struct ctdb_context
*ctdb
, const char *script
);
1148 int ctdb_takeover_run(struct ctdb_context
*ctdb
, struct ctdb_node_map
*nodemap
,
1149 uint32_t *force_rebalance_nodes
,
1150 client_async_callback fail_callback
, void *callback_data
);
1152 int32_t ctdb_control_tcp_client(struct ctdb_context
*ctdb
, uint32_t client_id
,
1154 int32_t ctdb_control_tcp_add(struct ctdb_context
*ctdb
, TDB_DATA indata
, bool tcp_update_needed
);
1155 int32_t ctdb_control_tcp_remove(struct ctdb_context
*ctdb
, TDB_DATA indata
);
1156 int32_t ctdb_control_startup(struct ctdb_context
*ctdb
, uint32_t vnn
);
1157 int32_t ctdb_control_kill_tcp(struct ctdb_context
*ctdb
, TDB_DATA indata
);
1158 int32_t ctdb_control_send_gratious_arp(struct ctdb_context
*ctdb
, TDB_DATA indata
);
1159 int32_t ctdb_control_get_tcp_tickle_list(struct ctdb_context
*ctdb
, TDB_DATA indata
, TDB_DATA
*outdata
);
1160 int32_t ctdb_control_set_tcp_tickle_list(struct ctdb_context
*ctdb
, TDB_DATA indata
);
1162 void ctdb_takeover_client_destructor_hook(struct ctdb_client
*client
);
1163 int ctdb_event_script(struct ctdb_context
*ctdb
, enum ctdb_eventscript_call call
);
1164 int ctdb_event_script_args(struct ctdb_context
*ctdb
, enum ctdb_eventscript_call call
,
1165 const char *fmt
, ...) PRINTF_ATTRIBUTE(3,4);
1166 int ctdb_event_script_callback(struct ctdb_context
*ctdb
,
1167 TALLOC_CTX
*mem_ctx
,
1168 void (*callback
)(struct ctdb_context
*, int, void *),
1170 enum ctdb_eventscript_call call
,
1171 const char *fmt
, ...) PRINTF_ATTRIBUTE(6,7);
1172 void ctdb_release_all_ips(struct ctdb_context
*ctdb
);
1174 void set_nonblocking(int fd
);
1175 void set_close_on_exec(int fd
);
1177 bool ctdb_recovery_have_lock(struct ctdb_context
*ctdb
);
1178 bool ctdb_recovery_lock(struct ctdb_context
*ctdb
);
1179 void ctdb_recovery_unlock(struct ctdb_context
*ctdb
);
1181 int ctdb_set_recovery_lock_file(struct ctdb_context
*ctdb
, const char *file
);
1183 int32_t ctdb_control_get_tunable(struct ctdb_context
*ctdb
, TDB_DATA indata
,
1185 int32_t ctdb_control_set_tunable(struct ctdb_context
*ctdb
, TDB_DATA indata
);
1186 int32_t ctdb_control_list_tunables(struct ctdb_context
*ctdb
, TDB_DATA
*outdata
);
1187 int32_t ctdb_control_try_delete_records(struct ctdb_context
*ctdb
, TDB_DATA indata
, TDB_DATA
*outdata
);
1188 int32_t ctdb_control_receive_records(struct ctdb_context
*ctdb
, TDB_DATA indata
, TDB_DATA
*outdata
);
1189 int32_t ctdb_control_add_public_address(struct ctdb_context
*ctdb
, TDB_DATA indata
);
1190 int32_t ctdb_control_del_public_address(struct ctdb_context
*ctdb
,
1191 struct ctdb_req_control
*c
,
1192 TDB_DATA recdata
, bool *async_reply
);
1194 void ctdb_tunables_set_defaults(struct ctdb_context
*ctdb
);
1196 int32_t ctdb_control_modflags(struct ctdb_context
*ctdb
, TDB_DATA indata
);
1198 int ctdb_ctrl_get_all_tunables(struct ctdb_context
*ctdb
,
1199 struct timeval timeout
,
1201 struct ctdb_tunable
*tunables
);
1203 void ctdb_start_freeze(struct ctdb_context
*ctdb
, uint32_t priority
);
1205 bool parse_ip_mask(const char *s
, const char *iface
, ctdb_sock_addr
*addr
, unsigned *mask
);
1206 bool parse_ip_port(const char *s
, ctdb_sock_addr
*addr
);
1207 bool parse_ip(const char *s
, const char *iface
, unsigned port
, ctdb_sock_addr
*addr
);
1208 bool parse_ipv4(const char *s
, unsigned port
, struct sockaddr_in
*sin
);
1211 int ctdb_sys_open_capture_socket(const char *iface
, void **private_data
);
1212 int ctdb_sys_close_capture_socket(void *private_data
);
1213 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
);
1215 int ctdb_ctrl_killtcp(struct ctdb_context
*ctdb
,
1216 struct timeval timeout
,
1218 struct ctdb_control_killtcp
*killtcp
);
1220 int ctdb_ctrl_add_public_ip(struct ctdb_context
*ctdb
,
1221 struct timeval timeout
,
1223 struct ctdb_control_ip_iface
*pub
);
1225 int ctdb_ctrl_del_public_ip(struct ctdb_context
*ctdb
,
1226 struct timeval timeout
,
1228 struct ctdb_control_ip_iface
*pub
);
1230 int ctdb_ctrl_gratious_arp(struct ctdb_context
*ctdb
,
1231 struct timeval timeout
,
1233 ctdb_sock_addr
*addr
,
1234 const char *ifname
);
1236 int ctdb_ctrl_get_tcp_tickles(struct ctdb_context
*ctdb
,
1237 struct timeval timeout
,
1239 TALLOC_CTX
*mem_ctx
,
1240 ctdb_sock_addr
*addr
,
1241 struct ctdb_control_tcp_tickle_list
**list
);
1244 int32_t ctdb_control_register_server_id(struct ctdb_context
*ctdb
,
1247 int32_t ctdb_control_check_server_id(struct ctdb_context
*ctdb
,
1249 int32_t ctdb_control_unregister_server_id(struct ctdb_context
*ctdb
,
1251 int32_t ctdb_control_get_server_id_list(struct ctdb_context
*ctdb
,
1253 int32_t ctdb_control_uptime(struct ctdb_context
*ctdb
,
1256 int ctdb_attach_databases(struct ctdb_context
*ctdb
);
1258 int32_t ctdb_control_persistent_store(struct ctdb_context
*ctdb
,
1259 struct ctdb_req_control
*c
,
1260 TDB_DATA recdata
, bool *async_reply
);
1261 int32_t ctdb_control_update_record(struct ctdb_context
*ctdb
,
1262 struct ctdb_req_control
*c
, TDB_DATA recdata
,
1265 int32_t ctdb_control_trans3_commit(struct ctdb_context
*ctdb
,
1266 struct ctdb_req_control
*c
,
1267 TDB_DATA recdata
, bool *async_reply
);
1269 void ctdb_persistent_finish_trans3_commits(struct ctdb_context
*ctdb
);
1271 int32_t ctdb_control_transaction_start(struct ctdb_context
*ctdb
, uint32_t id
);
1272 int32_t ctdb_control_transaction_commit(struct ctdb_context
*ctdb
, uint32_t id
);
1273 int32_t ctdb_control_transaction_cancel(struct ctdb_context
*ctdb
);
1274 int32_t ctdb_control_wipe_database(struct ctdb_context
*ctdb
, TDB_DATA indata
);
1275 int32_t ctdb_control_db_set_healthy(struct ctdb_context
*ctdb
, TDB_DATA indata
);
1276 int32_t ctdb_control_db_get_health(struct ctdb_context
*ctdb
,
1281 int ctdb_repack(struct ctdb_context
*ctdb
, int argc
, const char **argv
);
1283 int32_t ctdb_monitoring_mode(struct ctdb_context
*ctdb
);
1284 bool ctdb_stopped_monitoring(struct ctdb_context
*ctdb
);
1285 int ctdb_set_child_logging(struct ctdb_context
*ctdb
);
1286 void lockdown_memory(bool valgrinding
);
1288 struct client_async_data
{
1289 enum ctdb_controls opcode
;
1290 bool dont_log_errors
;
1292 uint32_t fail_count
;
1293 client_async_callback callback
;
1294 client_async_callback fail_callback
;
1295 void *callback_data
;
1297 void ctdb_client_async_add(struct client_async_data
*data
, struct ctdb_client_control_state
*state
);
1298 int ctdb_client_async_wait(struct ctdb_context
*ctdb
, struct client_async_data
*data
);
1299 int ctdb_client_async_control(struct ctdb_context
*ctdb
,
1300 enum ctdb_controls opcode
,
1303 struct timeval timeout
,
1304 bool dont_log_errors
,
1306 client_async_callback client_callback
,
1307 client_async_callback fail_callback
,
1308 void *callback_data
);
1310 struct ctdb_node_map
*
1311 ctdb_node_list_to_map(struct ctdb_node
**nodes
, uint32_t num_nodes
,
1312 TALLOC_CTX
*mem_ctx
);
1313 struct ctdb_node_map
*ctdb_read_nodes_file(TALLOC_CTX
*mem_ctx
,
1315 void ctdb_load_nodes_file(struct ctdb_context
*ctdb
);
1317 int ctdb_control_reload_nodes_file(struct ctdb_context
*ctdb
, uint32_t opcode
);
1319 int32_t ctdb_dump_memory(struct ctdb_context
*ctdb
, TDB_DATA
*outdata
);
1320 int32_t ctdb_control_get_capabilities(struct ctdb_context
*ctdb
, TDB_DATA
*outdata
);
1322 char *ctdb_addr_to_str(ctdb_sock_addr
*addr
);
1323 unsigned ctdb_addr_to_port(ctdb_sock_addr
*addr
);
1324 void ctdb_canonicalize_ip(const ctdb_sock_addr
*ip
, ctdb_sock_addr
*cip
);
1326 int32_t ctdb_control_recd_ping(struct ctdb_context
*ctdb
);
1327 int32_t ctdb_control_set_recmaster(struct ctdb_context
*ctdb
, uint32_t opcode
, TDB_DATA indata
);
1329 extern int script_log_level
;
1330 extern bool fast_start
;
1331 extern const char *ctdbd_pidfile
;
1333 int32_t ctdb_control_get_event_script_status(struct ctdb_context
*ctdb
,
1337 int ctdb_ctrl_report_recd_lock_latency(struct ctdb_context
*ctdb
, struct timeval timeout
, double latency
);
1339 int32_t ctdb_control_stop_node(struct ctdb_context
*ctdb
);
1340 int32_t ctdb_control_continue_node(struct ctdb_context
*ctdb
);
1342 void ctdb_stop_vacuuming(struct ctdb_context
*ctdb
);
1343 int ctdb_vacuum_init(struct ctdb_db_context
*ctdb_db
);
1345 int32_t ctdb_control_enable_script(struct ctdb_context
*ctdb
, TDB_DATA indata
);
1346 int32_t ctdb_control_disable_script(struct ctdb_context
*ctdb
, TDB_DATA indata
);
1348 void ctdb_local_node_got_banned(struct ctdb_context
*ctdb
);
1349 int32_t ctdb_control_set_ban_state(struct ctdb_context
*ctdb
, TDB_DATA indata
);
1350 int32_t ctdb_control_get_ban_state(struct ctdb_context
*ctdb
, TDB_DATA
*outdata
);
1351 int32_t ctdb_control_set_db_priority(struct ctdb_context
*ctdb
, TDB_DATA indata
,
1352 uint32_t client_id
);
1353 void ctdb_ban_self(struct ctdb_context
*ctdb
);
1355 int32_t ctdb_control_register_notify(struct ctdb_context
*ctdb
, uint32_t client_id
, TDB_DATA indata
);
1357 int32_t ctdb_control_deregister_notify(struct ctdb_context
*ctdb
, uint32_t client_id
, TDB_DATA indata
);
1359 struct ctdb_log_state
*ctdb_vfork_with_logging(TALLOC_CTX
*mem_ctx
,
1360 struct ctdb_context
*ctdb
,
1361 const char *log_prefix
,
1364 const char **helper_argv
,
1365 void (*logfn
)(const char *, uint16_t, void *),
1366 void *logfn_private
, pid_t
*pid
);
1369 int32_t ctdb_control_process_exists(struct ctdb_context
*ctdb
, pid_t pid
);
1370 struct ctdb_client
*ctdb_find_client_by_pid(struct ctdb_context
*ctdb
, pid_t pid
);
1372 int32_t ctdb_control_get_db_seqnum(struct ctdb_context
*ctdb
,
1376 int ctdb_load_persistent_health(struct ctdb_context
*ctdb
,
1377 struct ctdb_db_context
*ctdb_db
);
1378 int ctdb_update_persistent_health(struct ctdb_context
*ctdb
,
1379 struct ctdb_db_context
*ctdb_db
,
1380 const char *reason
,/* NULL means healthy */
1381 int num_healthy_nodes
);
1382 int ctdb_recheck_persistent_health(struct ctdb_context
*ctdb
);
1384 void ctdb_run_notification_script(struct ctdb_context
*ctdb
, const char *event
);
1386 int verify_remote_ip_allocation(struct ctdb_context
*ctdb
,
1387 struct ctdb_all_public_ips
*ips
,
1389 int update_ip_assignment_tree(struct ctdb_context
*ctdb
,
1390 struct ctdb_public_ip
*ip
);
1391 void clear_ip_assignment_tree(struct ctdb_context
*ctdb
);
1393 int ctdb_init_tevent_logging(struct ctdb_context
*ctdb
);
1395 int ctdb_statistics_init(struct ctdb_context
*ctdb
);
1397 int32_t ctdb_control_get_stat_history(struct ctdb_context
*ctdb
,
1398 struct ctdb_req_control
*c
,
1401 int ctdb_deferred_drop_all_ips(struct ctdb_context
*ctdb
);
1403 int ctdb_process_deferred_attach(struct ctdb_context
*ctdb
);
1406 * structure to pass to a schedule_for_deletion_control
1408 struct ctdb_control_schedule_for_deletion
{
1410 struct ctdb_ltdb_header hdr
;
1412 uint8_t key
[1]; /* key[] */
1415 int32_t ctdb_control_schedule_for_deletion(struct ctdb_context
*ctdb
,
1419 int32_t ctdb_local_schedule_for_deletion(struct ctdb_db_context
*ctdb_db
,
1420 const struct ctdb_ltdb_header
*hdr
,
1423 void ctdb_local_remove_from_delete_queue(struct ctdb_db_context
*ctdb_db
,
1424 const struct ctdb_ltdb_header
*hdr
,
1425 const TDB_DATA key
);
1427 struct ctdb_ltdb_header
*ctdb_header_from_record_handle(struct ctdb_record_handle
*h
);
1429 int ctdb_trackingdb_add_pnn(struct ctdb_context
*ctdb
, TDB_DATA
*data
, uint32_t pnn
);
1431 typedef void (*ctdb_trackingdb_cb
)(struct ctdb_context
*ctdb
, uint32_t pnn
, void *private_data
);
1433 void ctdb_trackingdb_traverse(struct ctdb_context
*ctdb
, TDB_DATA data
, ctdb_trackingdb_cb cb
, void *private_data
);
1435 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
);
1437 typedef void (*deferred_requeue_fn
)(void *call_context
, struct ctdb_req_header
*hdr
);
1439 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
);
1441 int ctdb_set_db_readonly(struct ctdb_context
*ctdb
, struct ctdb_db_context
*ctdb_db
);
1443 int ctdb_null_func(struct ctdb_call_info
*call
);
1445 int ctdb_fetch_func(struct ctdb_call_info
*call
);
1447 int ctdb_fetch_with_header_func(struct ctdb_call_info
*call
);
1449 void ctdb_db_statistics_reset(struct ctdb_db_context
*ctdb_db
);
1451 int32_t ctdb_control_get_db_statistics(struct ctdb_context
*ctdb
,
1455 int ctdb_set_db_sticky(struct ctdb_context
*ctdb
, struct ctdb_db_context
*ctdb_db
);
1458 description for a message to reload all ips via recovery master/daemon
1460 struct reloadips_all_reply
{
1465 int32_t ctdb_control_reload_public_ips(struct ctdb_context
*ctdb
, struct ctdb_req_control
*c
, bool *async_reply
);
1467 /* from server/ctdb_lock.c */
1468 struct lock_request
;
1470 int ctdb_lockall_mark_prio(struct ctdb_context
*ctdb
, uint32_t priority
);
1471 int ctdb_lockall_unmark_prio(struct ctdb_context
*ctdb
, uint32_t priority
);
1473 struct lock_request
*ctdb_lock_record(TALLOC_CTX
*mem_ctx
,
1474 struct ctdb_db_context
*ctdb_db
,
1477 void (*callback
)(void *, bool),
1478 void *private_data
);
1480 struct lock_request
*ctdb_lock_db(TALLOC_CTX
*mem_ctx
,
1481 struct ctdb_db_context
*ctdb_db
,
1483 void (*callback
)(void *, bool),
1484 void *private_data
);
1486 struct lock_request
*ctdb_lock_alldb_prio(TALLOC_CTX
*mem_ctx
,
1487 struct ctdb_context
*ctdb
,
1490 void (*callback
)(void *, bool),
1491 void *private_data
);
1493 struct lock_request
*ctdb_lock_alldb(TALLOC_CTX
*mem_ctx
,
1494 struct ctdb_context
*ctdb
,
1496 void (*callback
)(void *, bool),
1497 void *private_data
);
1499 int mkdir_p(const char *dir
, int mode
);
1500 void mkdir_p_or_die(const char *dir
, int mode
);
1502 ssize_t
sys_read(int fd
, void *buf
, size_t count
);
1503 ssize_t
sys_write(int fd
, const void *buf
, size_t count
);