2006-11-18 10:41:20 +11:00
/*
ctdb database library
Copyright ( C ) Andrew Tridgell 2006
2007-05-31 13:50:53 +10:00
This program is free software ; you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
2007-07-10 15:29:31 +10:00
the Free Software Foundation ; either version 3 of the License , or
2007-05-31 13:50:53 +10:00
( at your option ) any later version .
This program is distributed in the hope that it will be useful ,
2006-11-18 10:41:20 +11:00
but WITHOUT ANY WARRANTY ; without even the implied warranty of
2007-05-31 13:50:53 +10:00
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
You should have received a copy of the GNU General Public License
2007-07-10 15:29:31 +10:00
along with this program ; if not , see < http : //www.gnu.org/licenses/>.
2006-11-18 10:41:20 +11:00
*/
2007-01-23 11:38:45 +11:00
# ifndef _CTDB_PRIVATE_H
# define _CTDB_PRIVATE_H
2010-05-20 15:18:30 +09:30
# include "ctdb_client.h"
2007-05-25 13:05:25 +10:00
# include <sys/socket.h>
2006-11-18 10:41:20 +11:00
2008-04-01 15:34:54 +11:00
/*
2013-11-12 15:16:49 +11:00
* Structures to support SRVID requests and replies
2008-04-01 15:34:54 +11:00
*/
2013-08-16 20:10:10 +10:00
struct srvid_request {
2009-10-14 11:59:16 +11:00
uint32_t pnn ;
uint64_t srvid ;
2013-11-12 15:16:49 +11:00
} ;
struct srvid_request_data {
uint32_t pnn ;
uint64_t srvid ;
2013-08-16 20:10:10 +10:00
uint32_t data ;
2009-10-14 11:59:16 +11:00
} ;
2007-07-20 15:05:55 +10:00
/*
a tcp connection description
2010-08-18 12:36:03 +10:00
also used by tcp_add and tcp_remove controls
2007-07-20 15:05:55 +10:00
*/
struct ctdb_tcp_connection {
2008-08-19 14:58:29 +10:00
ctdb_sock_addr src_addr ;
ctdb_sock_addr dst_addr ;
2007-07-20 15:05:55 +10:00
} ;
/* the wire representation for a tcp tickle array */
struct ctdb_tcp_wire_array {
uint32_t num ;
struct ctdb_tcp_connection connections [ 1 ] ;
} ;
/* the list of tcp tickles used by get/set tcp tickle list */
struct ctdb_control_tcp_tickle_list {
2008-08-19 14:58:29 +10:00
ctdb_sock_addr addr ;
2007-07-20 15:05:55 +10:00
struct ctdb_tcp_wire_array tickles ;
} ;
/*
array of tcp connections
*/
struct ctdb_tcp_array {
uint32_t num ;
struct ctdb_tcp_connection * connections ;
} ;
2007-06-04 17:23:55 +10:00
/* all tunable variables go in here */
struct ctdb_tunable {
uint32_t max_redirect_count ;
2009-04-01 17:21:38 +11:00
uint32_t seqnum_interval ; /* unit is ms */
2007-06-04 17:23:55 +10:00
uint32_t control_timeout ;
uint32_t traverse_timeout ;
2007-06-06 10:25:46 +10:00
uint32_t keepalive_interval ;
uint32_t keepalive_limit ;
2007-06-04 20:22:44 +10:00
uint32_t recover_timeout ;
2007-06-06 10:25:46 +10:00
uint32_t recover_interval ;
2007-06-04 20:22:44 +10:00
uint32_t election_timeout ;
2007-06-05 17:43:19 +10:00
uint32_t takeover_timeout ;
2007-06-06 10:25:46 +10:00
uint32_t monitor_interval ;
2007-07-20 15:05:55 +10:00
uint32_t tickle_update_interval ;
2007-06-06 13:45:12 +10:00
uint32_t script_timeout ;
2009-12-14 15:53:23 +11:00
uint32_t script_timeout_count ; /* allow dodgy scripts to hang this many times in a row before we mark the node unhealthy */
2009-12-16 09:51:17 +11:00
uint32_t script_unhealthy_on_timeout ; /* obsolete */
2007-06-07 15:18:55 +10:00
uint32_t recovery_grace_period ;
uint32_t recovery_ban_period ;
2007-06-17 23:31:44 +10:00
uint32_t database_hash_size ;
2008-01-05 09:36:53 +11:00
uint32_t database_max_dead ;
2007-07-04 08:36:59 +10:00
uint32_t rerecovery_timeout ;
2007-10-15 13:22:58 +10:00
uint32_t enable_bans ;
2007-10-16 12:15:02 +10:00
uint32_t deterministic_public_ips ;
2008-03-03 09:19:30 +11:00
uint32_t reclock_ping_period ;
2008-03-03 12:52:16 +11:00
uint32_t no_ip_failback ;
2010-11-09 15:19:06 +11:00
uint32_t disable_ip_failover ;
2008-04-01 15:34:54 +11:00
uint32_t verbose_memory_names ;
2008-09-09 13:44:46 +10:00
uint32_t recd_ping_timeout ;
2008-09-17 14:17:41 +10:00
uint32_t recd_ping_failcount ;
2008-10-30 12:49:53 +11:00
uint32_t log_latency_ms ;
2009-05-14 10:33:25 +10:00
uint32_t reclock_latency_ms ;
2009-04-24 18:23:48 +10:00
uint32_t recovery_drop_all_ips ;
2009-05-01 01:18:27 +10:00
uint32_t verify_recovery_lock ;
2011-12-13 14:33:08 +01:00
uint32_t vacuum_interval ;
2009-07-29 13:25:43 +10:00
uint32_t vacuum_max_run_time ;
2009-07-28 23:09:28 +03:00
uint32_t repack_limit ;
2009-09-29 13:20:18 +10:00
uint32_t vacuum_limit ;
2009-10-21 15:20:55 +11:00
uint32_t max_queue_depth_drop_msg ;
2009-12-07 13:28:11 +01:00
uint32_t allow_unhealthy_db_read ;
2010-09-30 14:39:54 +10:00
uint32_t stat_history_interval ;
2011-02-23 15:46:36 +11:00
uint32_t deferred_attach_timeout ;
2010-12-20 17:42:25 +01:00
uint32_t vacuum_fast_path_count ;
2011-07-28 15:16:46 +10:00
uint32_t lcp2_public_ip_assignment ;
2011-09-02 16:42:10 +02:00
uint32_t allow_client_db_attach ;
2011-11-28 13:56:30 +11:00
uint32_t recover_pdb_by_seqnum ;
2012-02-28 06:58:59 +11:00
uint32_t deferred_rebalance_on_node_add ;
2012-03-20 11:31:59 +11:00
uint32_t fetch_collapse ;
2012-03-20 16:58:35 +11:00
uint32_t hopcount_make_sticky ;
uint32_t sticky_duration ;
uint32_t sticky_pindown ;
2012-03-22 11:00:27 +11:00
uint32_t no_ip_takeover ;
2012-05-21 13:11:38 +10:00
uint32_t db_record_count_warn ;
uint32_t db_record_size_warn ;
uint32_t db_size_warn ;
2012-05-25 12:27:59 +10:00
uint32_t pulldb_preallocation_size ;
2013-05-03 16:59:20 +10:00
uint32_t no_ip_host_on_all_disabled ;
2013-01-04 14:32:55 +11:00
uint32_t samba3_hack ;
2013-11-11 00:32:31 +11:00
uint32_t mutex_enabled ;
2014-07-15 12:13:53 +10:00
uint32_t lock_processes_per_db ;
2007-06-04 17:23:55 +10:00
} ;
2007-04-27 16:42:43 +02:00
2006-11-18 10:41:20 +11:00
/*
an installed ctdb remote call
*/
struct ctdb_registered_call {
struct ctdb_registered_call * next , * prev ;
uint32_t id ;
ctdb_fn_t fn ;
} ;
2007-04-18 18:39:02 +10:00
/*
2007-09-04 10:09:58 +10:00
check that a pnn is valid
2007-04-18 18:39:02 +10:00
*/
2007-09-04 10:09:58 +10:00
# define ctdb_validate_pnn(ctdb, pnn) (((uint32_t)(pnn)) < (ctdb)->num_nodes)
2007-04-18 18:39:02 +10:00
2007-04-10 19:33:21 +10:00
/* called from the queue code when a packet comes in. Called with data==NULL
on error */
2007-04-11 20:12:15 +02:00
typedef void ( * ctdb_queue_cb_fn_t ) ( uint8_t * data , size_t length ,
void * private_data ) ;
2007-04-10 19:33:21 +10:00
2007-04-26 14:27:49 +02:00
/* used for callbacks in ctdb_control requests */
typedef void ( * ctdb_control_callback_fn_t ) ( struct ctdb_context * ,
2007-05-18 23:48:29 +10:00
int32_t status , TDB_DATA data ,
2007-05-12 21:25:26 +10:00
const char * errormsg ,
2007-04-26 14:27:49 +02:00
void * private_data ) ;
2007-05-27 15:26:29 +10:00
/*
structure describing a connected client in the daemon
*/
struct ctdb_client {
struct ctdb_context * ctdb ;
int fd ;
struct ctdb_queue * queue ;
uint32_t client_id ;
2007-06-19 03:54:06 +10:00
pid_t pid ;
2007-05-27 15:26:29 +10:00
struct ctdb_tcp_list * tcp_list ;
2009-07-21 11:30:38 +02:00
uint32_t db_id ;
2008-07-17 13:50:55 +10:00
uint32_t num_persistent_updates ;
2009-10-23 15:24:51 +11:00
struct ctdb_client_notify_list * notify ;
2007-05-27 15:26:29 +10:00
} ;
2009-12-16 10:39:40 +01:00
struct ctdb_iface ;
2007-05-27 15:26:29 +10:00
2007-09-04 09:50:07 +10:00
/* state associated with a public ip address */
struct ctdb_vnn {
2007-09-04 18:20:29 +10:00
struct ctdb_vnn * prev , * next ;
2007-09-04 09:50:07 +10:00
2009-12-16 10:39:40 +01:00
struct ctdb_iface * iface ;
2009-12-14 18:52:06 +01:00
const char * * ifaces ;
2008-08-19 14:58:29 +10:00
ctdb_sock_addr public_address ;
2007-09-04 09:50:07 +10:00
uint8_t public_netmask_bits ;
/* the node number that is serving this public address, if any.
If no node serves this ip it is set to - 1 */
int32_t pnn ;
/* List of clients to tickle for this public address */
struct ctdb_tcp_array * tcp_array ;
/* whether we need to update the other nodes with changes to our list
of connected clients */
bool tcp_update_needed ;
2007-09-04 14:36:52 +10:00
/* a context to hang sending gratious arp events off */
TALLOC_CTX * takeover_ctx ;
2007-09-04 09:50:07 +10:00
struct ctdb_kill_tcp * killtcp ;
2012-07-11 14:46:07 +10:00
/* Set to true any time an update to this VNN is in flight.
This helps to avoid races . */
bool update_in_flight ;
2014-01-22 13:30:47 +11:00
/* If CTDB_CONTROL_DEL_PUBLIC_IP is received for this IP
* address then this flag is set . It will be deleted in the
* release IP callback . */
bool delete_pending ;
2007-09-04 09:50:07 +10:00
} ;
2006-11-18 10:41:20 +11:00
/*
state associated with one node
*/
struct ctdb_node {
struct ctdb_context * ctdb ;
2015-02-20 11:47:23 +11:00
ctdb_sock_addr address ;
2006-11-28 14:15:46 +11:00
const char * name ; /* for debug messages */
2007-04-11 20:12:15 +02:00
void * private_data ; /* private to transport */
2007-09-04 09:50:07 +10:00
uint32_t pnn ;
2007-04-28 20:40:26 +10:00
uint32_t flags ;
2007-05-18 19:19:35 +10:00
/* used by the dead node monitoring */
uint32_t dead_count ;
uint32_t rx_cnt ;
2007-05-19 10:20:19 +10:00
uint32_t tx_cnt ;
2007-05-18 23:48:29 +10:00
/* a list of controls pending to this node, so we can time them out quickly
if the node becomes disconnected */
struct daemon_control_state * pending_controls ;
2007-09-04 23:15:23 +10:00
/* used by the recovery daemon when distributing ip addresses
across the nodes . it needs to know which public ip ' s can be handled
by each node .
*/
2009-12-16 16:09:40 +01:00
struct ctdb_all_public_ips * known_public_ips ;
struct ctdb_all_public_ips * available_public_ips ;
2009-09-04 02:20:39 +10:00
/* used by the recovery dameon to track when a node should be banned */
struct ctdb_banning_state * ban_state ;
2006-11-18 10:41:20 +11:00
} ;
2006-11-18 13:45:04 +11:00
/*
2006-11-27 21:38:13 +11:00
transport specific methods
2006-11-18 13:45:04 +11:00
*/
2006-11-27 21:38:13 +11:00
struct ctdb_methods {
2007-05-30 13:26:50 +10:00
int ( * initialise ) ( struct ctdb_context * ) ; /* initialise transport structures */
2008-12-02 13:26:30 +11:00
int ( * start ) ( struct ctdb_context * ) ; /* start the transport */
2006-11-27 21:38:13 +11:00
int ( * add_node ) ( struct ctdb_node * ) ; /* setup a new node */
2008-12-02 13:26:30 +11:00
int ( * connect_node ) ( struct ctdb_node * ) ; /* connect to node */
2006-11-28 11:51:33 +11:00
int ( * queue_pkt ) ( struct ctdb_node * , uint8_t * data , uint32_t length ) ;
2007-04-19 10:37:44 +10:00
void * ( * allocate_pkt ) ( TALLOC_CTX * mem_ctx , size_t ) ;
2007-06-02 08:41:19 +10:00
void ( * shutdown ) ( struct ctdb_context * ) ; /* shutdown transport */
2007-10-19 08:58:30 +10:00
void ( * restart ) ( struct ctdb_node * ) ; /* stop and restart the connection */
2006-11-28 11:51:33 +11:00
} ;
/*
transport calls up to the ctdb layer
*/
struct ctdb_upcalls {
2006-11-28 17:56:10 +11:00
/* recv_pkt is called when a packet comes in */
2006-11-28 14:15:46 +11:00
void ( * recv_pkt ) ( struct ctdb_context * , uint8_t * data , uint32_t length ) ;
2006-11-28 17:56:10 +11:00
/* node_dead is called when an attempt to send to a node fails */
2006-11-28 14:15:46 +11:00
void ( * node_dead ) ( struct ctdb_node * ) ;
2006-11-28 17:56:10 +11:00
/* node_connected is called when a connection to a node is established */
void ( * node_connected ) ( struct ctdb_node * ) ;
2006-11-18 13:45:04 +11:00
} ;
2007-04-11 11:58:28 +10:00
/* list of message handlers - needs to be changed to a more efficient data
structure so we can find a message handler given a srvid quickly */
2013-02-21 13:16:15 +11:00
struct ctdb_message_list_header {
struct ctdb_message_list_header * next , * prev ;
2007-04-11 11:58:28 +10:00
struct ctdb_context * ctdb ;
2007-04-28 00:31:45 +10:00
uint64_t srvid ;
2013-02-21 13:16:15 +11:00
struct ctdb_message_list * m ;
} ;
struct ctdb_message_list {
struct ctdb_message_list * next , * prev ;
struct ctdb_message_list_header * h ;
2010-06-02 10:00:58 +10:00
ctdb_msg_fn_t message_handler ;
2007-04-11 11:58:28 +10:00
void * message_private ;
} ;
2007-04-10 06:03:39 +10:00
/* additional data required for the daemon mode */
struct ctdb_daemon_data {
int sd ;
char * name ;
2007-04-10 19:33:21 +10:00
struct ctdb_queue * queue ;
2007-04-10 06:03:39 +10:00
} ;
2007-04-03 19:41:00 +10:00
2010-09-29 10:38:41 +10:00
# define CTDB_UPDATE_STAT(ctdb, counter, value) \
{ \
if ( value > ctdb - > statistics . counter ) { \
ctdb - > statistics . counter = c - > hopcount ; \
} \
2010-09-29 10:58:18 +10:00
if ( value > ctdb - > statistics_current . counter ) { \
ctdb - > statistics_current . counter = c - > hopcount ; \
} \
2010-09-29 10:38:41 +10:00
}
# define CTDB_INCREMENT_STAT(ctdb, counter) \
{ \
ctdb - > statistics . counter + + ; \
2010-09-29 10:58:18 +10:00
ctdb - > statistics_current . counter + + ; \
2010-09-29 10:38:41 +10:00
}
# define CTDB_DECREMENT_STAT(ctdb, counter) \
{ \
if ( ctdb - > statistics . counter > 0 ) \
ctdb - > statistics . counter - - ; \
2010-09-29 10:58:18 +10:00
if ( ctdb - > statistics_current . counter > 0 ) \
ctdb - > statistics_current . counter - - ; \
2010-09-29 10:38:41 +10:00
}
2012-05-09 12:56:53 +10:00
# define CTDB_INCREMENT_DB_STAT(ctdb_db, counter) \
{ \
ctdb_db - > statistics . counter + + ; \
}
# define CTDB_DECREMENT_DB_STAT(ctdb_db, counter) \
{ \
if ( ctdb_db - > statistics . counter > 0 ) \
ctdb_db - > statistics . counter - - ; \
}
2010-09-29 10:38:41 +10:00
# define CTDB_UPDATE_RECLOCK_LATENCY(ctdb, name, counter, value) \
{ \
2012-05-09 12:56:53 +10:00
if ( value > ctdb - > statistics . counter . max ) \
2010-10-11 15:11:18 +11:00
ctdb - > statistics . counter . max = value ; \
2012-05-09 12:56:53 +10:00
if ( value > ctdb - > statistics_current . counter . max ) \
2010-10-11 15:11:18 +11:00
ctdb - > statistics_current . counter . max = value ; \
\
2012-05-09 12:56:53 +10:00
if ( ctdb - > statistics . counter . num = = 0 | | \
value < ctdb - > statistics . counter . min ) \
2010-10-11 15:11:18 +11:00
ctdb - > statistics . counter . min = value ; \
2012-05-09 12:56:53 +10:00
if ( ctdb - > statistics_current . counter . num = = 0 | | \
value < ctdb - > statistics_current . counter . min ) \
2010-10-11 15:11:18 +11:00
ctdb - > statistics_current . counter . min = value ; \
\
2012-05-09 12:56:53 +10:00
ctdb - > statistics . counter . total + = value ; \
ctdb - > statistics_current . counter . total + = value ; \
2010-10-11 15:11:18 +11:00
\
ctdb - > statistics . counter . num + + ; \
ctdb - > statistics_current . counter . num + + ; \
2010-09-29 10:38:41 +10:00
\
if ( ctdb - > tunable . reclock_latency_ms ! = 0 ) { \
if ( value * 1000 > ctdb - > tunable . reclock_latency_ms ) { \
2012-05-09 12:56:53 +10:00
DEBUG ( DEBUG_ERR , \
( " High RECLOCK latency %fs for operation %s \n " , \
value , name ) ) ; \
2010-09-29 10:38:41 +10:00
} \
} \
}
2012-11-14 15:51:59 +11:00
# define CTDB_UPDATE_DB_LATENCY(ctdb_db, operation, counter, value) \
2012-05-09 12:56:53 +10:00
{ \
if ( value > ctdb_db - > statistics . counter . max ) \
ctdb_db - > statistics . counter . max = value ; \
if ( ctdb_db - > statistics . counter . num = = 0 | | \
value < ctdb_db - > statistics . counter . min ) \
ctdb_db - > statistics . counter . min = value ; \
\
ctdb_db - > statistics . counter . total + = value ; \
ctdb_db - > statistics . counter . num + + ; \
\
2012-11-30 12:21:30 +11:00
if ( ctdb_db - > ctdb - > tunable . log_latency_ms ! = 0 ) { \
2012-11-14 15:51:59 +11:00
if ( value * 1000 > ctdb_db - > ctdb - > tunable . log_latency_ms ) { \
2012-05-09 12:56:53 +10:00
DEBUG ( DEBUG_ERR , \
2012-11-14 15:51:59 +11:00
( " High latency %.6fs for operation %s on database %s \n " , \
value , operation , ctdb_db - > db_name ) ) ; \
2012-05-09 12:56:53 +10:00
} \
} \
}
2010-09-29 10:38:41 +10:00
# define CTDB_UPDATE_LATENCY(ctdb, db, operation, counter, t) \
{ \
double l = timeval_elapsed ( & t ) ; \
2010-10-11 15:11:18 +11:00
\
if ( l > ctdb - > statistics . counter . max ) \
ctdb - > statistics . counter . max = l ; \
if ( l > ctdb - > statistics_current . counter . max ) \
ctdb - > statistics_current . counter . max = l ; \
\
2012-05-09 12:56:53 +10:00
if ( ctdb - > statistics . counter . num = = 0 | | \
l < ctdb - > statistics . counter . min ) \
2010-10-11 15:11:18 +11:00
ctdb - > statistics . counter . min = l ; \
2012-05-09 12:56:53 +10:00
if ( ctdb - > statistics_current . counter . num = = 0 | | \
l < ctdb - > statistics_current . counter . min ) \
2010-10-11 15:11:18 +11:00
ctdb - > statistics_current . counter . min = l ; \
\
ctdb - > statistics . counter . total + = l ; \
ctdb - > statistics_current . counter . total + = l ; \
\
ctdb - > statistics . counter . num + + ; \
ctdb - > statistics_current . counter . num + + ; \
2010-09-29 10:38:41 +10:00
\
2012-05-09 12:56:53 +10:00
if ( ctdb - > tunable . log_latency_ms ! = 0 ) { \
2010-09-29 10:38:41 +10:00
if ( l * 1000 > ctdb - > tunable . log_latency_ms ) { \
2012-05-09 12:56:53 +10:00
DEBUG ( DEBUG_WARNING , \
( " High latency %.6fs for operation %s on database %s \n " , \
l , operation , db - > db_name ) ) ; \
2010-09-29 10:38:41 +10:00
} \
} \
}
2007-05-03 16:18:03 +10:00
/* a structure that contains the elements required for the write record
control
*/
struct ctdb_write_record {
uint32_t dbid ;
uint32_t keylen ;
uint32_t datalen ;
unsigned char blob [ 1 ] ;
} ;
2007-05-12 14:34:21 +10:00
2007-05-12 15:15:27 +10:00
enum ctdb_freeze_mode { CTDB_FREEZE_NONE , CTDB_FREEZE_PENDING , CTDB_FREEZE_FROZEN } ;
2007-05-12 14:34:21 +10:00
2013-01-10 16:06:25 +11:00
enum ctdb_runstate {
CTDB_RUNSTATE_UNKNOWN ,
CTDB_RUNSTATE_INIT ,
CTDB_RUNSTATE_SETUP ,
2013-04-18 20:30:14 +10:00
CTDB_RUNSTATE_FIRST_RECOVERY ,
2013-01-10 16:06:25 +11:00
CTDB_RUNSTATE_STARTUP ,
CTDB_RUNSTATE_RUNNING ,
CTDB_RUNSTATE_SHUTDOWN ,
} ;
const char * runstate_to_string ( enum ctdb_runstate runstate ) ;
enum ctdb_runstate runstate_from_string ( const char * label ) ;
void ctdb_set_runstate ( struct ctdb_context * ctdb , enum ctdb_runstate runstate ) ;
2013-06-19 10:58:14 +10:00
void ctdb_shutdown_sequence ( struct ctdb_context * ctdb , int exit_code ) ;
2007-05-21 09:24:34 +10:00
# define CTDB_MONITORING_ACTIVE 0
# define CTDB_MONITORING_DISABLED 1
2009-10-12 12:08:39 +11:00
# define NUM_DB_PRIORITIES 3
2006-11-18 10:41:20 +11:00
/* main state of the ctdb daemon */
struct ctdb_context {
2010-08-18 09:16:31 +09:30
struct tevent_context * ev ;
2008-01-17 11:33:23 +11:00
struct timeval ctdbd_start_time ;
2008-07-02 13:55:59 +10:00
struct timeval last_recovery_started ;
struct timeval last_recovery_finished ;
2007-04-29 22:51:56 +10:00
uint32_t recovery_mode ;
2007-07-20 15:05:55 +10:00
TALLOC_CTX * tickle_update_context ;
2008-01-15 08:42:12 +11:00
TALLOC_CTX * keepalive_ctx ;
2011-09-06 17:02:19 +10:00
TALLOC_CTX * check_public_ifaces_ctx ;
2007-06-04 17:46:37 +10:00
struct ctdb_tunable tunable ;
2009-10-12 12:08:39 +11:00
enum ctdb_freeze_mode freeze_mode [ NUM_DB_PRIORITIES + 1 ] ;
struct ctdb_freeze_handle * freeze_handles [ NUM_DB_PRIORITIES + 1 ] ;
bool freeze_transaction_started ;
uint32_t freeze_transaction_id ;
2015-02-20 11:47:23 +11:00
ctdb_sock_addr * address ;
2006-11-28 17:56:10 +11:00
const char * name ;
2007-04-18 16:36:22 +02:00
const char * db_directory ;
2007-09-21 12:24:02 +10:00
const char * db_directory_persistent ;
2009-11-23 14:38:03 +01:00
const char * db_directory_state ;
2009-11-29 12:39:37 +01:00
struct tdb_wrap * db_persistent_health ;
2009-12-07 13:28:11 +01:00
uint32_t db_persistent_startup_generation ;
uint64_t db_persistent_check_errors ;
uint64_t max_persistent_check_errors ;
2007-04-26 15:28:13 +02:00
const char * transport ;
2007-06-02 11:36:42 +10:00
char * recovery_lock_file ;
int recovery_lock_fd ;
2007-09-04 10:06:36 +10:00
uint32_t pnn ; /* our own pnn */
2006-11-28 17:56:10 +11:00
uint32_t num_nodes ;
2006-12-01 09:01:11 +11:00
uint32_t num_connected ;
2006-12-01 15:45:24 +11:00
unsigned flags ;
2008-05-06 10:02:27 +10:00
uint32_t capabilities ;
2006-11-28 20:48:34 +11:00
struct idr_context * idr ;
2010-06-10 08:58:55 +09:30
int lastid ;
2006-11-28 17:56:10 +11:00
struct ctdb_node * * nodes ; /* array of nodes in the cluster - indexed by vnn */
2007-09-04 18:20:29 +10:00
struct ctdb_vnn * vnn ; /* list of public ip addresses and interfaces */
2007-10-10 09:42:32 +10:00
struct ctdb_vnn * single_ip_vnn ; /* a structure for the single ip */
2009-12-16 10:39:40 +01:00
struct ctdb_iface * ifaces ; /* list of local interfaces */
2006-11-18 10:41:20 +11:00
char * err_msg ;
2006-11-27 21:38:13 +11:00
const struct ctdb_methods * methods ; /* transport methods */
2006-11-28 11:51:33 +11:00
const struct ctdb_upcalls * upcalls ; /* transport upcalls */
2007-04-11 20:12:15 +02:00
void * private_data ; /* private to transport */
2007-04-03 19:41:00 +10:00
struct ctdb_db_context * db_list ;
2013-02-21 13:16:15 +11:00
struct ctdb_message_list_header * message_list_header ;
struct tdb_context * message_list_indexdb ;
2007-04-10 06:03:39 +10:00
struct ctdb_daemon_data daemon ;
2007-05-29 12:16:59 +10:00
struct ctdb_statistics statistics ;
2010-09-29 10:58:18 +10:00
struct ctdb_statistics statistics_current ;
2010-09-29 12:13:05 +10:00
# define MAX_STAT_HISTORY 100
struct ctdb_statistics statistics_history [ MAX_STAT_HISTORY ] ;
2007-04-27 18:43:52 +10:00
struct ctdb_vnn_map * vnn_map ;
2007-04-28 15:15:21 +02:00
uint32_t num_clients ;
2007-05-07 05:02:48 +10:00
uint32_t recovery_master ;
2007-05-19 00:56:49 +10:00
struct ctdb_call_state * pending_calls ;
2007-06-19 03:54:06 +10:00
struct ctdb_client_ip * client_ip_list ;
2012-03-22 15:27:25 +11:00
bool do_checkpublicip ;
2011-01-10 13:35:39 +11:00
struct trbt_tree * server_ids ;
bool do_setsched ;
2007-09-04 09:50:07 +10:00
const char * event_script_dir ;
2009-03-31 14:23:31 +11:00
const char * notification_script ;
2007-09-10 14:27:29 +10:00
const char * default_public_interface ;
2008-01-07 16:17:22 +11:00
pid_t ctdbd_pid ;
2007-10-22 12:34:08 +10:00
pid_t recoverd_pid ;
2013-01-10 16:06:25 +11:00
enum ctdb_runstate runstate ;
2008-01-10 14:40:56 +11:00
struct ctdb_monitor_state * monitor ;
2008-02-22 09:42:52 +11:00
int start_as_disabled ;
2009-07-09 11:57:20 +10:00
int start_as_stopped ;
2009-12-16 20:59:15 +10:30
bool valgrinding ;
2008-06-13 13:18:06 +10:00
uint32_t event_script_timeouts ; /* counting how many consecutive times an eventscript has timedout */
2008-09-17 14:17:41 +10:00
uint32_t * recd_ping_count ;
2012-12-04 15:05:44 +11:00
TALLOC_CTX * recd_ctx ; /* a context used to track recoverd monitoring events */
2008-10-22 11:04:41 +11:00
TALLOC_CTX * release_ips_ctx ; /* a context used to automatically drop all IPs if we fail to recover the node */
2009-11-25 11:00:11 +10:30
2009-12-08 00:09:20 +10:30
TALLOC_CTX * event_script_ctx ;
2013-12-19 13:01:25 +11:00
int active_events ;
2009-11-25 11:00:11 +10:30
2009-12-08 00:14:01 +10:30
struct ctdb_event_script_state * current_monitor ;
2009-12-08 12:27:48 +10:30
struct ctdb_scripts_wire * last_status [ CTDB_EVENT_MAX ] ;
2009-11-25 11:00:11 +10:30
2009-09-04 02:20:39 +10:00
TALLOC_CTX * banning_ctx ;
2009-12-02 13:41:04 +11:00
2010-07-21 12:29:55 +09:30
struct ctdb_vacuum_child_context * vacuumers ;
2009-12-02 13:41:04 +11:00
/* mapping from pid to ctdb_client * */
struct ctdb_client_pid_list * client_pids ;
2010-04-08 14:07:57 +10:00
/* used in the recovery daemon to remember the ip allocation */
struct trbt_tree * ip_tree ;
2011-02-23 15:46:36 +11:00
/* Used to defer db attach requests while in recovery mode */
struct ctdb_deferred_attach_context * deferred_attach ;
2012-02-21 07:03:44 +11:00
/* if we are a child process, do we have a domain socket to send controls on */
bool can_send_controls ;
2012-02-22 17:38:12 +11:00
/* list of event script callback functions that are active */
struct event_script_callback * script_callbacks ;
2012-04-30 15:50:44 +10:00
struct ctdb_reloadips_handle * reload_ips ;
2013-10-21 19:33:10 +11:00
const char * nodes_file ;
2012-04-30 15:50:44 +10:00
const char * public_addresses_file ;
2012-05-03 11:42:41 +10:00
struct trbt_tree * child_processes ;
2012-10-11 11:29:29 +11:00
/* Used for locking record/db/alldb */
struct lock_context * lock_current ;
struct lock_context * lock_pending ;
2007-04-03 19:41:00 +10:00
} ;
struct ctdb_db_context {
struct ctdb_db_context * next , * prev ;
struct ctdb_context * ctdb ;
uint32_t db_id ;
2009-10-10 14:26:09 +11:00
uint32_t priority ;
2007-09-21 12:24:02 +10:00
bool persistent ;
2011-07-20 13:15:48 +10:00
bool readonly ; /* Do we support read-only delegations ? */
2012-03-20 16:58:35 +11:00
bool sticky ; /* Do we support sticky records ? */
2007-04-03 19:41:00 +10:00
const char * db_name ;
2007-04-26 23:10:35 +02:00
const char * db_path ;
2007-04-03 19:41:00 +10:00
struct tdb_wrap * ltdb ;
2011-07-20 13:15:48 +10:00
struct tdb_context * rottdb ; /* ReadOnly tracking TDB */
2007-04-03 19:41:00 +10:00
struct ctdb_registered_call * calls ; /* list of registered calls */
2007-05-04 22:18:00 +10:00
uint32_t seqnum ;
2009-12-08 17:00:55 +01:00
struct timed_event * seqnum_update ;
2009-05-06 07:32:25 +10:00
struct ctdb_traverse_local_handle * traverse ;
2009-07-29 13:25:43 +10:00
struct ctdb_vacuum_handle * vacuum_handle ;
2009-12-07 13:28:11 +01:00
char * unhealthy_reason ;
2011-01-21 21:17:02 +10:30
int pending_requests ;
2011-07-20 13:49:17 +10:00
struct revokechild_handle * revokechild_active ;
2011-02-23 00:00:04 +01:00
struct ctdb_persistent_state * persistent_state ;
2010-12-22 14:50:53 +01:00
struct trbt_tree * delete_queue ;
2012-03-20 16:58:35 +11:00
struct trbt_tree * sticky_records ;
2010-12-30 18:19:32 +01:00
int ( * ctdb_ltdb_store_fn ) ( struct ctdb_db_context * ctdb_db ,
TDB_DATA key ,
struct ctdb_ltdb_header * header ,
TDB_DATA data ) ;
2011-11-08 06:55:46 +11:00
/* used to track which records we are currently fetching
so we can avoid sending duplicate fetch requests
*/
struct trbt_tree * deferred_fetch ;
2014-08-15 15:20:36 +10:00
struct trbt_tree * defer_dmaster ;
2012-02-08 15:29:27 +11:00
struct ctdb_db_statistics statistics ;
2013-11-15 15:58:59 +11:00
2014-07-24 15:56:41 +10:00
struct lock_context * lock_current ;
struct lock_context * lock_pending ;
2013-11-15 15:58:59 +11:00
int lock_num_current ;
2006-11-18 10:41:20 +11:00
} ;
2007-04-09 11:51:27 +10:00
2006-11-27 21:38:13 +11:00
# define CTDB_NO_MEMORY(ctdb, p) do { if (!(p)) { \
2007-05-10 13:15:58 +10:00
DEBUG ( 0 , ( " Out of memory for %s at %s \n " , # p , __location__ ) ) ; \
2006-11-27 21:38:13 +11:00
ctdb_set_error ( ctdb , " Out of memory at %s:%d " , __FILE__ , __LINE__ ) ; \
return - 1 ; } } while ( 0 )
2007-04-26 14:27:49 +02:00
# define CTDB_NO_MEMORY_VOID(ctdb, p) do { if (!(p)) { \
2007-05-10 13:15:58 +10:00
DEBUG ( 0 , ( " Out of memory for %s at %s \n " , # p , __location__ ) ) ; \
2007-04-26 14:27:49 +02:00
ctdb_set_error ( ctdb , " Out of memory at %s:%d " , __FILE__ , __LINE__ ) ; \
2008-07-04 16:58:29 +10:00
return ; } } while ( 0 )
2007-04-26 14:27:49 +02:00
2006-12-01 12:26:21 +03:00
# define CTDB_NO_MEMORY_NULL(ctdb, p) do { if (!(p)) { \
2007-05-10 13:15:58 +10:00
DEBUG ( 0 , ( " Out of memory for %s at %s \n " , # p , __location__ ) ) ; \
2006-12-01 12:26:21 +03:00
ctdb_set_error ( ctdb , " Out of memory at %s:%d " , __FILE__ , __LINE__ ) ; \
return NULL ; } } while ( 0 )
2006-12-18 16:26:57 +11:00
# define CTDB_NO_MEMORY_FATAL(ctdb, p) do { if (!(p)) { \
2007-05-10 13:15:58 +10:00
DEBUG ( 0 , ( " Out of memory for %s at %s \n " , # p , __location__ ) ) ; \
2006-12-18 16:26:57 +11:00
ctdb_fatal ( ctdb , " Out of memory in " __location__ ) ; \
} } while ( 0 )
2007-07-11 18:24:25 +10:00
/*
struct for kill_tcp control
*/
2007-07-12 08:30:04 +10:00
struct ctdb_control_killtcp {
2008-08-19 14:58:29 +10:00
ctdb_sock_addr src_addr ;
ctdb_sock_addr dst_addr ;
2007-07-11 18:24:25 +10:00
} ;
2007-10-09 11:56:09 +10:00
/*
2008-08-19 14:58:29 +10:00
struct holding a ctdb_sock_addr and an interface name ,
2008-06-04 15:13:00 +10:00
used to add / remove public addresses
2007-10-09 11:56:09 +10:00
*/
2008-03-27 09:23:27 +11:00
struct ctdb_control_ip_iface {
2008-08-19 14:58:29 +10:00
ctdb_sock_addr addr ;
2008-03-27 09:23:27 +11:00
uint32_t mask ;
2007-10-09 11:56:09 +10:00
uint32_t len ;
char iface [ 1 ] ;
} ;
2008-06-04 15:13:00 +10:00
/*
struct holding a ctdb_sock_addr and an interface name ,
used for send_gratious_arp
*/
struct ctdb_control_gratious_arp {
ctdb_sock_addr addr ;
uint32_t mask ;
uint32_t len ;
char iface [ 1 ] ;
} ;
2007-09-21 12:24:02 +10:00
/*
persistent store control - update this record on all other nodes
*/
struct ctdb_control_persistent_store {
uint32_t db_id ;
uint32_t len ;
uint8_t data [ 1 ] ;
} ;
2007-06-06 10:25:46 +10:00
/*
structure used for CTDB_SRVID_NODE_FLAGS_CHANGED
*/
struct ctdb_node_flag_change {
2007-09-04 10:33:10 +10:00
uint32_t pnn ;
2007-08-21 17:25:15 +10:00
uint32_t new_flags ;
uint32_t old_flags ;
2007-06-06 10:25:46 +10:00
} ;
2007-06-07 16:34:33 +10:00
/*
struct for admin setting a ban
*/
struct ctdb_ban_info {
2007-09-04 10:33:10 +10:00
uint32_t pnn ;
2007-06-07 16:34:33 +10:00
uint32_t ban_time ;
} ;
2007-04-09 11:51:27 +10:00
enum call_state { CTDB_CALL_WAIT , CTDB_CALL_DONE , CTDB_CALL_ERROR } ;
2007-05-02 10:20:34 +10:00
# define CTDB_LMASTER_ANY 0xffffffff
2007-04-09 11:51:27 +10:00
/*
state of a in - progress ctdb call
*/
struct ctdb_call_state {
2007-05-19 00:56:49 +10:00
struct ctdb_call_state * next , * prev ;
2007-04-09 11:51:27 +10:00
enum call_state state ;
2007-04-23 18:19:50 +10:00
uint32_t reqid ;
2007-04-09 11:51:27 +10:00
struct ctdb_req_call * c ;
struct ctdb_db_context * ctdb_db ;
const char * errmsg ;
2008-03-19 13:54:17 +11:00
struct ctdb_call * call ;
2007-05-10 14:06:48 +10:00
uint32_t generation ;
2007-04-12 15:46:50 +10:00
struct {
void ( * fn ) ( struct ctdb_call_state * ) ;
2007-04-13 20:38:24 +10:00
void * private_data ;
2007-04-12 15:46:50 +10:00
} async ;
2007-04-09 11:51:27 +10:00
} ;
2006-11-28 20:48:34 +11:00
2007-04-17 12:36:31 +10:00
/* used for fetch_lock */
2007-04-18 11:20:24 +10:00
struct ctdb_fetch_handle {
2007-04-17 12:36:31 +10:00
struct ctdb_db_context * ctdb_db ;
TDB_DATA key ;
TDB_DATA * data ;
2007-04-17 14:52:51 +10:00
struct ctdb_ltdb_header header ;
2007-04-17 12:36:31 +10:00
} ;
2006-11-27 21:38:13 +11:00
/* internal prototypes */
2007-01-23 11:38:45 +11:00
void ctdb_set_error ( struct ctdb_context * ctdb , const char * fmt , . . . ) PRINTF_ATTRIBUTE ( 2 , 3 ) ;
2006-12-18 16:01:11 +11:00
void ctdb_fatal ( struct ctdb_context * ctdb , const char * msg ) ;
2013-06-30 17:42:11 +10:00
void ctdb_die ( struct ctdb_context * ctdb , const char * msg ) ;
2015-03-07 07:22:32 +11:00
bool ctdb_set_helper ( const char * type , char * helper , size_t size ,
const char * envvar , const char * dir , const char * file ) ;
2012-09-06 20:22:38 +10:00
void ctdb_external_trace ( void ) ;
2015-02-20 11:47:23 +11:00
bool ctdb_same_address ( ctdb_sock_addr * a1 , ctdb_sock_addr * a2 ) ;
2015-02-23 10:34:33 +11:00
int ctdb_parse_address ( TALLOC_CTX * mem_ctx , const char * str ,
2015-02-20 11:47:23 +11:00
ctdb_sock_addr * address ) ;
2008-08-19 14:58:29 +10:00
bool ctdb_same_ip ( const ctdb_sock_addr * ip1 , const ctdb_sock_addr * ip2 ) ;
bool ctdb_same_sockaddr ( const ctdb_sock_addr * ip1 , const ctdb_sock_addr * ip2 ) ;
2006-12-18 16:01:11 +11:00
uint32_t ctdb_hash ( const TDB_DATA * key ) ;
2014-08-15 13:22:29 +10:00
uint32_t * ctdb_key_to_idkey ( TALLOC_CTX * mem_ctx , TDB_DATA key ) ;
2006-12-01 15:45:24 +11:00
void ctdb_request_call ( struct ctdb_context * ctdb , struct ctdb_req_header * hdr ) ;
2006-12-18 16:01:11 +11:00
void ctdb_request_dmaster ( struct ctdb_context * ctdb , struct ctdb_req_header * hdr ) ;
2007-02-09 09:42:04 +11:00
void ctdb_request_message ( struct ctdb_context * ctdb , struct ctdb_req_header * hdr ) ;
2006-12-18 16:01:11 +11:00
void ctdb_reply_dmaster ( struct ctdb_context * ctdb , struct ctdb_req_header * hdr ) ;
2006-12-01 15:45:24 +11:00
void ctdb_reply_call ( struct ctdb_context * ctdb , struct ctdb_req_header * hdr ) ;
2006-12-18 14:27:20 +11:00
void ctdb_reply_error ( struct ctdb_context * ctdb , struct ctdb_req_header * hdr ) ;
2006-11-18 10:41:20 +11:00
2006-12-18 16:01:11 +11:00
uint32_t ctdb_lmaster ( struct ctdb_context * ctdb , const TDB_DATA * key ) ;
2007-04-03 19:41:00 +10:00
int ctdb_ltdb_fetch ( struct ctdb_db_context * ctdb_db ,
2007-04-07 10:45:00 +10:00
TDB_DATA key , struct ctdb_ltdb_header * header ,
TALLOC_CTX * mem_ctx , TDB_DATA * data ) ;
2007-04-03 19:41:00 +10:00
int ctdb_ltdb_store ( struct ctdb_db_context * ctdb_db , TDB_DATA key ,
2006-12-18 13:24:02 +11:00
struct ctdb_ltdb_header * header , TDB_DATA data ) ;
2010-12-06 16:06:20 +11:00
int ctdb_ltdb_delete ( struct ctdb_db_context * ctdb_db , TDB_DATA key ) ;
2011-09-13 18:38:20 +10:00
int ctdb_ltdb_fetch_with_header ( struct ctdb_db_context * ctdb_db ,
2011-07-20 15:37:37 +10:00
TDB_DATA key , struct ctdb_ltdb_header * header ,
TALLOC_CTX * mem_ctx , TDB_DATA * data ) ;
2008-07-17 13:50:55 +10:00
int32_t ctdb_control_start_persistent_update ( struct ctdb_context * ctdb ,
struct ctdb_req_control * c ,
TDB_DATA recdata ) ;
int32_t ctdb_control_cancel_persistent_update ( struct ctdb_context * ctdb ,
struct ctdb_req_control * c ,
TDB_DATA recdata ) ;
2007-02-09 09:42:04 +11:00
void ctdb_queue_packet ( struct ctdb_context * ctdb , struct ctdb_req_header * hdr ) ;
2008-07-04 18:00:24 +10:00
void ctdb_queue_packet_opcode ( struct ctdb_context * ctdb , struct ctdb_req_header * hdr , unsigned opcode ) ;
2007-04-19 17:43:27 +10:00
int ctdb_ltdb_lock_requeue ( struct ctdb_db_context * ctdb_db ,
TDB_DATA key , struct ctdb_req_header * hdr ,
2007-05-19 13:45:24 +10:00
void ( * recv_pkt ) ( void * , struct ctdb_req_header * ) ,
2007-05-12 18:08:50 +10:00
void * recv_context , bool ignore_generation ) ;
2007-04-16 23:52:14 +10:00
int ctdb_ltdb_lock_fetch_requeue ( struct ctdb_db_context * ctdb_db ,
TDB_DATA key , struct ctdb_ltdb_header * header ,
2007-04-19 16:27:56 +10:00
struct ctdb_req_header * hdr , TDB_DATA * data ,
2007-05-19 13:45:24 +10:00
void ( * recv_pkt ) ( void * , struct ctdb_req_header * ) ,
2007-05-12 18:08:50 +10:00
void * recv_context , bool ignore_generation ) ;
2007-05-19 13:45:24 +10:00
void ctdb_input_pkt ( struct ctdb_context * ctdb , struct ctdb_req_header * ) ;
2006-12-18 13:24:02 +11:00
2007-04-09 11:51:27 +10:00
struct ctdb_call_state * ctdb_call_local_send ( struct ctdb_db_context * ctdb_db ,
struct ctdb_call * call ,
struct ctdb_ltdb_header * header ,
TDB_DATA * data ) ;
2006-12-18 13:24:02 +11:00
2007-04-10 06:03:39 +10:00
2014-08-08 20:57:05 +10:00
int ctdb_start_daemon ( struct ctdb_context * ctdb , bool do_fork ) ;
2007-04-10 19:33:21 +10:00
/*
queue a packet for sending
*/
int ctdb_queue_send ( struct ctdb_queue * queue , uint8_t * data , uint32_t length ) ;
/*
setup the fd used by the queue
*/
int ctdb_queue_set_fd ( struct ctdb_queue * queue , int fd ) ;
/*
setup a packet queue on a socket
*/
struct ctdb_queue * ctdb_queue_setup ( struct ctdb_context * ctdb ,
TALLOC_CTX * mem_ctx , int fd , int alignment ,
ctdb_queue_cb_fn_t callback ,
2010-07-01 23:08:49 +10:00
void * private_data , const char * fmt , . . . )
PRINTF_ATTRIBUTE ( 7 , 8 ) ;
2007-04-10 19:33:21 +10:00
2007-04-11 11:01:42 +10:00
/*
allocate a packet for use in client < - > daemon communication
*/
2007-04-28 10:50:32 +02:00
struct ctdb_req_header * _ctdbd_allocate_pkt ( struct ctdb_context * ctdb ,
TALLOC_CTX * mem_ctx ,
enum ctdb_operation operation ,
size_t length , size_t slength ,
const char * type ) ;
# define ctdbd_allocate_pkt(ctdb, mem_ctx, operation, length, type) \
( type * ) _ctdbd_allocate_pkt ( ctdb , mem_ctx , operation , length , sizeof ( type ) , # type )
struct ctdb_req_header * _ctdb_transport_allocate ( struct ctdb_context * ctdb ,
TALLOC_CTX * mem_ctx ,
enum ctdb_operation operation ,
size_t length , size_t slength ,
const char * type ) ;
# define ctdb_transport_allocate(ctdb, mem_ctx, operation, length, type) \
( type * ) _ctdb_transport_allocate ( ctdb , mem_ctx , operation , length , sizeof ( type ) , # type )
2007-04-11 11:01:42 +10:00
2009-10-21 15:20:55 +11:00
int ctdb_queue_length ( struct ctdb_queue * queue ) ;
2007-04-11 11:01:42 +10:00
/*
lock a record in the ltdb , given a key
*/
int ctdb_ltdb_lock ( struct ctdb_db_context * ctdb_db , TDB_DATA key ) ;
/*
unlock a record in the ltdb , given a key
*/
int ctdb_ltdb_unlock ( struct ctdb_db_context * ctdb_db , TDB_DATA key ) ;
2007-04-11 13:43:15 +10:00
int ctdb_client_send_message ( struct ctdb_context * ctdb , uint32_t vnn ,
2007-04-28 00:31:45 +10:00
uint64_t srvid , TDB_DATA data ) ;
2007-04-11 13:43:15 +10:00
2007-04-11 14:05:01 +10:00
/*
send a ctdb message
*/
2007-09-04 10:45:41 +10:00
int ctdb_daemon_send_message ( struct ctdb_context * ctdb , uint32_t pnn ,
2007-04-28 00:31:45 +10:00
uint64_t srvid , TDB_DATA data ) ;
2007-04-11 14:05:01 +10:00
2007-04-11 14:26:14 +10:00
2007-04-17 14:52:51 +10:00
int ctdb_daemon_call_recv ( struct ctdb_call_state * state , struct ctdb_call * call ) ;
2007-04-17 16:20:32 +10:00
struct ctdb_call_state * ctdb_daemon_call_send_remote ( struct ctdb_db_context * ctdb_db ,
struct ctdb_call * call ,
struct ctdb_ltdb_header * header ) ;
2007-04-19 11:28:01 +10:00
int ctdb_call_local ( struct ctdb_db_context * ctdb_db , struct ctdb_call * call ,
2010-11-29 13:07:59 +11:00
struct ctdb_ltdb_header * header , TALLOC_CTX * mem_ctx ,
2013-08-19 15:04:46 +10:00
TDB_DATA * data , bool updatetdb ) ;
2007-04-19 11:28:01 +10:00
2007-04-23 18:19:50 +10:00
# define ctdb_reqid_find(ctdb, reqid, type) (type *)_ctdb_reqid_find(ctdb, reqid, #type, __location__)
2007-04-19 11:28:01 +10:00
2007-04-20 20:07:47 +10:00
int ctdb_socket_connect ( struct ctdb_context * ctdb ) ;
2011-08-03 10:38:27 +02:00
void ctdb_client_read_cb ( uint8_t * data , size_t cnt , void * args ) ;
2007-04-20 20:07:47 +10:00
2010-05-08 22:24:11 +09:30
# define CTDB_BAD_REQID ((uint32_t)-1)
2007-04-23 18:19:50 +10:00
uint32_t ctdb_reqid_new ( struct ctdb_context * ctdb , void * state ) ;
void * _ctdb_reqid_find ( struct ctdb_context * ctdb , uint32_t reqid , const char * type , const char * location ) ;
void ctdb_reqid_remove ( struct ctdb_context * ctdb , uint32_t reqid ) ;
2007-04-26 14:27:49 +02:00
void ctdb_request_control ( struct ctdb_context * ctdb , struct ctdb_req_header * hdr ) ;
void ctdb_reply_control ( struct ctdb_context * ctdb , struct ctdb_req_header * hdr ) ;
int ctdb_daemon_send_control ( struct ctdb_context * ctdb , uint32_t destnode ,
2007-05-04 11:41:29 +10:00
uint64_t srvid , uint32_t opcode , uint32_t client_id , uint32_t flags ,
2007-04-30 15:31:40 +02:00
TDB_DATA data ,
2007-04-26 14:27:49 +02:00
ctdb_control_callback_fn_t callback ,
void * private_data ) ;
2007-04-30 15:31:40 +02:00
int32_t ctdb_control_db_attach ( struct ctdb_context * ctdb , TDB_DATA indata ,
2011-02-23 15:46:36 +11:00
TDB_DATA * outdata , uint64_t tdb_flags ,
bool persistent , uint32_t client_id ,
struct ctdb_req_control * c ,
bool * async_reply ) ;
2014-03-31 15:44:21 +11:00
int32_t ctdb_control_db_detach ( struct ctdb_context * ctdb , TDB_DATA indata ,
uint32_t client_id ) ;
2007-04-30 15:31:40 +02:00
int ctdb_daemon_set_call ( struct ctdb_context * ctdb , uint32_t db_id ,
ctdb_fn_t fn , int id ) ;
2007-05-02 12:43:35 +10:00
int ctdb_control ( struct ctdb_context * ctdb , uint32_t destnode , uint64_t srvid ,
uint32_t opcode , uint32_t flags , TDB_DATA data ,
2007-05-04 08:30:18 +10:00
TALLOC_CTX * mem_ctx , TDB_DATA * outdata , int32_t * status ,
2007-05-12 21:25:26 +10:00
struct timeval * timeout , char * * errormsg ) ;
2007-08-23 19:27:09 +10:00
int ctdb_control_recv ( struct ctdb_context * ctdb ,
struct ctdb_client_control_state * state ,
TALLOC_CTX * mem_ctx ,
TDB_DATA * outdata , int32_t * status , char * * errormsg ) ;
struct ctdb_client_control_state *
ctdb_control_send ( struct ctdb_context * ctdb ,
uint32_t destnode , uint64_t srvid ,
uint32_t opcode , uint32_t flags , TDB_DATA data ,
2008-01-16 10:23:26 +11:00
TALLOC_CTX * mem_ctx ,
2007-08-23 19:27:09 +10:00
struct timeval * timeout ,
2007-08-24 10:42:06 +10:00
char * * errormsg ) ;
2007-05-02 12:43:35 +10:00
2007-05-03 11:06:24 +10:00
# define CHECK_CONTROL_DATA_SIZE(size) do { \
if ( indata . dsize ! = size ) { \
DEBUG ( 0 , ( __location__ " Invalid data size in opcode %u. Got %u expected %u \n " , \
2007-05-29 13:58:41 +10:00
opcode , ( unsigned ) indata . dsize , ( unsigned ) size ) ) ; \
2007-05-03 11:06:24 +10:00
return - 1 ; \
} \
} while ( 0 )
2011-03-09 00:56:25 +01:00
# define CHECK_CONTROL_MIN_DATA_SIZE(size) do { \
if ( indata . dsize < size ) { \
DEBUG ( 0 , ( __location__ " Invalid data size in opcode %u. Got %u expected >= %u \n " , \
opcode , ( unsigned ) indata . dsize , ( unsigned ) size ) ) ; \
return - 1 ; \
} \
} while ( 0 )
2007-05-03 11:06:24 +10:00
int ctdb_control_getvnnmap ( struct ctdb_context * ctdb , uint32_t opcode , TDB_DATA indata , TDB_DATA * outdata ) ;
int ctdb_control_setvnnmap ( struct ctdb_context * ctdb , uint32_t opcode , TDB_DATA indata , TDB_DATA * outdata ) ;
2007-05-03 13:07:34 +10:00
int ctdb_control_getdbmap ( struct ctdb_context * ctdb , uint32_t opcode , TDB_DATA indata , TDB_DATA * outdata ) ;
2007-05-03 13:30:38 +10:00
int ctdb_control_getnodemap ( struct ctdb_context * ctdb , uint32_t opcode , TDB_DATA indata , TDB_DATA * outdata ) ;
2015-02-20 21:19:01 +11:00
int ctdb_control_getnodesfile ( struct ctdb_context * ctdb , uint32_t opcode , TDB_DATA indata , TDB_DATA * outdata ) ;
2007-05-03 11:06:24 +10:00
2007-05-03 17:12:23 +10:00
2007-05-10 17:43:45 +10:00
/* structure used for pulldb control */
struct ctdb_control_pulldb {
uint32_t db_id ;
uint32_t lmaster ;
} ;
2008-07-30 14:24:56 +10:00
/* structure used for sending lists of records */
struct ctdb_marshall_buffer {
2007-05-10 17:43:45 +10:00
uint32_t db_id ;
uint32_t count ;
uint8_t data [ 1 ] ;
} ;
2007-06-04 19:53:19 +10:00
/*
structure for setting a tunable
*/
struct ctdb_control_set_tunable {
uint32_t value ;
uint32_t length ;
uint8_t name [ 1 ] ;
} ;
/*
structure for getting a tunable
*/
struct ctdb_control_get_tunable {
uint32_t length ;
uint8_t name [ 1 ] ;
} ;
/*
structure for listing tunables
*/
struct ctdb_control_list_tunable {
uint32_t length ;
/* returns a : separated list of tunable names */
uint8_t data [ 1 ] ;
} ;
2008-01-06 13:24:55 +11:00
struct ctdb_control_wipe_database {
uint32_t db_id ;
uint32_t transaction_id ;
} ;
2008-01-08 21:28:42 +11:00
/*
state of a in - progress ctdb call in client
*/
struct ctdb_client_call_state {
enum call_state state ;
uint32_t reqid ;
struct ctdb_db_context * ctdb_db ;
2008-03-19 13:54:17 +11:00
struct ctdb_call * call ;
2008-01-08 21:28:42 +11:00
struct {
void ( * fn ) ( struct ctdb_client_call_state * ) ;
2008-07-22 09:07:42 +10:00
void * private_data ;
2008-01-08 21:28:42 +11:00
} async ;
} ;
2011-12-03 02:15:30 +01:00
int32_t ctdb_control_traverse_start_ext ( struct ctdb_context * ctdb ,
TDB_DATA indata ,
TDB_DATA * outdata ,
uint32_t srcnode ,
uint32_t client_id ) ;
2007-05-03 17:12:23 +10:00
int32_t ctdb_control_traverse_start ( struct ctdb_context * ctdb , TDB_DATA indata ,
2009-05-06 07:32:25 +10:00
TDB_DATA * outdata , uint32_t srcnode , uint32_t client_id ) ;
2007-05-03 17:12:23 +10:00
int32_t ctdb_control_traverse_all ( struct ctdb_context * ctdb , TDB_DATA data , TDB_DATA * outdata ) ;
2013-04-11 13:18:36 +10:00
int32_t ctdb_control_traverse_all_ext ( struct ctdb_context * ctdb , TDB_DATA data , TDB_DATA * outdata ) ;
2007-05-03 17:12:23 +10:00
int32_t ctdb_control_traverse_data ( struct ctdb_context * ctdb , TDB_DATA data , TDB_DATA * outdata ) ;
2009-05-06 07:32:25 +10:00
int32_t ctdb_control_traverse_kill ( struct ctdb_context * ctdb , TDB_DATA indata ,
TDB_DATA * outdata , uint32_t srcnode ) ;
2007-05-03 17:12:23 +10:00
int ctdb_dispatch_message ( struct ctdb_context * ctdb , uint64_t srvid , TDB_DATA data ) ;
2013-02-21 13:16:15 +11:00
bool ctdb_check_message_handler ( struct ctdb_context * ctdb , uint64_t srvid ) ;
2007-05-03 17:12:23 +10:00
2007-05-04 11:41:29 +10:00
int daemon_register_message_handler ( struct ctdb_context * ctdb , uint32_t client_id , uint64_t srvid ) ;
int ctdb_deregister_message_handler ( struct ctdb_context * ctdb , uint64_t srvid , void * private_data ) ;
int daemon_deregister_message_handler ( struct ctdb_context * ctdb , uint32_t client_id , uint64_t srvid ) ;
2011-10-31 13:29:13 +01:00
int daemon_check_srvids ( struct ctdb_context * ctdb , TDB_DATA indata ,
TDB_DATA * outdata ) ;
2007-05-03 17:12:23 +10:00
2007-05-04 22:18:00 +10:00
int32_t ctdb_ltdb_enable_seqnum ( struct ctdb_context * ctdb , uint32_t db_id ) ;
int32_t ctdb_ltdb_update_seqnum ( struct ctdb_context * ctdb , uint32_t db_id , uint32_t srcnode ) ;
2007-09-21 12:24:02 +10:00
struct ctdb_rec_data * ctdb_marshall_record ( TALLOC_CTX * mem_ctx , uint32_t reqid ,
TDB_DATA key , struct ctdb_ltdb_header * , TDB_DATA data ) ;
2007-05-10 17:43:45 +10:00
2008-07-30 19:57:00 +10:00
struct ctdb_rec_data * ctdb_marshall_loop_next ( struct ctdb_marshall_buffer * m , struct ctdb_rec_data * r ,
uint32_t * reqid ,
struct ctdb_ltdb_header * header ,
TDB_DATA * key , TDB_DATA * data ) ;
2007-05-10 17:43:45 +10:00
int32_t ctdb_control_pull_db ( struct ctdb_context * ctdb , TDB_DATA indata , TDB_DATA * outdata ) ;
int32_t ctdb_control_push_db ( struct ctdb_context * ctdb , TDB_DATA indata ) ;
2007-06-02 08:41:19 +10:00
int32_t ctdb_control_set_recmode ( struct ctdb_context * ctdb ,
struct ctdb_req_control * c ,
TDB_DATA indata , bool * async_reply ,
const char * * errormsg ) ;
2007-05-12 14:34:21 +10:00
void ctdb_request_control_reply ( struct ctdb_context * ctdb , struct ctdb_req_control * c ,
2007-05-12 21:25:26 +10:00
TDB_DATA * outdata , int32_t status , const char * errormsg ) ;
2007-05-12 14:34:21 +10:00
2007-05-12 15:15:27 +10:00
int32_t ctdb_control_freeze ( struct ctdb_context * ctdb , struct ctdb_req_control * c , bool * async_reply ) ;
2014-05-06 14:20:44 +10:00
int32_t ctdb_control_thaw ( struct ctdb_context * ctdb , uint32_t priority ,
bool check_recmode ) ;
2007-05-12 15:15:27 +10:00
2007-05-15 15:13:36 +10:00
int ctdb_start_recoverd ( struct ctdb_context * ctdb ) ;
2007-10-22 12:34:08 +10:00
void ctdb_stop_recoverd ( struct ctdb_context * ctdb ) ;
2007-05-15 15:13:36 +10:00
2007-06-19 03:54:06 +10:00
uint32_t ctdb_get_num_active_nodes ( struct ctdb_context * ctdb ) ;
2007-05-17 23:23:41 +10:00
2007-11-30 10:09:54 +11:00
void ctdb_disable_monitoring ( struct ctdb_context * ctdb ) ;
void ctdb_enable_monitoring ( struct ctdb_context * ctdb ) ;
2007-06-06 13:45:12 +10:00
void ctdb_stop_monitoring ( struct ctdb_context * ctdb ) ;
2013-12-18 15:37:11 +11:00
void ctdb_wait_for_first_recovery ( struct ctdb_context * ctdb ) ;
2014-09-04 13:31:15 +10:00
int ctdb_tcp_init ( struct ctdb_context * ctdb ) ;
int ctdb_ibw_init ( struct ctdb_context * ctdb ) ;
2007-07-20 15:05:55 +10:00
void ctdb_start_tcp_tickle_update ( struct ctdb_context * ctdb ) ;
2007-05-18 23:23:36 +10:00
void ctdb_send_keepalive ( struct ctdb_context * ctdb , uint32_t destnode ) ;
2008-01-15 08:42:12 +11:00
void ctdb_start_keepalive ( struct ctdb_context * ctdb ) ;
void ctdb_stop_keepalive ( struct ctdb_context * ctdb ) ;
2008-04-02 11:13:30 +11:00
int32_t ctdb_run_eventscripts ( struct ctdb_context * ctdb , struct ctdb_req_control * c , TDB_DATA data , bool * async_reply ) ;
2007-05-18 19:19:35 +10:00
2007-05-18 23:48:29 +10:00
void ctdb_daemon_cancel_controls ( struct ctdb_context * ctdb , struct ctdb_node * node ) ;
2007-05-19 00:56:49 +10:00
void ctdb_call_resend_all ( struct ctdb_context * ctdb ) ;
2007-05-19 16:59:10 +10:00
void ctdb_node_dead ( struct ctdb_node * node ) ;
2007-05-19 17:21:58 +10:00
void ctdb_node_connected ( struct ctdb_node * node ) ;
2007-05-23 12:23:07 +10:00
bool ctdb_blocking_freeze ( struct ctdb_context * ctdb ) ;
2014-09-12 11:22:36 +10:00
bool set_scheduler ( void ) ;
2014-06-10 16:48:03 +10:00
void reset_scheduler ( void ) ;
2012-05-03 11:42:41 +10:00
struct tevent_signal * ctdb_init_sigchld ( struct ctdb_context * ctdb ) ;
2013-11-19 16:13:20 +11:00
void ctdb_track_child ( struct ctdb_context * ctdb , pid_t pid ) ;
2011-01-10 13:57:49 +11:00
pid_t ctdb_fork ( struct ctdb_context * ctdb ) ;
2013-04-16 11:11:11 +10:00
void ctdb_set_child_info ( TALLOC_CTX * mem_ctx , const char * child_name_fmt , . . . ) ;
2012-05-03 11:42:41 +10:00
int ctdb_kill ( struct ctdb_context * ctdb , pid_t pid , int signum ) ;
2007-06-01 19:05:41 +10:00
int32_t ctdb_control_takeover_ip ( struct ctdb_context * ctdb ,
struct ctdb_req_control * c ,
TDB_DATA indata ,
bool * async_reply ) ;
int32_t ctdb_control_release_ip ( struct ctdb_context * ctdb ,
struct ctdb_req_control * c ,
TDB_DATA indata ,
bool * async_reply ) ;
2013-04-19 13:05:02 +10:00
int32_t ctdb_control_ipreallocated ( struct ctdb_context * ctdb ,
struct ctdb_req_control * c ,
bool * async_reply ) ;
2008-01-29 13:59:28 +11:00
int32_t ctdb_control_start_recovery ( struct ctdb_context * ctdb ,
struct ctdb_req_control * c ,
bool * async_reply ) ;
int32_t ctdb_control_end_recovery ( struct ctdb_context * ctdb ,
struct ctdb_req_control * c ,
bool * async_reply ) ;
2007-06-04 20:07:37 +10:00
int ctdb_ctrl_takeover_ip ( struct ctdb_context * ctdb , struct timeval timeout ,
uint32_t destnode , struct ctdb_public_ip * ip ) ;
2007-05-25 13:05:25 +10:00
int ctdb_ctrl_release_ip ( struct ctdb_context * ctdb , struct timeval timeout ,
2007-06-04 20:07:37 +10:00
uint32_t destnode , struct ctdb_public_ip * ip ) ;
2007-05-25 17:04:13 +10:00
2015-03-23 17:06:31 +11:00
int32_t ctdb_control_get_public_ips ( struct ctdb_context * ctdb ,
struct ctdb_req_control * c ,
TDB_DATA * outdata ) ;
int ctdb_ctrl_get_public_ips ( struct ctdb_context * ctdb ,
2009-12-16 15:50:06 +01:00
struct timeval timeout ,
uint32_t destnode ,
TALLOC_CTX * mem_ctx ,
struct ctdb_all_public_ips * * ips ) ;
# define CTDB_PUBLIC_IP_FLAGS_ONLY_AVAILABLE 0x00010000
int ctdb_ctrl_get_public_ips_flags ( struct ctdb_context * ctdb ,
struct timeval timeout , uint32_t destnode ,
TALLOC_CTX * mem_ctx ,
uint32_t flags ,
struct ctdb_all_public_ips * * ips ) ;
2007-06-04 21:11:51 +10:00
2009-12-16 14:40:21 +01:00
struct ctdb_control_iface_info {
char name [ CTDB_IFACE_SIZE + 2 ] ;
uint16_t link_state ;
uint32_t references ;
} ;
struct ctdb_control_public_ip_info {
struct ctdb_public_ip ip ;
uint32_t active_idx ;
uint32_t num ;
struct ctdb_control_iface_info ifaces [ 1 ] ;
} ;
struct ctdb_control_get_ifaces {
uint32_t num ;
struct ctdb_control_iface_info ifaces [ 1 ] ;
} ;
int32_t ctdb_control_get_public_ip_info ( struct ctdb_context * ctdb ,
struct ctdb_req_control * c ,
TDB_DATA indata ,
TDB_DATA * outdata ) ;
int32_t ctdb_control_get_ifaces ( struct ctdb_context * ctdb ,
struct ctdb_req_control * c ,
TDB_DATA * outdata ) ;
int32_t ctdb_control_set_iface_link ( struct ctdb_context * ctdb ,
struct ctdb_req_control * c ,
TDB_DATA indata ) ;
int ctdb_ctrl_get_public_ip_info ( struct ctdb_context * ctdb ,
struct timeval timeout , uint32_t destnode ,
TALLOC_CTX * mem_ctx ,
const ctdb_sock_addr * addr ,
struct ctdb_control_public_ip_info * * info ) ;
int ctdb_ctrl_get_ifaces ( struct ctdb_context * ctdb ,
struct timeval timeout , uint32_t destnode ,
TALLOC_CTX * mem_ctx ,
struct ctdb_control_get_ifaces * * ifaces ) ;
int ctdb_ctrl_set_iface_link ( struct ctdb_context * ctdb ,
struct timeval timeout , uint32_t destnode ,
TALLOC_CTX * mem_ctx ,
const struct ctdb_control_iface_info * info ) ;
2007-05-25 17:04:13 +10:00
/* from takeover/system.c */
2009-02-28 03:08:31 +01:00
uint32_t uint16_checksum ( uint16_t * data , size_t n ) ;
2008-06-04 15:13:00 +10:00
int ctdb_sys_send_arp ( const ctdb_sock_addr * addr , const char * iface ) ;
2008-08-19 14:58:29 +10:00
bool ctdb_sys_have_ip ( ctdb_sock_addr * addr ) ;
2012-06-20 13:32:02 +10:00
char * ctdb_sys_find_ifname ( ctdb_sock_addr * addr ) ;
2011-09-06 16:11:00 +10:00
bool ctdb_sys_check_iface_exists ( const char * iface ) ;
2011-11-05 19:04:40 +01:00
int ctdb_get_peer_pid ( const int fd , pid_t * peer_pid ) ;
2008-05-14 15:47:47 +10:00
int ctdb_sys_send_tcp ( const ctdb_sock_addr * dest ,
const ctdb_sock_addr * src ,
2007-07-04 13:32:38 +10:00
uint32_t seq , uint32_t ack , int rst ) ;
2007-05-25 17:04:13 +10:00
2012-06-06 11:50:25 +10:00
/* Details of a byte range lock */
struct ctdb_lock_info {
ino_t inode ;
off_t start , end ;
bool waiting ;
bool read_only ;
} ;
2013-07-09 12:24:59 +10:00
int ctdb_set_process_name ( const char * name ) ;
2012-06-06 11:50:25 +10:00
2012-10-23 16:23:12 +11:00
typedef void ( * client_async_callback ) ( struct ctdb_context * ctdb , uint32_t node_pnn , int32_t res , TDB_DATA outdata , void * callback_data ) ;
2012-05-01 15:27:12 +10:00
int ctdb_set_public_addresses ( struct ctdb_context * ctdb , bool check_addresses ) ;
2009-12-14 19:33:35 +01:00
int ctdb_set_single_public_ip ( struct ctdb_context * ctdb ,
const char * iface ,
const char * ip ) ;
2009-03-31 14:23:31 +11:00
int ctdb_set_notification_script ( struct ctdb_context * ctdb , const char * script ) ;
2013-09-04 14:30:04 +10:00
int ctdb_takeover_run ( struct ctdb_context * ctdb , struct ctdb_node_map * nodemap ,
uint32_t * force_rebalance_nodes ,
client_async_callback fail_callback , void * callback_data ) ;
2007-05-18 23:48:29 +10:00
2007-05-27 15:26:29 +10:00
int32_t ctdb_control_tcp_client ( struct ctdb_context * ctdb , uint32_t client_id ,
2007-07-20 10:06:41 +10:00
TDB_DATA indata ) ;
2010-08-18 12:36:03 +10:00
int32_t ctdb_control_tcp_add ( struct ctdb_context * ctdb , TDB_DATA indata , bool tcp_update_needed ) ;
2007-05-27 15:26:29 +10:00
int32_t ctdb_control_tcp_remove ( struct ctdb_context * ctdb , TDB_DATA indata ) ;
2007-05-28 00:34:40 +10:00
int32_t ctdb_control_startup ( struct ctdb_context * ctdb , uint32_t vnn ) ;
2007-07-11 18:24:25 +10:00
int32_t ctdb_control_kill_tcp ( struct ctdb_context * ctdb , TDB_DATA indata ) ;
2007-10-09 11:56:09 +10:00
int32_t ctdb_control_send_gratious_arp ( struct ctdb_context * ctdb , TDB_DATA indata ) ;
2007-07-20 15:05:55 +10:00
int32_t ctdb_control_get_tcp_tickle_list ( struct ctdb_context * ctdb , TDB_DATA indata , TDB_DATA * outdata ) ;
int32_t ctdb_control_set_tcp_tickle_list ( struct ctdb_context * ctdb , TDB_DATA indata ) ;
2007-05-27 15:26:29 +10:00
void ctdb_takeover_client_destructor_hook ( struct ctdb_client * client ) ;
2009-11-24 11:16:49 +10:30
int ctdb_event_script ( struct ctdb_context * ctdb , enum ctdb_eventscript_call call ) ;
int ctdb_event_script_args ( struct ctdb_context * ctdb , enum ctdb_eventscript_call call ,
const char * fmt , . . . ) PRINTF_ATTRIBUTE ( 3 , 4 ) ;
2007-05-30 13:26:50 +10:00
int ctdb_event_script_callback ( struct ctdb_context * ctdb ,
2007-06-01 19:05:41 +10:00
TALLOC_CTX * mem_ctx ,
void ( * callback ) ( struct ctdb_context * , int , void * ) ,
void * private_data ,
2009-11-24 11:16:49 +10:30
enum ctdb_eventscript_call call ,
2013-12-16 15:57:42 +11:00
const char * fmt , . . . ) PRINTF_ATTRIBUTE ( 6 , 7 ) ;
2007-05-29 13:33:59 +10:00
void ctdb_release_all_ips ( struct ctdb_context * ctdb ) ;
2007-05-29 12:49:25 +10:00
2007-05-30 15:43:25 +10:00
void set_nonblocking ( int fd ) ;
void set_close_on_exec ( int fd ) ;
2007-05-29 13:48:30 +10:00
2014-12-09 13:50:22 +11:00
bool ctdb_recovery_have_lock ( struct ctdb_context * ctdb ) ;
2014-12-09 14:50:38 +11:00
bool ctdb_recovery_lock ( struct ctdb_context * ctdb ) ;
2014-12-09 14:07:20 +11:00
void ctdb_recovery_unlock ( struct ctdb_context * ctdb ) ;
2007-06-02 10:03:28 +10:00
2007-06-02 11:36:42 +10:00
int ctdb_set_recovery_lock_file ( struct ctdb_context * ctdb , const char * file ) ;
2007-05-29 13:48:30 +10:00
2007-06-04 19:53:19 +10:00
int32_t ctdb_control_get_tunable ( struct ctdb_context * ctdb , TDB_DATA indata ,
TDB_DATA * outdata ) ;
int32_t ctdb_control_set_tunable ( struct ctdb_context * ctdb , TDB_DATA indata ) ;
int32_t ctdb_control_list_tunables ( struct ctdb_context * ctdb , TDB_DATA * outdata ) ;
2008-03-13 07:53:29 +11:00
int32_t ctdb_control_try_delete_records ( struct ctdb_context * ctdb , TDB_DATA indata , TDB_DATA * outdata ) ;
2012-12-21 00:24:47 +01:00
int32_t ctdb_control_receive_records ( struct ctdb_context * ctdb , TDB_DATA indata , TDB_DATA * outdata ) ;
2008-03-27 09:23:27 +11:00
int32_t ctdb_control_add_public_address ( struct ctdb_context * ctdb , TDB_DATA indata ) ;
2014-01-22 13:30:47 +11:00
int32_t ctdb_control_del_public_address ( struct ctdb_context * ctdb ,
struct ctdb_req_control * c ,
TDB_DATA recdata , bool * async_reply ) ;
2007-06-04 19:53:19 +10:00
2007-06-04 20:22:44 +10:00
void ctdb_tunables_set_defaults ( struct ctdb_context * ctdb ) ;
2007-06-07 15:18:55 +10:00
int32_t ctdb_control_modflags ( struct ctdb_context * ctdb , TDB_DATA indata ) ;
2007-06-07 11:15:22 +10:00
2007-06-07 18:05:25 +10:00
int ctdb_ctrl_get_all_tunables ( struct ctdb_context * ctdb ,
struct timeval timeout ,
uint32_t destnode ,
struct ctdb_tunable * tunables ) ;
2013-07-01 16:28:04 +10:00
void ctdb_start_freeze ( struct ctdb_context * ctdb , uint32_t priority ) ;
2007-06-10 08:46:33 +10:00
2009-01-19 15:33:24 +01:00
bool parse_ip_mask ( const char * s , const char * iface , ctdb_sock_addr * addr , unsigned * mask ) ;
2008-08-19 14:58:29 +10:00
bool parse_ip_port ( const char * s , ctdb_sock_addr * addr ) ;
2009-03-24 13:45:11 +11:00
bool parse_ip ( const char * s , const char * iface , unsigned port , ctdb_sock_addr * addr ) ;
2008-10-14 10:40:29 +11:00
bool parse_ipv4 ( const char * s , unsigned port , struct sockaddr_in * sin ) ;
2008-08-19 14:58:29 +10:00
2007-07-04 16:51:13 +10:00
2007-07-13 17:07:10 +10:00
int ctdb_sys_open_capture_socket ( const char * iface , void * * private_data ) ;
int ctdb_sys_close_capture_socket ( void * private_data ) ;
2008-08-19 14:58:29 +10:00
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 ) ;
2007-07-11 12:33:14 +10:00
2007-07-12 08:30:04 +10:00
int ctdb_ctrl_killtcp ( struct ctdb_context * ctdb ,
struct timeval timeout ,
uint32_t destnode ,
struct ctdb_control_killtcp * killtcp ) ;
2008-03-27 09:23:27 +11:00
int ctdb_ctrl_add_public_ip ( struct ctdb_context * ctdb ,
struct timeval timeout ,
uint32_t destnode ,
struct ctdb_control_ip_iface * pub ) ;
int ctdb_ctrl_del_public_ip ( struct ctdb_context * ctdb ,
struct timeval timeout ,
uint32_t destnode ,
struct ctdb_control_ip_iface * pub ) ;
2007-10-09 11:56:09 +10:00
int ctdb_ctrl_gratious_arp ( struct ctdb_context * ctdb ,
struct timeval timeout ,
uint32_t destnode ,
2008-06-04 15:13:00 +10:00
ctdb_sock_addr * addr ,
2007-10-09 11:56:09 +10:00
const char * ifname ) ;
2007-07-20 15:05:55 +10:00
int ctdb_ctrl_get_tcp_tickles ( struct ctdb_context * ctdb ,
struct timeval timeout ,
uint32_t destnode ,
TALLOC_CTX * mem_ctx ,
2008-08-19 14:58:29 +10:00
ctdb_sock_addr * addr ,
2007-07-20 15:05:55 +10:00
struct ctdb_control_tcp_tickle_list * * list ) ;
2007-07-12 08:30:04 +10:00
2007-08-24 15:53:41 +10:00
int32_t ctdb_control_register_server_id ( struct ctdb_context * ctdb ,
uint32_t client_id ,
TDB_DATA indata ) ;
int32_t ctdb_control_check_server_id ( struct ctdb_context * ctdb ,
TDB_DATA indata ) ;
int32_t ctdb_control_unregister_server_id ( struct ctdb_context * ctdb ,
TDB_DATA indata ) ;
2007-08-26 10:57:02 +10:00
int32_t ctdb_control_get_server_id_list ( struct ctdb_context * ctdb ,
TDB_DATA * outdata ) ;
2008-01-17 11:33:23 +11:00
int32_t ctdb_control_uptime ( struct ctdb_context * ctdb ,
TDB_DATA * outdata ) ;
2007-08-24 15:53:41 +10:00
2009-11-29 12:39:23 +01:00
int ctdb_attach_databases ( struct ctdb_context * ctdb ) ;
2007-09-21 12:24:02 +10:00
int32_t ctdb_control_persistent_store ( struct ctdb_context * ctdb ,
struct ctdb_req_control * c ,
TDB_DATA recdata , bool * async_reply ) ;
int32_t ctdb_control_update_record ( struct ctdb_context * ctdb ,
struct ctdb_req_control * c , TDB_DATA recdata ,
bool * async_reply ) ;
2009-12-03 17:59:49 +01:00
int32_t ctdb_control_trans3_commit ( struct ctdb_context * ctdb ,
struct ctdb_req_control * c ,
TDB_DATA recdata , bool * async_reply ) ;
2011-02-23 17:38:40 +01:00
void ctdb_persistent_finish_trans3_commits ( struct ctdb_context * ctdb ) ;
2008-01-06 13:24:55 +11:00
int32_t ctdb_control_transaction_start ( struct ctdb_context * ctdb , uint32_t id ) ;
int32_t ctdb_control_transaction_commit ( struct ctdb_context * ctdb , uint32_t id ) ;
2009-10-12 16:48:05 +11:00
int32_t ctdb_control_transaction_cancel ( struct ctdb_context * ctdb ) ;
2008-01-06 12:38:01 +11:00
int32_t ctdb_control_wipe_database ( struct ctdb_context * ctdb , TDB_DATA indata ) ;
2009-12-02 12:48:22 +01:00
int32_t ctdb_control_db_set_healthy ( struct ctdb_context * ctdb , TDB_DATA indata ) ;
int32_t ctdb_control_db_get_health ( struct ctdb_context * ctdb ,
TDB_DATA indata ,
TDB_DATA * outdata ) ;
2007-09-21 12:24:02 +10:00
2008-01-08 17:23:27 +11:00
int ctdb_repack ( struct ctdb_context * ctdb , int argc , const char * * argv ) ;
2008-01-10 14:40:56 +11:00
int32_t ctdb_monitoring_mode ( struct ctdb_context * ctdb ) ;
2012-10-29 14:56:10 +11:00
bool ctdb_stopped_monitoring ( struct ctdb_context * ctdb ) ;
2008-01-16 22:03:01 +11:00
int ctdb_set_child_logging ( struct ctdb_context * ctdb ) ;
2014-06-10 17:00:38 +10:00
void lockdown_memory ( bool valgrinding ) ;
2008-01-29 13:59:28 +11:00
struct client_async_data {
2008-07-02 12:21:53 +10:00
enum ctdb_controls opcode ;
2008-01-29 13:59:28 +11:00
bool dont_log_errors ;
uint32_t count ;
uint32_t fail_count ;
2008-05-06 15:42:59 +10:00
client_async_callback callback ;
2008-06-12 16:53:36 +10:00
client_async_callback fail_callback ;
void * callback_data ;
2008-01-29 13:59:28 +11:00
} ;
void ctdb_client_async_add ( struct client_async_data * data , struct ctdb_client_control_state * state ) ;
int ctdb_client_async_wait ( struct ctdb_context * ctdb , struct client_async_data * data ) ;
int ctdb_client_async_control ( struct ctdb_context * ctdb ,
enum ctdb_controls opcode ,
uint32_t * nodes ,
2009-10-12 12:08:39 +11:00
uint64_t srvid ,
2008-01-29 13:59:28 +11:00
struct timeval timeout ,
bool dont_log_errors ,
2008-05-06 15:42:59 +10:00
TDB_DATA data ,
2008-06-12 16:53:36 +10:00
client_async_callback client_callback ,
client_async_callback fail_callback ,
void * callback_data ) ;
2008-01-29 13:59:28 +11:00
2015-02-20 12:34:25 +11:00
struct ctdb_node_map *
ctdb_node_list_to_map ( struct ctdb_node * * nodes , uint32_t num_nodes ,
TALLOC_CTX * mem_ctx ) ;
2015-02-22 06:49:04 +11:00
struct ctdb_node_map * ctdb_read_nodes_file ( TALLOC_CTX * mem_ctx ,
const char * nlist ) ;
2008-02-19 14:44:48 +11:00
void ctdb_load_nodes_file ( struct ctdb_context * ctdb ) ;
int ctdb_control_reload_nodes_file ( struct ctdb_context * ctdb , uint32_t opcode ) ;
2008-04-01 15:34:54 +11:00
int32_t ctdb_dump_memory ( struct ctdb_context * ctdb , TDB_DATA * outdata ) ;
2008-05-06 15:42:59 +10:00
int32_t ctdb_control_get_capabilities ( struct ctdb_context * ctdb , TDB_DATA * outdata ) ;
2008-01-29 13:59:28 +11:00
2008-08-19 14:58:29 +10:00
char * ctdb_addr_to_str ( ctdb_sock_addr * addr ) ;
2009-03-24 13:45:11 +11:00
unsigned ctdb_addr_to_port ( ctdb_sock_addr * addr ) ;
2008-08-20 11:58:27 +10:00
void ctdb_canonicalize_ip ( const ctdb_sock_addr * ip , ctdb_sock_addr * cip ) ;
2008-09-09 13:44:46 +10:00
int32_t ctdb_control_recd_ping ( struct ctdb_context * ctdb ) ;
2008-10-22 11:04:41 +11:00
int32_t ctdb_control_set_recmaster ( struct ctdb_context * ctdb , uint32_t opcode , TDB_DATA indata ) ;
2008-08-19 14:58:29 +10:00
2008-10-17 07:56:12 +11:00
extern int script_log_level ;
2010-06-22 22:52:34 +09:30
extern bool fast_start ;
2013-04-15 13:32:57 +10:00
extern const char * ctdbd_pidfile ;
2008-10-17 07:56:12 +11:00
2009-12-08 01:50:55 +10:30
int32_t ctdb_control_get_event_script_status ( struct ctdb_context * ctdb ,
uint32_t call_type ,
TDB_DATA * outdata ) ;
2009-03-23 19:07:45 +11:00
2009-05-14 10:33:25 +10:00
int ctdb_ctrl_report_recd_lock_latency ( struct ctdb_context * ctdb , struct timeval timeout , double latency ) ;
2009-03-23 19:07:45 +11:00
2013-02-21 14:28:13 +11:00
int32_t ctdb_control_stop_node ( struct ctdb_context * ctdb ) ;
2009-07-09 12:22:46 +10:00
int32_t ctdb_control_continue_node ( struct ctdb_context * ctdb ) ;
2010-07-21 12:29:55 +09:30
void ctdb_stop_vacuuming ( struct ctdb_context * ctdb ) ;
2009-07-29 13:25:43 +10:00
int ctdb_vacuum_init ( struct ctdb_db_context * ctdb_db ) ;
2009-08-13 13:04:08 +10:00
int32_t ctdb_control_enable_script ( struct ctdb_context * ctdb , TDB_DATA indata ) ;
int32_t ctdb_control_disable_script ( struct ctdb_context * ctdb , TDB_DATA indata ) ;
2013-06-28 14:04:18 +10:00
void ctdb_local_node_got_banned ( struct ctdb_context * ctdb ) ;
2009-09-04 02:20:39 +10:00
int32_t ctdb_control_set_ban_state ( struct ctdb_context * ctdb , TDB_DATA indata ) ;
int32_t ctdb_control_get_ban_state ( struct ctdb_context * ctdb , TDB_DATA * outdata ) ;
2014-04-02 17:17:47 +11:00
int32_t ctdb_control_set_db_priority ( struct ctdb_context * ctdb , TDB_DATA indata ,
uint32_t client_id ) ;
2009-12-07 23:18:40 +10:30
void ctdb_ban_self ( struct ctdb_context * ctdb ) ;
2009-09-04 02:20:39 +10:00
2009-10-23 15:24:51 +11:00
int32_t ctdb_control_register_notify ( struct ctdb_context * ctdb , uint32_t client_id , TDB_DATA indata ) ;
int32_t ctdb_control_deregister_notify ( struct ctdb_context * ctdb , uint32_t client_id , TDB_DATA indata ) ;
2013-12-16 15:39:29 +11:00
struct ctdb_log_state * ctdb_vfork_with_logging ( TALLOC_CTX * mem_ctx ,
struct ctdb_context * ctdb ,
const char * log_prefix ,
const char * helper ,
int helper_argc ,
const char * * helper_argv ,
void ( * logfn ) ( const char * , uint16_t , void * ) ,
void * logfn_private , pid_t * pid ) ;
2009-11-18 12:44:18 +11:00
2009-12-02 13:58:27 +11:00
int32_t ctdb_control_process_exists ( struct ctdb_context * ctdb , pid_t pid ) ;
struct ctdb_client * ctdb_find_client_by_pid ( struct ctdb_context * ctdb , pid_t pid ) ;
2009-12-11 15:31:02 +01:00
int32_t ctdb_control_get_db_seqnum ( struct ctdb_context * ctdb ,
TDB_DATA indata ,
TDB_DATA * outdata ) ;
2009-12-07 13:28:11 +01:00
int ctdb_load_persistent_health ( struct ctdb_context * ctdb ,
struct ctdb_db_context * ctdb_db ) ;
int ctdb_update_persistent_health ( struct ctdb_context * ctdb ,
struct ctdb_db_context * ctdb_db ,
const char * reason , /* NULL means healthy */
int num_healthy_nodes ) ;
int ctdb_recheck_persistent_health ( struct ctdb_context * ctdb ) ;
2010-01-19 10:07:14 +01:00
void ctdb_run_notification_script ( struct ctdb_context * ctdb , const char * event ) ;
2015-06-11 15:46:27 +10:00
int verify_remote_ip_allocation ( struct ctdb_context * ctdb ,
2013-06-30 18:45:46 +10:00
struct ctdb_all_public_ips * ips ,
uint32_t pnn ) ;
2010-04-28 15:43:11 +10:00
int update_ip_assignment_tree ( struct ctdb_context * ctdb ,
struct ctdb_public_ip * ip ) ;
2015-06-11 15:46:27 +10:00
void clear_ip_assignment_tree ( struct ctdb_context * ctdb ) ;
2010-04-08 14:07:57 +10:00
2010-09-22 10:59:01 +10:00
int ctdb_init_tevent_logging ( struct ctdb_context * ctdb ) ;
2010-09-29 12:13:05 +10:00
int ctdb_statistics_init ( struct ctdb_context * ctdb ) ;
int32_t ctdb_control_get_stat_history ( struct ctdb_context * ctdb ,
struct ctdb_req_control * c ,
TDB_DATA * outdata ) ;
2010-09-29 10:38:41 +10:00
2010-11-09 15:19:06 +11:00
int ctdb_deferred_drop_all_ips ( struct ctdb_context * ctdb ) ;
2011-02-23 15:46:36 +11:00
int ctdb_process_deferred_attach ( struct ctdb_context * ctdb ) ;
2010-12-21 14:25:48 +01:00
/**
* structure to pass to a schedule_for_deletion_control
*/
struct ctdb_control_schedule_for_deletion {
uint32_t db_id ;
struct ctdb_ltdb_header hdr ;
uint32_t keylen ;
uint8_t key [ 1 ] ; /* key[] */
} ;
int32_t ctdb_control_schedule_for_deletion ( struct ctdb_context * ctdb ,
TDB_DATA indata ) ;
2010-12-28 13:13:34 +01:00
int32_t ctdb_local_schedule_for_deletion ( struct ctdb_db_context * ctdb_db ,
const struct ctdb_ltdb_header * hdr ,
TDB_DATA key ) ;
2011-04-07 12:17:16 +02:00
void ctdb_local_remove_from_delete_queue ( struct ctdb_db_context * ctdb_db ,
const struct ctdb_ltdb_header * hdr ,
const TDB_DATA key ) ;
2010-12-21 15:29:23 +01:00
struct ctdb_ltdb_header * ctdb_header_from_record_handle ( struct ctdb_record_handle * h ) ;
2011-07-20 11:39:50 +10:00
int ctdb_trackingdb_add_pnn ( struct ctdb_context * ctdb , TDB_DATA * data , uint32_t pnn ) ;
typedef void ( * ctdb_trackingdb_cb ) ( struct ctdb_context * ctdb , uint32_t pnn , void * private_data ) ;
void ctdb_trackingdb_traverse ( struct ctdb_context * ctdb , TDB_DATA data , ctdb_trackingdb_cb cb , void * private_data ) ;
2011-07-28 15:22:42 +10:00
2011-08-23 10:27:31 +10:00
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 ) ;
2011-07-20 13:49:17 +10:00
typedef void ( * deferred_requeue_fn ) ( void * call_context , struct ctdb_req_header * hdr ) ;
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 ) ;
2011-09-01 11:08:18 +10:00
int ctdb_set_db_readonly ( struct ctdb_context * ctdb , struct ctdb_db_context * ctdb_db ) ;
2011-07-28 15:22:42 +10:00
2011-11-11 13:56:46 +11:00
int ctdb_null_func ( struct ctdb_call_info * call ) ;
int ctdb_fetch_func ( struct ctdb_call_info * call ) ;
int ctdb_fetch_with_header_func ( struct ctdb_call_info * call ) ;
2015-04-02 13:53:09 +11:00
void ctdb_db_statistics_reset ( struct ctdb_db_context * ctdb_db ) ;
2013-07-15 14:52:07 +10:00
int32_t ctdb_control_get_db_statistics ( struct ctdb_context * ctdb ,
uint32_t db_id ,
TDB_DATA * outdata ) ;
2012-03-20 16:58:35 +11:00
int ctdb_set_db_sticky ( struct ctdb_context * ctdb , struct ctdb_db_context * ctdb_db ) ;
2012-04-30 15:50:44 +10:00
/*
description for a message to reload all ips via recovery master / daemon
*/
struct reloadips_all_reply {
uint32_t pnn ;
uint64_t srvid ;
} ;
int32_t ctdb_control_reload_public_ips ( struct ctdb_context * ctdb , struct ctdb_req_control * c , bool * async_reply ) ;
2012-10-11 11:29:29 +11:00
/* from server/ctdb_lock.c */
struct lock_request ;
int ctdb_lockall_mark_prio ( struct ctdb_context * ctdb , uint32_t priority ) ;
int ctdb_lockall_unmark_prio ( struct ctdb_context * ctdb , uint32_t priority ) ;
2014-08-11 17:08:20 +10:00
struct lock_request * ctdb_lock_record ( TALLOC_CTX * mem_ctx ,
struct ctdb_db_context * ctdb_db ,
2012-10-11 11:29:29 +11:00
TDB_DATA key ,
bool auto_mark ,
void ( * callback ) ( void * , bool ) ,
void * private_data ) ;
2014-08-11 17:08:20 +10:00
struct lock_request * ctdb_lock_db ( TALLOC_CTX * mem_ctx ,
struct ctdb_db_context * ctdb_db ,
2012-10-11 11:29:29 +11:00
bool auto_mark ,
void ( * callback ) ( void * , bool ) ,
void * private_data ) ;
2014-08-11 17:08:20 +10:00
struct lock_request * ctdb_lock_alldb_prio ( TALLOC_CTX * mem_ctx ,
struct ctdb_context * ctdb ,
2012-10-11 11:29:29 +11:00
uint32_t priority ,
bool auto_mark ,
void ( * callback ) ( void * , bool ) ,
void * private_data ) ;
2014-08-11 17:08:20 +10:00
struct lock_request * ctdb_lock_alldb ( TALLOC_CTX * mem_ctx ,
struct ctdb_context * ctdb ,
2012-10-11 11:29:29 +11:00
bool auto_mark ,
void ( * callback ) ( void * , bool ) ,
void * private_data ) ;
2013-10-21 19:08:52 +11:00
int mkdir_p ( const char * dir , int mode ) ;
2014-06-06 15:24:20 +10:00
void mkdir_p_or_die ( const char * dir , int mode ) ;
2013-10-21 19:08:52 +11:00
2014-07-30 20:50:59 +10:00
ssize_t sys_read ( int fd , void * buf , size_t count ) ;
ssize_t sys_write ( int fd , const void * buf , size_t count ) ;
2007-01-23 11:38:45 +11:00
# endif