summaryrefslogtreecommitdiffstats
path: root/ctdb/include
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 17:20:00 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 17:20:00 +0000
commit8daa83a594a2e98f39d764422bfbdbc62c9efd44 (patch)
tree4099e8021376c7d8c05bdf8503093d80e9c7bad0 /ctdb/include
parentInitial commit. (diff)
downloadsamba-8daa83a594a2e98f39d764422bfbdbc62c9efd44.tar.xz
samba-8daa83a594a2e98f39d764422bfbdbc62c9efd44.zip
Adding upstream version 2:4.20.0+dfsg.upstream/2%4.20.0+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'ctdb/include')
l---------ctdb/include/common/srvid.h1
-rw-r--r--ctdb/include/ctdb_client.h289
-rw-r--r--ctdb/include/ctdb_private.h1040
-rw-r--r--ctdb/include/ctdb_protocol.h301
-rw-r--r--ctdb/include/public/README.txt6
-rw-r--r--ctdb/include/public/util/README.txt6
6 files changed, 1643 insertions, 0 deletions
diff --git a/ctdb/include/common/srvid.h b/ctdb/include/common/srvid.h
new file mode 120000
index 0000000..5a36c27
--- /dev/null
+++ b/ctdb/include/common/srvid.h
@@ -0,0 +1 @@
+../../common/srvid.h \ No newline at end of file
diff --git a/ctdb/include/ctdb_client.h b/ctdb/include/ctdb_client.h
new file mode 100644
index 0000000..b993620
--- /dev/null
+++ b/ctdb/include/ctdb_client.h
@@ -0,0 +1,289 @@
+/*
+ ctdb database library: old client interface
+
+ Copyright (C) Andrew Tridgell 2006
+
+ 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
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ 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
+ along with this program; if not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _CTDB_CLIENT_H
+#define _CTDB_CLIENT_H
+
+#include "common/srvid.h"
+#include "ctdb_protocol.h"
+
+enum control_state {
+ CTDB_CONTROL_WAIT,
+ CTDB_CONTROL_DONE,
+ CTDB_CONTROL_ERROR,
+ CTDB_CONTROL_TIMEOUT
+};
+
+struct ctdb_client_control_state {
+ struct ctdb_context *ctdb;
+ uint32_t reqid;
+ int32_t status;
+ TDB_DATA outdata;
+ enum control_state state;
+ char *errormsg;
+ struct ctdb_req_control_old *c;
+
+ /* if we have a callback registered for the completion (or failure) of
+ this control
+ if a callback is used, it MUST talloc_free the cb_data passed to it
+ */
+ struct {
+ void (*fn)(struct ctdb_client_control_state *);
+ void *private_data;
+ } async;
+};
+
+struct tevent_context;
+struct ctdb_db_context;
+
+/*
+ allocate a packet for use in client<->daemon communication
+ */
+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)
+
+int ctdb_call_local(struct ctdb_db_context *ctdb_db, struct ctdb_call *call,
+ struct ctdb_ltdb_header *header, TALLOC_CTX *mem_ctx,
+ TDB_DATA *data, bool updatetdb);
+
+void ctdb_request_message(struct ctdb_context *ctdb,
+ struct ctdb_req_header *hdr);
+
+void ctdb_client_read_cb(uint8_t *data, size_t cnt, void *args);
+
+int ctdb_socket_connect(struct ctdb_context *ctdb);
+
+/*
+ make a ctdb call. The associated ctdb call function will be called on the DMASTER
+ for the given record
+*/
+struct ctdb_client_call_state *ctdb_call_send(struct ctdb_db_context *ctdb_db,
+ struct ctdb_call *call);
+int ctdb_call_recv(struct ctdb_client_call_state *state,
+ struct ctdb_call *call);
+int ctdb_call(struct ctdb_db_context *ctdb_db, struct ctdb_call *call);
+
+/* setup a handler for ctdb messages */
+typedef void (*ctdb_msg_fn_t)(struct ctdb_context *, uint64_t srvid,
+ TDB_DATA data, void *);
+
+int ctdb_client_set_message_handler(struct ctdb_context *ctdb, uint64_t srvid,
+ srvid_handler_fn handler,
+ void *private_data);
+int ctdb_client_remove_message_handler(struct ctdb_context *ctdb,
+ uint64_t srvid, void *private_data);
+
+/* send a ctdb message */
+int ctdb_client_send_message(struct ctdb_context *ctdb, uint32_t pnn,
+ uint64_t srvid, TDB_DATA data);
+
+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,
+ TALLOC_CTX *mem_ctx,
+ struct timeval *timeout,
+ char **errormsg);
+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);
+int ctdb_control(struct ctdb_context *ctdb, uint32_t destnode, uint64_t srvid,
+ uint32_t opcode, uint32_t flags, TDB_DATA data,
+ TALLOC_CTX *mem_ctx, TDB_DATA *outdata, int32_t *status,
+ struct timeval *timeout, char **errormsg);
+
+int ctdb_ctrl_getvnnmap(struct ctdb_context *ctdb, struct timeval timeout,
+ uint32_t destnode, TALLOC_CTX *mem_ctx,
+ struct ctdb_vnn_map **vnnmap);
+
+/*
+ get the recovery mode of a remote node
+ */
+struct ctdb_client_control_state *ctdb_ctrl_getrecmode_send(
+ struct ctdb_context *ctdb,
+ TALLOC_CTX *mem_ctx,
+ struct timeval timeout,
+ uint32_t destnode);
+int ctdb_ctrl_getrecmode_recv(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx,
+ struct ctdb_client_control_state *state,
+ uint32_t *recmode);
+int ctdb_ctrl_getrecmode(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx,
+ struct timeval timeout, uint32_t destnode,
+ uint32_t *recmode);
+
+/*
+ set the recovery mode of a remote node
+ */
+int ctdb_ctrl_setrecmode(struct ctdb_context *ctdb, struct timeval timeout,
+ uint32_t destnode, uint32_t recmode);
+
+int ctdb_ctrl_getnodemap(struct ctdb_context *ctdb, struct timeval timeout,
+ uint32_t destnode, TALLOC_CTX *mem_ctx,
+ struct ctdb_node_map_old **nodemap);
+
+int ctdb_ctrl_get_runstate(struct ctdb_context *ctdb, struct timeval timeout,
+ uint32_t destnode, uint32_t *runstate);
+
+int ctdb_ctrl_get_debuglevel(struct ctdb_context *ctdb, uint32_t destnode,
+ int32_t *level);
+
+int ctdb_ctrl_freeze(struct ctdb_context *ctdb, struct timeval timeout,
+ uint32_t destnode);
+
+int ctdb_ctrl_getpnn(struct ctdb_context *ctdb, struct timeval timeout,
+ uint32_t destnode);
+
+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_public_ip_list_old **ips);
+int ctdb_ctrl_get_public_ips(struct ctdb_context *ctdb,
+ struct timeval timeout, uint32_t destnode,
+ TALLOC_CTX *mem_ctx,
+ struct ctdb_public_ip_list_old **ips);
+
+int ctdb_ctrl_get_ifaces(struct ctdb_context *ctdb,
+ struct timeval timeout, uint32_t destnode,
+ TALLOC_CTX *mem_ctx,
+ struct ctdb_iface_list_old **ifaces);
+
+int ctdb_ctrl_get_all_tunables(struct ctdb_context *ctdb,
+ struct timeval timeout, uint32_t destnode,
+ struct ctdb_tunable_list *tunables);
+
+/*
+ set some flags
+*/
+void ctdb_set_flags(struct ctdb_context *ctdb, unsigned flags);
+
+const char *ctdb_get_socketname(struct ctdb_context *ctdb);
+
+/* return pnn of this node */
+uint32_t ctdb_get_pnn(struct ctdb_context *ctdb);
+
+typedef void (*client_async_callback)(struct ctdb_context *ctdb,
+ uint32_t node_pnn, int32_t res,
+ TDB_DATA outdata, void *callback_data);
+
+struct client_async_data {
+ enum ctdb_controls opcode;
+ bool dont_log_errors;
+ uint32_t count;
+ uint32_t fail_count;
+ client_async_callback callback;
+ client_async_callback fail_callback;
+ void *callback_data;
+};
+
+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,
+ uint64_t srvid, struct timeval timeout,
+ bool dont_log_errors, TDB_DATA data,
+ client_async_callback client_callback,
+ client_async_callback fail_callback,
+ void *callback_data);
+
+uint32_t *list_of_vnnmap_nodes(struct ctdb_context *ctdb,
+ struct ctdb_vnn_map *vnn_map,
+ TALLOC_CTX *mem_ctx, bool include_self);
+
+uint32_t *list_of_active_nodes(struct ctdb_context *ctdb,
+ struct ctdb_node_map_old *node_map,
+ TALLOC_CTX *mem_ctx, bool include_self);
+uint32_t *list_of_connected_nodes(struct ctdb_context *ctdb,
+ struct ctdb_node_map_old *node_map,
+ TALLOC_CTX *mem_ctx, bool include_self);
+
+/*
+ get capabilities of a remote node
+ */
+
+struct ctdb_client_control_state *ctdb_ctrl_getcapabilities_send(
+ struct ctdb_context *ctdb,
+ TALLOC_CTX *mem_ctx,
+ struct timeval timeout,
+ uint32_t destnode);
+int ctdb_ctrl_getcapabilities_recv(struct ctdb_context *ctdb,
+ TALLOC_CTX *mem_ctx,
+ struct ctdb_client_control_state *state,
+ uint32_t *capabilities);
+int ctdb_ctrl_getcapabilities(struct ctdb_context *ctdb,
+ struct timeval timeout, uint32_t destnode,
+ uint32_t *capabilities);
+
+struct ctdb_node_capabilities {
+ bool retrieved;
+ uint32_t capabilities;
+};
+
+/* Retrieve capabilities for all connected nodes. The length of the
+ * returned array can be calculated using talloc_array_length(). */
+struct ctdb_node_capabilities *ctdb_get_capabilities(
+ struct ctdb_context *ctdb,
+ TALLOC_CTX *mem_ctx,
+ struct timeval timeout,
+ struct ctdb_node_map_old *nodemap);
+
+/* Get capabilities for specified node, NULL if not found */
+uint32_t *ctdb_get_node_capabilities(struct ctdb_node_capabilities *caps,
+ uint32_t pnn);
+
+/* True if the given node has all of the required capabilities */
+bool ctdb_node_has_capabilities(struct ctdb_node_capabilities *caps,
+ uint32_t pnn, uint32_t capabilities_required);
+
+int ctdb_ctrl_recd_ping(struct ctdb_context *ctdb);
+
+int ctdb_ctrl_report_recd_lock_latency(struct ctdb_context *ctdb,
+ struct timeval timeout, double latency);
+
+int ctdb_ctrl_set_ban(struct ctdb_context *ctdb, struct timeval timeout,
+ uint32_t destnode, struct ctdb_ban_state *bantime);
+
+struct ctdb_client_control_state *ctdb_ctrl_updaterecord_send(
+ struct ctdb_context *ctdb,
+ TALLOC_CTX *mem_ctx,
+ struct timeval timeout,
+ uint32_t destnode,
+ struct ctdb_db_context *ctdb_db,
+ TDB_DATA key,
+ struct ctdb_ltdb_header *header,
+ TDB_DATA data);
+int ctdb_ctrl_updaterecord_recv(struct ctdb_context *ctdb,
+ struct ctdb_client_control_state *state);
+int ctdb_ctrl_updaterecord(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx,
+ struct timeval timeout, uint32_t destnode,
+ struct ctdb_db_context *ctdb_db, TDB_DATA key,
+ struct ctdb_ltdb_header *header, TDB_DATA data);
+
+#endif /* _CTDB_CLIENT_H */
diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h
new file mode 100644
index 0000000..8027812
--- /dev/null
+++ b/ctdb/include/ctdb_private.h
@@ -0,0 +1,1040 @@
+/*
+ ctdb database library
+
+ Copyright (C) Andrew Tridgell 2006
+
+ 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
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ 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
+ along with this program; if not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _CTDB_PRIVATE_H
+#define _CTDB_PRIVATE_H
+
+#include "ctdb_client.h"
+#include <sys/socket.h>
+
+#include "common/db_hash.h"
+
+/*
+ array of tcp connections
+ */
+struct ctdb_tcp_array {
+ uint32_t num;
+ struct ctdb_connection *connections;
+};
+
+/*
+ an installed ctdb remote call
+*/
+typedef int (*ctdb_fn_t)(struct ctdb_call_info *);
+
+struct ctdb_registered_call {
+ struct ctdb_registered_call *next, *prev;
+ uint32_t id;
+ ctdb_fn_t fn;
+};
+
+/*
+ check that a pnn is valid
+ */
+#define ctdb_validate_pnn(ctdb, pnn) (((uint32_t)(pnn)) < (ctdb)->num_nodes)
+
+/* used for callbacks in ctdb_control requests */
+typedef void (*ctdb_control_callback_fn_t)(struct ctdb_context *,
+ int32_t status, TDB_DATA data,
+ const char *errormsg,
+ void *private_data);
+/*
+ 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;
+ pid_t pid;
+ struct ctdb_tcp_list *tcp_list;
+ uint32_t db_id;
+ uint32_t num_persistent_updates;
+ struct ctdb_client_notify_list *notify;
+};
+
+/*
+ state associated with one node
+*/
+struct ctdb_node {
+ struct ctdb_context *ctdb;
+ ctdb_sock_addr address;
+ const char *name; /* for debug messages */
+ void *transport_data; /* private to transport */
+ uint32_t pnn;
+ uint32_t flags;
+
+ /* used by the dead node monitoring */
+ uint32_t dead_count;
+ uint32_t rx_cnt;
+ uint32_t tx_cnt;
+
+ /* 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;
+};
+
+/*
+ transport specific methods
+*/
+struct ctdb_methods {
+ int (*initialise)(struct ctdb_context *); /* initialise transport structures */
+ int (*start)(struct ctdb_context *); /* start the transport */
+ int (*add_node)(struct ctdb_node *); /* setup a new node */
+ int (*connect_node)(struct ctdb_node *); /* connect to node */
+ int (*queue_pkt)(struct ctdb_node *, uint8_t *data, uint32_t length);
+ void *(*allocate_pkt)(TALLOC_CTX *mem_ctx, size_t );
+ void (*shutdown)(struct ctdb_context *); /* shutdown transport */
+ void (*restart)(struct ctdb_node *); /* stop and restart the connection */
+};
+
+/*
+ transport calls up to the ctdb layer
+*/
+struct ctdb_upcalls {
+ /* recv_pkt is called when a packet comes in */
+ void (*recv_pkt)(struct ctdb_context *, uint8_t *data, uint32_t length);
+
+ /* node_dead is called when an attempt to send to a node fails */
+ void (*node_dead)(struct ctdb_node *);
+
+ /* node_connected is called when a connection to a node is established */
+ void (*node_connected)(struct ctdb_node *);
+};
+
+/* additional data required for the daemon mode */
+struct ctdb_daemon_data {
+ int sd;
+ char *name;
+ struct ctdb_queue *queue;
+};
+
+
+#define CTDB_UPDATE_STAT(ctdb, counter, value) \
+ { \
+ if (value > ctdb->statistics.counter) { \
+ ctdb->statistics.counter = value; \
+ } \
+ if (value > ctdb->statistics_current.counter) { \
+ ctdb->statistics_current.counter = value; \
+ } \
+ }
+
+#define CTDB_INCREMENT_STAT(ctdb, counter) \
+ { \
+ ctdb->statistics.counter++; \
+ ctdb->statistics_current.counter++; \
+ }
+
+#define CTDB_DECREMENT_STAT(ctdb, counter) \
+ { \
+ if (ctdb->statistics.counter > 0) \
+ ctdb->statistics.counter--; \
+ if (ctdb->statistics_current.counter > 0) \
+ ctdb->statistics_current.counter--; \
+ }
+
+#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--; \
+ }
+
+#define CTDB_UPDATE_RECLOCK_LATENCY(ctdb, name, counter, value) \
+ { \
+ if (value > ctdb->statistics.counter.max) \
+ ctdb->statistics.counter.max = value; \
+ if (value > ctdb->statistics_current.counter.max) \
+ ctdb->statistics_current.counter.max = value; \
+ \
+ if (ctdb->statistics.counter.num == 0 || \
+ value < ctdb->statistics.counter.min) \
+ ctdb->statistics.counter.min = value; \
+ if (ctdb->statistics_current.counter.num == 0 || \
+ value < ctdb->statistics_current.counter.min) \
+ ctdb->statistics_current.counter.min = value; \
+ \
+ ctdb->statistics.counter.total += value; \
+ ctdb->statistics_current.counter.total += value; \
+ \
+ ctdb->statistics.counter.num++; \
+ ctdb->statistics_current.counter.num++; \
+ \
+ if (ctdb->tunable.reclock_latency_ms != 0) { \
+ if (value*1000 > ctdb->tunable.reclock_latency_ms) { \
+ DEBUG(DEBUG_ERR, \
+ ("High RECLOCK latency %fs for operation %s\n", \
+ value, name)); \
+ } \
+ } \
+ }
+
+#define CTDB_UPDATE_DB_LATENCY(ctdb_db, operation, counter, value) \
+ { \
+ 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++; \
+ \
+ if (ctdb_db->ctdb->tunable.log_latency_ms != 0) { \
+ if (value*1000 > ctdb_db->ctdb->tunable.log_latency_ms) { \
+ DEBUG(DEBUG_ERR, \
+ ("High latency %.6fs for operation %s on database %s\n",\
+ value, operation, ctdb_db->db_name)); \
+ } \
+ } \
+ }
+
+#define CTDB_UPDATE_LATENCY(ctdb, db, operation, counter, t) \
+ { \
+ double l = timeval_elapsed(&t); \
+ \
+ if (l > ctdb->statistics.counter.max) \
+ ctdb->statistics.counter.max = l; \
+ if (l > ctdb->statistics_current.counter.max) \
+ ctdb->statistics_current.counter.max = l; \
+ \
+ if (ctdb->statistics.counter.num == 0 || \
+ l < ctdb->statistics.counter.min) \
+ ctdb->statistics.counter.min = l; \
+ if (ctdb->statistics_current.counter.num == 0 || \
+ l < ctdb->statistics_current.counter.min) \
+ 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++; \
+ \
+ if (ctdb->tunable.log_latency_ms != 0) { \
+ if (l*1000 > ctdb->tunable.log_latency_ms) { \
+ DEBUG(DEBUG_WARNING, \
+ ("High latency %.6fs for operation %s on database %s\n",\
+ l, operation, db->db_name)); \
+ } \
+ } \
+ }
+
+
+struct ctdb_cluster_mutex_handle;
+struct eventd_context;
+
+enum ctdb_freeze_mode {CTDB_FREEZE_NONE, CTDB_FREEZE_PENDING, CTDB_FREEZE_FROZEN};
+
+/* main state of the ctdb daemon */
+struct ctdb_context {
+ struct tevent_context *ev;
+ struct timeval ctdbd_start_time;
+ struct timeval last_recovery_started;
+ struct timeval last_recovery_finished;
+ uint32_t recovery_mode;
+ TALLOC_CTX *tickle_update_context;
+ TALLOC_CTX *keepalive_ctx;
+ TALLOC_CTX *check_public_ifaces_ctx;
+ struct ctdb_tunable_list tunable;
+ enum ctdb_freeze_mode freeze_mode;
+ struct ctdb_freeze_handle *freeze_handle;
+ bool freeze_transaction_started;
+ uint32_t freeze_transaction_id;
+ ctdb_sock_addr *address;
+ const char *name;
+ const char *db_directory;
+ const char *db_directory_persistent;
+ const char *db_directory_state;
+ struct tdb_wrap *db_persistent_health;
+ uint32_t db_persistent_startup_generation;
+ uint64_t db_persistent_check_errors;
+ uint64_t max_persistent_check_errors;
+ const char *transport;
+ const char *recovery_lock;
+ uint32_t pnn; /* our own pnn */
+ uint32_t num_nodes;
+ uint32_t num_connected;
+ unsigned flags;
+ uint32_t capabilities;
+ struct reqid_context *idr;
+ struct ctdb_node **nodes; /* array of nodes in the cluster - indexed by vnn */
+ struct ctdb_vnn *vnn; /* list of public ip addresses and interfaces */
+ struct ctdb_interface *ifaces; /* list of local interfaces */
+ char *err_msg;
+ const struct ctdb_methods *methods; /* transport methods */
+ const struct ctdb_upcalls *upcalls; /* transport upcalls */
+ void *transport_data; /* private to transport */
+ struct ctdb_db_context *db_list;
+ struct srvid_context *srv;
+ struct srvid_context *tunnels;
+ struct ctdb_daemon_data daemon;
+ struct ctdb_statistics statistics;
+ struct ctdb_statistics statistics_current;
+#define MAX_STAT_HISTORY 100
+ struct ctdb_statistics statistics_history[MAX_STAT_HISTORY];
+ struct ctdb_vnn_map *vnn_map;
+ uint32_t num_clients;
+ bool do_checkpublicip;
+ bool do_setsched;
+ const char *event_script_dir;
+ const char *notification_script;
+ pid_t ctdbd_pid;
+ pid_t recoverd_pid;
+ enum ctdb_runstate runstate;
+ struct ctdb_monitor_state *monitor;
+ int start_as_disabled;
+ int start_as_stopped;
+ bool valgrinding;
+ uint32_t *recd_ping_count;
+ TALLOC_CTX *recd_ctx; /* a context used to track recoverd monitoring events */
+ TALLOC_CTX *release_ips_ctx; /* a context used to automatically drop all IPs if we fail to recover the node */
+
+ struct eventd_context *ectx;
+
+ TALLOC_CTX *banning_ctx;
+
+ struct ctdb_vacuum_child_context *vacuumer;
+
+ /* mapping from pid to ctdb_client * */
+ struct ctdb_client_pid_list *client_pids;
+
+ /* Used to defer db attach requests while in recovery mode */
+ struct ctdb_deferred_attach_context *deferred_attach;
+
+ /* if we are a child process, do we have a domain socket to send controls on */
+ bool can_send_controls;
+
+ struct ctdb_reloadips_handle *reload_ips;
+
+ const char *nodes_file;
+ const char *public_addresses_file;
+ struct trbt_tree *child_processes;
+
+ /* Used for locking record/db/alldb */
+ struct lock_context *lock_current;
+ struct lock_context *lock_pending;
+};
+
+struct ctdb_db_hot_key {
+ uint32_t count;
+ TDB_DATA key;
+ uint32_t last_logged_count;
+};
+
+struct ctdb_db_context {
+ struct ctdb_db_context *next, *prev;
+ struct ctdb_context *ctdb;
+ uint32_t db_id;
+ uint8_t db_flags;
+ const char *db_name;
+ const char *db_path;
+ struct tdb_wrap *ltdb;
+ struct tdb_context *rottdb; /* ReadOnly tracking TDB */
+ struct ctdb_registered_call *calls; /* list of registered calls */
+ uint32_t seqnum;
+ struct tevent_timer *seqnum_update;
+ struct ctdb_traverse_local_handle *traverse;
+ struct ctdb_vacuum_handle *vacuum_handle;
+ char *unhealthy_reason;
+ int pending_requests;
+ struct revokechild_handle *revokechild_active;
+ struct ctdb_persistent_state *persistent_state;
+ struct trbt_tree *delete_queue;
+ struct trbt_tree *fetch_queue;
+ struct trbt_tree *sticky_records;
+ int (*ctdb_ltdb_store_fn)(struct ctdb_db_context *ctdb_db,
+ TDB_DATA key,
+ struct ctdb_ltdb_header *header,
+ TDB_DATA data);
+
+ /* used to track which records we are currently fetching
+ so we can avoid sending duplicate fetch requests
+ */
+ struct trbt_tree *deferred_fetch;
+ struct trbt_tree *defer_dmaster;
+
+ struct ctdb_db_statistics_old statistics;
+ struct ctdb_db_hot_key hot_keys[MAX_HOT_KEYS];
+
+ struct lock_context *lock_current;
+ struct lock_context *lock_pending;
+ unsigned int lock_num_current;
+ struct db_hash_context *lock_log;
+
+ struct ctdb_call_state *pending_calls;
+
+ enum ctdb_freeze_mode freeze_mode;
+ struct ctdb_db_freeze_handle *freeze_handle;
+ bool freeze_transaction_started;
+ uint32_t freeze_transaction_id;
+ uint32_t generation;
+
+ bool invalid_records;
+ bool push_started;
+ void *push_state;
+
+ struct hash_count_context *migratedb;
+};
+
+
+#define CTDB_NO_MEMORY(ctdb, p) do { if (!(p)) { \
+ DEBUG(0,("Out of memory for %s at %s\n", #p, __location__)); \
+ ctdb_set_error(ctdb, "Out of memory at %s:%d", __FILE__, __LINE__); \
+ return -1; }} while (0)
+
+#define CTDB_NO_MEMORY_VOID(ctdb, p) do { if (!(p)) { \
+ DEBUG(0,("Out of memory for %s at %s\n", #p, __location__)); \
+ ctdb_set_error(ctdb, "Out of memory at %s:%d", __FILE__, __LINE__); \
+ return; }} while (0)
+
+#define CTDB_NO_MEMORY_NULL(ctdb, p) do { if (!(p)) { \
+ DEBUG(0,("Out of memory for %s at %s\n", #p, __location__)); \
+ ctdb_set_error(ctdb, "Out of memory at %s:%d", __FILE__, __LINE__); \
+ return NULL; }} while (0)
+
+#define CTDB_NO_MEMORY_FATAL(ctdb, p) do { if (!(p)) { \
+ DEBUG(0,("Out of memory for %s at %s\n", #p, __location__)); \
+ ctdb_fatal(ctdb, "Out of memory in " __location__ ); \
+ }} while (0)
+
+
+enum call_state {CTDB_CALL_WAIT, CTDB_CALL_DONE, CTDB_CALL_ERROR};
+
+/*
+ state of a in-progress ctdb call
+*/
+struct ctdb_call_state {
+ struct ctdb_call_state *next, *prev;
+ enum call_state state;
+ uint32_t reqid;
+ struct ctdb_req_call_old *c;
+ struct ctdb_db_context *ctdb_db;
+ const char *errmsg;
+ struct ctdb_call *call;
+ uint32_t generation;
+ struct {
+ void (*fn)(struct ctdb_call_state *);
+ void *private_data;
+ } async;
+};
+
+/* internal prototypes */
+
+#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", \
+ opcode, (unsigned)indata.dsize, (unsigned)size)); \
+ return -1; \
+ } \
+ } while (0)
+
+#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)
+
+/*
+ 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;
+ struct ctdb_call *call;
+ struct {
+ void (*fn)(struct ctdb_client_call_state *);
+ void *private_data;
+ } async;
+};
+
+extern int script_log_level;
+extern bool fast_start;
+extern const char *ctdbd_pidfile;
+
+typedef void (*deferred_requeue_fn)(void *call_context, struct ctdb_req_header *hdr);
+
+
+/* from tcp/ and ib/ */
+
+int ctdb_tcp_init(struct ctdb_context *ctdb);
+int ctdb_ibw_init(struct ctdb_context *ctdb);
+
+/* from ctdb_banning.c */
+
+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);
+void ctdb_ban_self(struct ctdb_context *ctdb);
+
+/* from ctdb_call.c */
+
+struct ctdb_db_context *find_ctdb_db(struct ctdb_context *ctdb, uint32_t id);
+
+void ctdb_request_dmaster(struct ctdb_context *ctdb,
+ struct ctdb_req_header *hdr);
+void ctdb_reply_dmaster(struct ctdb_context *ctdb,
+ struct ctdb_req_header *hdr);
+void ctdb_request_call(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
+void ctdb_reply_call(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
+void ctdb_reply_error(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
+
+void ctdb_call_resend_db(struct ctdb_db_context *ctdb);
+void ctdb_call_resend_all(struct ctdb_context *ctdb);
+
+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);
+
+struct ctdb_call_state *ctdb_daemon_call_send_remote(
+ struct ctdb_db_context *ctdb_db,
+ struct ctdb_call *call,
+ struct ctdb_ltdb_header *header);
+int ctdb_daemon_call_recv(struct ctdb_call_state *state,
+ struct ctdb_call *call);
+
+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);
+
+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);
+
+int ctdb_migration_init(struct ctdb_db_context *ctdb_db);
+
+/* from server/ctdb_control.c */
+
+int32_t ctdb_dump_memory(struct ctdb_context *ctdb, TDB_DATA *outdata);
+
+void ctdb_request_control_reply(struct ctdb_context *ctdb,
+ struct ctdb_req_control_old *c,
+ TDB_DATA *outdata, int32_t status,
+ const char *errormsg);
+
+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,
+ uint64_t srvid, uint32_t opcode,
+ uint32_t client_id, uint32_t flags,
+ TDB_DATA data,
+ ctdb_control_callback_fn_t callback,
+ void *private_data);
+
+/* from server/ctdb_daemon.c */
+
+int daemon_register_message_handler(struct ctdb_context *ctdb,
+ uint32_t client_id, uint64_t srvid);
+int daemon_deregister_message_handler(struct ctdb_context *ctdb,
+ uint32_t client_id, uint64_t srvid);
+
+void daemon_tunnel_handler(uint64_t tunnel_id, TDB_DATA data,
+ void *private_data);
+
+struct ctdb_node *ctdb_find_node(struct ctdb_context *ctdb, uint32_t pnn);
+
+int ctdb_start_daemon(struct ctdb_context *ctdb,
+ bool interactive,
+ bool test_mode_enabled);
+
+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)
+
+void ctdb_daemon_cancel_controls(struct ctdb_context *ctdb,
+ struct ctdb_node *node);
+
+int ctdb_daemon_set_call(struct ctdb_context *ctdb, uint32_t db_id,
+ ctdb_fn_t fn, int id);
+
+int ctdb_daemon_send_message(struct ctdb_context *ctdb, uint32_t pnn,
+ uint64_t srvid, TDB_DATA data);
+
+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);
+
+struct ctdb_client *ctdb_find_client_by_pid(struct ctdb_context *ctdb,
+ pid_t pid);
+
+int32_t ctdb_control_process_exists(struct ctdb_context *ctdb, pid_t pid);
+int32_t ctdb_control_check_pid_srvid(struct ctdb_context *ctdb,
+ TDB_DATA indata);
+
+int ctdb_control_getnodesfile(struct ctdb_context *ctdb, uint32_t opcode,
+ TDB_DATA indata, TDB_DATA *outdata);
+
+void ctdb_shutdown_sequence(struct ctdb_context *ctdb, int exit_code);
+
+int switch_from_server_to_client(struct ctdb_context *ctdb);
+
+/* From server/ctdb_fork.c */
+
+void ctdb_track_child(struct ctdb_context *ctdb, pid_t pid);
+
+pid_t ctdb_fork(struct ctdb_context *ctdb);
+pid_t ctdb_vfork_exec(TALLOC_CTX *mem_ctx, struct ctdb_context *ctdb,
+ const char *helper, int helper_argc,
+ const char **helper_argv);
+
+struct tevent_signal *ctdb_init_sigchld(struct ctdb_context *ctdb);
+
+int ctdb_kill(struct ctdb_context *ctdb, pid_t pid, int signum);
+
+/* from server/ctdb_freeze.c */
+
+int32_t ctdb_control_db_freeze(struct ctdb_context *ctdb,
+ struct ctdb_req_control_old *c,
+ uint32_t db_id, bool *async_reply);
+int32_t ctdb_control_db_thaw(struct ctdb_context *ctdb, uint32_t db_id);
+
+int32_t ctdb_control_freeze(struct ctdb_context *ctdb,
+ struct ctdb_req_control_old *c, bool *async_reply);
+int32_t ctdb_control_thaw(struct ctdb_context *ctdb, bool check_recmode);
+
+bool ctdb_blocking_freeze(struct ctdb_context *ctdb);
+
+int32_t ctdb_control_db_transaction_start(struct ctdb_context *ctdb,
+ TDB_DATA indata);
+int32_t ctdb_control_db_transaction_cancel(struct ctdb_context *ctdb,
+ TDB_DATA indata);
+int32_t ctdb_control_db_transaction_commit(struct ctdb_context *ctdb,
+ TDB_DATA indata);
+
+int32_t ctdb_control_wipe_database(struct ctdb_context *ctdb, TDB_DATA indata);
+
+bool ctdb_db_frozen(struct ctdb_db_context *ctdb_db);
+bool ctdb_db_all_frozen(struct ctdb_context *ctdb);
+bool ctdb_db_allow_access(struct ctdb_db_context *ctdb_db);
+
+/* from server/ctdb_keepalive.c */
+
+void ctdb_start_keepalive(struct ctdb_context *ctdb);
+void ctdb_stop_keepalive(struct ctdb_context *ctdb);
+
+void ctdb_request_keepalive(struct ctdb_context *ctdb,
+ struct ctdb_req_header *hdr);
+
+/* from server/ctdb_lock.c */
+
+struct lock_request;
+
+typedef int (*ctdb_db_handler_t)(struct ctdb_db_context *ctdb_db,
+ void *private_data);
+
+int ctdb_db_iterator(struct ctdb_context *ctdb, ctdb_db_handler_t handler,
+ void *private_data);
+
+int ctdb_lockdb_mark(struct ctdb_db_context *ctdb_db);
+
+int ctdb_lockdb_unmark(struct ctdb_db_context *ctdb_db);
+
+struct lock_request *ctdb_lock_record(TALLOC_CTX *mem_ctx,
+ struct ctdb_db_context *ctdb_db,
+ TDB_DATA key,
+ bool auto_mark,
+ void (*callback)(void *, bool),
+ void *private_data);
+
+struct lock_request *ctdb_lock_db(TALLOC_CTX *mem_ctx,
+ struct ctdb_db_context *ctdb_db,
+ bool auto_mark,
+ void (*callback)(void *, bool),
+ void *private_data);
+
+/* from ctdb_logging.c */
+
+bool ctdb_logging_init(TALLOC_CTX *mem_ctx, const char *logging,
+ const char *debug_level);
+
+int ctdb_set_child_logging(struct ctdb_context *ctdb);
+
+/* from ctdb_logging_file.c */
+
+void ctdb_log_init_file(void);
+
+/* from ctdb_logging_syslog.c */
+
+void ctdb_log_init_syslog(void);
+
+/* from ctdb_ltdb_server.c */
+
+int ctdb_ltdb_lock_requeue(struct ctdb_db_context *ctdb_db,
+ TDB_DATA key, struct ctdb_req_header *hdr,
+ void (*recv_pkt)(void *, struct ctdb_req_header *),
+ void *recv_context, bool ignore_generation);
+
+int ctdb_ltdb_lock_fetch_requeue(struct ctdb_db_context *ctdb_db,
+ TDB_DATA key, struct ctdb_ltdb_header *header,
+ struct ctdb_req_header *hdr, TDB_DATA *data,
+ void (*recv_pkt)(void *, struct ctdb_req_header *),
+ void *recv_context, bool ignore_generation);
+
+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 */
+ unsigned int num_healthy_nodes);
+int ctdb_recheck_persistent_health(struct ctdb_context *ctdb);
+
+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);
+
+int ctdb_set_db_readonly(struct ctdb_context *ctdb,
+ struct ctdb_db_context *ctdb_db);
+
+int ctdb_process_deferred_attach(struct ctdb_context *ctdb);
+
+int32_t ctdb_control_db_attach(struct ctdb_context *ctdb,
+ TDB_DATA indata,
+ TDB_DATA *outdata,
+ uint8_t db_flags,
+ uint32_t srcnode,
+ uint32_t client_id,
+ struct ctdb_req_control_old *c,
+ bool *async_reply);
+int32_t ctdb_control_db_detach(struct ctdb_context *ctdb, TDB_DATA indata,
+ uint32_t client_id);
+
+int ctdb_attach_databases(struct ctdb_context *ctdb);
+
+int32_t ctdb_ltdb_update_seqnum(struct ctdb_context *ctdb, uint32_t db_id,
+ uint32_t srcnode);
+int32_t ctdb_ltdb_enable_seqnum(struct ctdb_context *ctdb, uint32_t db_id);
+
+int ctdb_set_db_sticky(struct ctdb_context *ctdb,
+ struct ctdb_db_context *ctdb_db);
+
+void ctdb_db_statistics_reset(struct ctdb_db_context *ctdb_db);
+
+int32_t ctdb_control_get_db_statistics(struct ctdb_context *ctdb,
+ uint32_t db_id, TDB_DATA *outdata);
+
+/* from ctdb_monitor.c */
+
+void ctdb_run_notification_script(struct ctdb_context *ctdb, const char *event);
+
+void ctdb_stop_monitoring(struct ctdb_context *ctdb);
+
+void ctdb_wait_for_first_recovery(struct ctdb_context *ctdb);
+
+int32_t ctdb_control_modflags(struct ctdb_context *ctdb, TDB_DATA indata);
+
+/* from ctdb_persistent.c */
+
+void ctdb_persistent_finish_trans3_commits(struct ctdb_context *ctdb);
+
+int32_t ctdb_control_trans3_commit(struct ctdb_context *ctdb,
+ struct ctdb_req_control_old *c,
+ TDB_DATA recdata, bool *async_reply);
+
+int32_t ctdb_control_start_persistent_update(struct ctdb_context *ctdb,
+ struct ctdb_req_control_old *c,
+ TDB_DATA recdata);
+int32_t ctdb_control_cancel_persistent_update(struct ctdb_context *ctdb,
+ struct ctdb_req_control_old *c,
+ TDB_DATA recdata);
+
+int32_t ctdb_control_get_db_seqnum(struct ctdb_context *ctdb,
+ TDB_DATA indata, TDB_DATA *outdata);
+
+/* from ctdb_recover.c */
+
+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);
+
+int ctdb_control_getdbmap(struct ctdb_context *ctdb, uint32_t opcode,
+ TDB_DATA indata, TDB_DATA *outdata);
+int ctdb_control_getnodemap(struct ctdb_context *ctdb, uint32_t opcode,
+ TDB_DATA indata, TDB_DATA *outdata);
+
+int ctdb_control_reload_nodes_file(struct ctdb_context *ctdb, uint32_t opcode);
+
+int32_t ctdb_control_db_pull(struct ctdb_context *ctdb,
+ struct ctdb_req_control_old *c,
+ TDB_DATA indata, TDB_DATA *outdata);
+int32_t ctdb_control_db_push_start(struct ctdb_context *ctdb,
+ TDB_DATA indata);
+int32_t ctdb_control_db_push_confirm(struct ctdb_context *ctdb,
+ TDB_DATA indata, TDB_DATA *outdata);
+
+int ctdb_deferred_drop_all_ips(struct ctdb_context *ctdb);
+
+int32_t ctdb_control_set_recmode(struct ctdb_context *ctdb,
+ struct ctdb_req_control_old *c,
+ TDB_DATA indata, bool *async_reply,
+ const char **errormsg);
+
+int32_t ctdb_control_end_recovery(struct ctdb_context *ctdb,
+ struct ctdb_req_control_old *c,
+ bool *async_reply);
+int32_t ctdb_control_start_recovery(struct ctdb_context *ctdb,
+ struct ctdb_req_control_old *c,
+ bool *async_reply);
+
+int32_t ctdb_control_try_delete_records(struct ctdb_context *ctdb,
+ TDB_DATA indata, TDB_DATA *outdata);
+
+int32_t ctdb_control_get_capabilities(struct ctdb_context *ctdb,
+ TDB_DATA *outdata);
+
+int32_t ctdb_control_recd_ping(struct ctdb_context *ctdb);
+
+void ctdb_node_become_inactive(struct ctdb_context *ctdb);
+
+int32_t ctdb_control_stop_node(struct ctdb_context *ctdb);
+int32_t ctdb_control_continue_node(struct ctdb_context *ctdb);
+
+/* from ctdb_recoverd.c */
+
+int ctdb_start_recoverd(struct ctdb_context *ctdb);
+void ctdb_stop_recoverd(struct ctdb_context *ctdb);
+
+/* from ctdb_server.c */
+
+int ctdb_set_transport(struct ctdb_context *ctdb, const char *transport);
+
+struct ctdb_node *ctdb_ip_to_node(struct ctdb_context *ctdb,
+ const ctdb_sock_addr *nodeip);
+uint32_t ctdb_ip_to_pnn(struct ctdb_context *ctdb,
+ const ctdb_sock_addr *nodeip);
+
+void ctdb_load_nodes_file(struct ctdb_context *ctdb);
+
+int ctdb_set_address(struct ctdb_context *ctdb, const char *address);
+
+uint32_t ctdb_get_num_active_nodes(struct ctdb_context *ctdb);
+
+void ctdb_input_pkt(struct ctdb_context *ctdb, struct ctdb_req_header *);
+
+void ctdb_node_dead(struct ctdb_node *node);
+void ctdb_node_connected(struct ctdb_node *node);
+
+void ctdb_queue_packet(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
+void ctdb_queue_packet_opcode(struct ctdb_context *ctdb,
+ struct ctdb_req_header *hdr, unsigned opcode);
+
+/* from ctdb_serverids.c */
+
+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);
+int32_t ctdb_control_get_server_id_list(struct ctdb_context *ctdb,
+ TDB_DATA *outdata);
+
+/* from ctdb_statistics.c */
+
+int ctdb_statistics_init(struct ctdb_context *ctdb);
+
+int32_t ctdb_control_get_stat_history(struct ctdb_context *ctdb,
+ struct ctdb_req_control_old *c,
+ TDB_DATA *outdata);
+
+/* from ctdb_takeover.c */
+
+int32_t ctdb_control_takeover_ip(struct ctdb_context *ctdb,
+ struct ctdb_req_control_old *c,
+ TDB_DATA indata,
+ bool *async_reply);
+int32_t ctdb_control_release_ip(struct ctdb_context *ctdb,
+ struct ctdb_req_control_old *c,
+ TDB_DATA indata,
+ bool *async_reply);
+int32_t ctdb_control_ipreallocated(struct ctdb_context *ctdb,
+ struct ctdb_req_control_old *c,
+ bool *async_reply);
+
+int ctdb_set_public_addresses(struct ctdb_context *ctdb, bool check_addresses);
+
+int32_t ctdb_control_tcp_client(struct ctdb_context *ctdb, uint32_t client_id,
+ TDB_DATA indata);
+int32_t ctdb_control_tcp_client_disconnected(struct ctdb_context *ctdb,
+ uint32_t client_id,
+ TDB_DATA indata);
+int32_t ctdb_control_tcp_client_passed(struct ctdb_context *ctdb,
+ uint32_t client_id,
+ TDB_DATA indata);
+int32_t ctdb_control_tcp_add(struct ctdb_context *ctdb, TDB_DATA indata,
+ bool tcp_update_needed);
+int32_t ctdb_control_tcp_remove(struct ctdb_context *ctdb, TDB_DATA indata);
+int32_t ctdb_control_startup(struct ctdb_context *ctdb, uint32_t vnn);
+
+void ctdb_takeover_client_destructor_hook(struct ctdb_client *client);
+
+void ctdb_release_all_ips(struct ctdb_context *ctdb);
+
+int32_t ctdb_control_get_public_ips(struct ctdb_context *ctdb,
+ struct ctdb_req_control_old *c,
+ TDB_DATA *outdata);
+int32_t ctdb_control_get_public_ip_info(struct ctdb_context *ctdb,
+ struct ctdb_req_control_old *c,
+ TDB_DATA indata, TDB_DATA *outdata);
+
+int32_t ctdb_control_get_ifaces(struct ctdb_context *ctdb,
+ struct ctdb_req_control_old *c,
+ TDB_DATA *outdata);
+int32_t ctdb_control_set_iface_link(struct ctdb_context *ctdb,
+ struct ctdb_req_control_old *c,
+ TDB_DATA indata);
+
+int32_t ctdb_control_set_tcp_tickle_list(struct ctdb_context *ctdb,
+ TDB_DATA indata);
+int32_t ctdb_control_get_tcp_tickle_list(struct ctdb_context *ctdb,
+ TDB_DATA indata, TDB_DATA *outdata);
+
+void ctdb_start_tcp_tickle_update(struct ctdb_context *ctdb);
+
+int32_t ctdb_control_send_gratious_arp(struct ctdb_context *ctdb,
+ TDB_DATA indata);
+
+int32_t ctdb_control_add_public_address(struct ctdb_context *ctdb,
+ TDB_DATA indata);
+int32_t ctdb_control_del_public_address(struct ctdb_context *ctdb,
+ TDB_DATA recdata);
+
+int32_t ctdb_control_reload_public_ips(struct ctdb_context *ctdb,
+ struct ctdb_req_control_old *c,
+ bool *async_reply);
+
+/* from ctdb_traverse.c */
+
+int32_t ctdb_control_traverse_all_ext(struct ctdb_context *ctdb,
+ TDB_DATA data, TDB_DATA *outdata);
+int32_t ctdb_control_traverse_all(struct ctdb_context *ctdb,
+ TDB_DATA data, TDB_DATA *outdata);
+int32_t ctdb_control_traverse_data(struct ctdb_context *ctdb,
+ TDB_DATA data, TDB_DATA *outdata);
+int32_t ctdb_control_traverse_kill(struct ctdb_context *ctdb, TDB_DATA indata,
+ TDB_DATA *outdata, uint32_t srcnode);
+
+int32_t ctdb_control_traverse_start_ext(struct ctdb_context *ctdb,
+ TDB_DATA indata, TDB_DATA *outdata,
+ uint32_t srcnode, uint32_t client_id);
+int32_t ctdb_control_traverse_start(struct ctdb_context *ctdb,
+ TDB_DATA indata, TDB_DATA *outdata,
+ uint32_t srcnode, uint32_t client_id);
+
+/* from ctdb_tunables.c */
+
+void ctdb_tunables_set_defaults(struct ctdb_context *ctdb);
+
+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);
+bool ctdb_tunables_load(struct ctdb_context *ctdb);
+
+/* from ctdb_tunnel.c */
+
+int32_t ctdb_control_tunnel_register(struct ctdb_context *ctdb,
+ uint32_t client_id, uint64_t tunnel_id);
+int32_t ctdb_control_tunnel_deregister(struct ctdb_context *ctdb,
+ uint32_t client_id, uint64_t tunnel_id);
+
+int ctdb_daemon_send_tunnel(struct ctdb_context *ctdb, uint32_t destnode,
+ uint64_t tunnel_id, uint32_t client_id,
+ TDB_DATA data);
+
+void ctdb_request_tunnel(struct ctdb_context *ctdb,
+ struct ctdb_req_header *hdr);
+
+/* from ctdb_update_record.c */
+
+int32_t ctdb_control_update_record(struct ctdb_context *ctdb,
+ struct ctdb_req_control_old *c,
+ TDB_DATA recdata, bool *async_reply);
+
+/* from ctdb_uptime.c */
+
+int32_t ctdb_control_uptime(struct ctdb_context *ctdb, TDB_DATA *outdata);
+
+/* from ctdb_vacuum.c */
+
+int32_t ctdb_control_db_vacuum(struct ctdb_context *ctdb,
+ struct ctdb_req_control_old *c,
+ TDB_DATA indata,
+ bool *async_reply);
+
+void ctdb_stop_vacuuming(struct ctdb_context *ctdb);
+int ctdb_vacuum_init(struct ctdb_db_context *ctdb_db);
+
+int32_t ctdb_control_schedule_for_deletion(struct ctdb_context *ctdb,
+ TDB_DATA indata);
+int32_t ctdb_local_schedule_for_deletion(struct ctdb_db_context *ctdb_db,
+ const struct ctdb_ltdb_header *hdr,
+ TDB_DATA key);
+
+void ctdb_local_remove_from_delete_queue(struct ctdb_db_context *ctdb_db,
+ const struct ctdb_ltdb_header *hdr,
+ const TDB_DATA key);
+
+int32_t ctdb_control_vacuum_fetch(struct ctdb_context *ctdb, TDB_DATA indata);
+
+/* from eventscript.c */
+
+int ctdb_start_eventd(struct ctdb_context *ctdb);
+void ctdb_stop_eventd(struct ctdb_context *ctdb);
+
+int ctdb_event_script_callback(struct ctdb_context *ctdb,
+ TALLOC_CTX *mem_ctx,
+ void (*callback)(struct ctdb_context *,
+ int, void *),
+ void *private_data,
+ enum ctdb_event call,
+ const char *fmt, ...) PRINTF_ATTRIBUTE(6,7);
+
+int ctdb_event_script_args(struct ctdb_context *ctdb,
+ enum ctdb_event call,
+ const char *fmt, ...) PRINTF_ATTRIBUTE(3,4);
+
+int ctdb_event_script(struct ctdb_context *ctdb,
+ enum ctdb_event call);
+
+void ctdb_event_reopen_logs(struct ctdb_context *ctdb);
+
+#endif
diff --git a/ctdb/include/ctdb_protocol.h b/ctdb/include/ctdb_protocol.h
new file mode 100644
index 0000000..31af420
--- /dev/null
+++ b/ctdb/include/ctdb_protocol.h
@@ -0,0 +1,301 @@
+/*
+ ctdb database library
+
+ Copyright (C) Andrew Tridgell 2006
+
+ 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
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ 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
+ along with this program; if not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _CTDB_PROTOCOL_H
+#define _CTDB_PROTOCOL_H
+
+#include <sys/socket.h>
+#include "protocol/protocol.h"
+
+/* define ctdb port number */
+#define CTDB_PORT 4379
+
+/* we must align packets to ensure ctdb works on all architectures (eg. sparc) */
+#define CTDB_DS_ALIGNMENT 8
+
+/*
+ structure passed to a ctdb call backend function
+*/
+struct ctdb_call_info {
+ TDB_DATA key; /* record key */
+ struct ctdb_ltdb_header *header;
+ TDB_DATA record_data; /* current data in the record */
+ TDB_DATA *new_data; /* optionally updated record data */
+ TDB_DATA *call_data; /* optionally passed from caller */
+ TDB_DATA *reply_data; /* optionally returned by function */
+ uint32_t status; /* optional reply status - defaults to zero */
+};
+
+/*
+ ctdb flags
+*/
+#define CTDB_FLAG_TORTURE (1<<1)
+
+struct ctdb_script_list_old {
+ uint32_t num_scripts;
+ struct ctdb_script scripts[1];
+};
+
+/* Mapping from enum to names. */
+extern const char *ctdb_eventscript_call_names[];
+
+/*
+ packet structures
+*/
+struct ctdb_req_call_old {
+ struct ctdb_req_header hdr;
+ uint32_t flags;
+ uint32_t db_id;
+ uint32_t callid;
+ uint32_t hopcount;
+ uint32_t keylen;
+ uint32_t calldatalen;
+ uint8_t data[1]; /* key[] followed by calldata[] */
+};
+
+struct ctdb_reply_call_old {
+ struct ctdb_req_header hdr;
+ uint32_t status;
+ uint32_t datalen;
+ uint8_t data[1];
+};
+
+struct ctdb_reply_error_old {
+ struct ctdb_req_header hdr;
+ uint32_t status;
+ uint32_t msglen;
+ uint8_t msg[1];
+};
+
+struct ctdb_req_dmaster_old {
+ struct ctdb_req_header hdr;
+ uint32_t db_id;
+ uint64_t rsn;
+ uint32_t dmaster;
+ uint32_t keylen;
+ uint32_t datalen;
+ uint8_t data[1];
+};
+
+struct ctdb_reply_dmaster_old {
+ struct ctdb_req_header hdr;
+ uint32_t db_id;
+ uint64_t rsn;
+ uint32_t keylen;
+ uint32_t datalen;
+ uint8_t data[1];
+};
+
+struct ctdb_req_message_old {
+ struct ctdb_req_header hdr;
+ uint64_t srvid;
+ uint32_t datalen;
+ uint8_t data[1];
+};
+
+struct ctdb_req_control_old {
+ struct ctdb_req_header hdr;
+ uint32_t opcode;
+ uint32_t pad;
+ uint64_t srvid;
+ uint32_t client_id;
+ uint32_t flags;
+ uint32_t datalen;
+ uint8_t data[1];
+};
+
+struct ctdb_reply_control_old {
+ struct ctdb_req_header hdr;
+ int32_t status;
+ uint32_t datalen;
+ uint32_t errorlen;
+ uint8_t data[1];
+};
+
+struct ctdb_req_keepalive_old {
+ struct ctdb_req_header hdr;
+ uint32_t version;
+ uint32_t uptime;
+};
+
+struct ctdb_req_tunnel_old {
+ struct ctdb_req_header hdr;
+ uint64_t tunnel_id;
+ uint32_t flags;
+ uint32_t datalen;
+ uint8_t data[1];
+};
+
+/*
+ Structure used for a nodemap.
+ The nodemap is the structure containing a list of all nodes
+ known to the cluster and their associated flags.
+*/
+struct ctdb_node_map_old {
+ uint32_t num;
+ struct ctdb_node_and_flags nodes[1];
+};
+
+struct ctdb_public_ip_list_old {
+ uint32_t num;
+ struct ctdb_public_ip ips[1];
+};
+
+/*
+ structure used to pass record data between the child and parent
+ */
+struct ctdb_rec_data_old {
+ uint32_t length;
+ uint32_t reqid;
+ uint32_t keylen;
+ uint32_t datalen;
+ uint8_t data[1];
+};
+
+/*
+ * wire format for statistics history
+ */
+struct ctdb_statistics_list_old {
+ uint32_t num;
+ struct ctdb_statistics stats[1];
+};
+
+/*
+ * db statistics
+ */
+struct ctdb_db_statistics_old {
+ struct {
+ uint32_t num_calls;
+ uint32_t num_current;
+ uint32_t num_pending;
+ uint32_t num_failed;
+ struct ctdb_latency_counter latency;
+ uint32_t buckets[MAX_COUNT_BUCKETS];
+ } locks;
+ struct {
+ struct ctdb_latency_counter latency;
+ } vacuum;
+ uint32_t db_ro_delegations;
+ uint32_t db_ro_revokes;
+ uint32_t hop_count_bucket[MAX_COUNT_BUCKETS];
+ uint32_t num_hot_keys;
+ struct {
+ uint32_t count;
+ TDB_DATA key;
+ } hot_keys[MAX_HOT_KEYS];
+ char hot_keys_wire[1];
+};
+
+/*
+ a wire representation of the vnn map
+ */
+struct ctdb_vnn_map_wire {
+ uint32_t generation;
+ uint32_t size;
+ uint32_t map[1];
+};
+
+struct ctdb_notify_data_old {
+ uint64_t srvid;
+ uint32_t len;
+ uint8_t notify_data[1];
+};
+
+/* table that contains a list of all dbids on a node
+ */
+struct ctdb_dbid_map_old {
+ uint32_t num;
+ struct ctdb_dbid dbs[1];
+};
+
+/* the list of tcp tickles used by get/set tcp tickle list */
+struct ctdb_tickle_list_old {
+ ctdb_sock_addr addr;
+ uint32_t num;
+ struct ctdb_connection connections[1];
+};
+
+/*
+ struct holding a ctdb_sock_addr and an interface name,
+ used to add/remove public addresses and gratuitous arp
+ */
+struct ctdb_addr_info_old {
+ ctdb_sock_addr addr;
+ uint32_t mask;
+ uint32_t len;
+ char iface[1];
+};
+
+/* structure used for sending lists of records */
+struct ctdb_marshall_buffer {
+ uint32_t db_id;
+ uint32_t count;
+ uint8_t data[1];
+};
+
+/*
+ structure for setting a tunable
+ */
+struct ctdb_tunable_old {
+ 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];
+};
+
+
+struct ctdb_public_ip_info_old {
+ struct ctdb_public_ip ip;
+ uint32_t active_idx;
+ uint32_t num;
+ struct ctdb_iface ifaces[1];
+};
+
+struct ctdb_iface_list_old {
+ uint32_t num;
+ struct ctdb_iface ifaces[1];
+};
+
+/**
+ * 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[] */
+};
+
+#endif
diff --git a/ctdb/include/public/README.txt b/ctdb/include/public/README.txt
new file mode 100644
index 0000000..534e9b7
--- /dev/null
+++ b/ctdb/include/public/README.txt
@@ -0,0 +1,6 @@
+DO NOT REMOVE
+
+This is a placeholder to allow for build rules putting public headers
+in this directory. Using this directory allows us to ensure that our
+public headers will work with external applications that make use of
+Samba libraries
diff --git a/ctdb/include/public/util/README.txt b/ctdb/include/public/util/README.txt
new file mode 100644
index 0000000..534e9b7
--- /dev/null
+++ b/ctdb/include/public/util/README.txt
@@ -0,0 +1,6 @@
+DO NOT REMOVE
+
+This is a placeholder to allow for build rules putting public headers
+in this directory. Using this directory allows us to ensure that our
+public headers will work with external applications that make use of
+Samba libraries