1 | /*
|
---|
2 | ctdb database library
|
---|
3 |
|
---|
4 | Copyright (C) Andrew Tridgell 2006
|
---|
5 |
|
---|
6 | This program is free software; you can redistribute it and/or modify
|
---|
7 | it under the terms of the GNU General Public License as published by
|
---|
8 | the Free Software Foundation; either version 3 of the License, or
|
---|
9 | (at your option) any later version.
|
---|
10 |
|
---|
11 | This program is distributed in the hope that it will be useful,
|
---|
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
14 | GNU General Public License for more details.
|
---|
15 |
|
---|
16 | You should have received a copy of the GNU General Public License
|
---|
17 | along with this program; if not, see <http://www.gnu.org/licenses/>.
|
---|
18 | */
|
---|
19 |
|
---|
20 | #ifndef _CTDB_PRIVATE_H
|
---|
21 | #define _CTDB_PRIVATE_H
|
---|
22 |
|
---|
23 | #include "ctdb_client.h"
|
---|
24 | #include <sys/socket.h>
|
---|
25 |
|
---|
26 | /*
|
---|
27 | array of tcp connections
|
---|
28 | */
|
---|
29 | struct ctdb_tcp_array {
|
---|
30 | uint32_t num;
|
---|
31 | struct ctdb_connection *connections;
|
---|
32 | };
|
---|
33 |
|
---|
34 | /*
|
---|
35 | an installed ctdb remote call
|
---|
36 | */
|
---|
37 | struct ctdb_registered_call {
|
---|
38 | struct ctdb_registered_call *next, *prev;
|
---|
39 | uint32_t id;
|
---|
40 | ctdb_fn_t fn;
|
---|
41 | };
|
---|
42 |
|
---|
43 | /*
|
---|
44 | check that a pnn is valid
|
---|
45 | */
|
---|
46 | #define ctdb_validate_pnn(ctdb, pnn) (((uint32_t)(pnn)) < (ctdb)->num_nodes)
|
---|
47 |
|
---|
48 |
|
---|
49 | /* called from the queue code when a packet comes in. Called with data==NULL
|
---|
50 | on error */
|
---|
51 | typedef void (*ctdb_queue_cb_fn_t)(uint8_t *data, size_t length,
|
---|
52 | void *private_data);
|
---|
53 |
|
---|
54 | /* used for callbacks in ctdb_control requests */
|
---|
55 | typedef void (*ctdb_control_callback_fn_t)(struct ctdb_context *,
|
---|
56 | int32_t status, TDB_DATA data,
|
---|
57 | const char *errormsg,
|
---|
58 | void *private_data);
|
---|
59 | /*
|
---|
60 | structure describing a connected client in the daemon
|
---|
61 | */
|
---|
62 | struct ctdb_client {
|
---|
63 | struct ctdb_context *ctdb;
|
---|
64 | int fd;
|
---|
65 | struct ctdb_queue *queue;
|
---|
66 | uint32_t client_id;
|
---|
67 | pid_t pid;
|
---|
68 | struct ctdb_tcp_list *tcp_list;
|
---|
69 | uint32_t db_id;
|
---|
70 | uint32_t num_persistent_updates;
|
---|
71 | struct ctdb_client_notify_list *notify;
|
---|
72 | };
|
---|
73 |
|
---|
74 | /* state associated with a public ip address */
|
---|
75 | struct ctdb_vnn {
|
---|
76 | struct ctdb_vnn *prev, *next;
|
---|
77 |
|
---|
78 | struct ctdb_interface *iface;
|
---|
79 | const char **ifaces;
|
---|
80 | ctdb_sock_addr public_address;
|
---|
81 | uint8_t public_netmask_bits;
|
---|
82 |
|
---|
83 | /* the node number that is serving this public address, if any.
|
---|
84 | If no node serves this ip it is set to -1 */
|
---|
85 | int32_t pnn;
|
---|
86 |
|
---|
87 | /* List of clients to tickle for this public address */
|
---|
88 | struct ctdb_tcp_array *tcp_array;
|
---|
89 |
|
---|
90 | /* whether we need to update the other nodes with changes to our list
|
---|
91 | of connected clients */
|
---|
92 | bool tcp_update_needed;
|
---|
93 |
|
---|
94 | /* a context to hang sending gratious arp events off */
|
---|
95 | TALLOC_CTX *takeover_ctx;
|
---|
96 |
|
---|
97 | struct ctdb_kill_tcp *killtcp;
|
---|
98 |
|
---|
99 | /* Set to true any time an update to this VNN is in flight.
|
---|
100 | This helps to avoid races. */
|
---|
101 | bool update_in_flight;
|
---|
102 |
|
---|
103 | /* If CTDB_CONTROL_DEL_PUBLIC_IP is received for this IP
|
---|
104 | * address then this flag is set. It will be deleted in the
|
---|
105 | * release IP callback. */
|
---|
106 | bool delete_pending;
|
---|
107 | };
|
---|
108 |
|
---|
109 | /*
|
---|
110 | state associated with one node
|
---|
111 | */
|
---|
112 | struct ctdb_node {
|
---|
113 | struct ctdb_context *ctdb;
|
---|
114 | ctdb_sock_addr address;
|
---|
115 | const char *name; /* for debug messages */
|
---|
116 | void *private_data; /* private to transport */
|
---|
117 | uint32_t pnn;
|
---|
118 | uint32_t flags;
|
---|
119 |
|
---|
120 | /* used by the dead node monitoring */
|
---|
121 | uint32_t dead_count;
|
---|
122 | uint32_t rx_cnt;
|
---|
123 | uint32_t tx_cnt;
|
---|
124 |
|
---|
125 | /* a list of controls pending to this node, so we can time them out quickly
|
---|
126 | if the node becomes disconnected */
|
---|
127 | struct daemon_control_state *pending_controls;
|
---|
128 |
|
---|
129 | /* used by the recovery dameon to track when a node should be banned */
|
---|
130 | struct ctdb_banning_state *ban_state;
|
---|
131 | };
|
---|
132 |
|
---|
133 | /*
|
---|
134 | transport specific methods
|
---|
135 | */
|
---|
136 | struct ctdb_methods {
|
---|
137 | int (*initialise)(struct ctdb_context *); /* initialise transport structures */
|
---|
138 | int (*start)(struct ctdb_context *); /* start the transport */
|
---|
139 | int (*add_node)(struct ctdb_node *); /* setup a new node */
|
---|
140 | int (*connect_node)(struct ctdb_node *); /* connect to node */
|
---|
141 | int (*queue_pkt)(struct ctdb_node *, uint8_t *data, uint32_t length);
|
---|
142 | void *(*allocate_pkt)(TALLOC_CTX *mem_ctx, size_t );
|
---|
143 | void (*shutdown)(struct ctdb_context *); /* shutdown transport */
|
---|
144 | void (*restart)(struct ctdb_node *); /* stop and restart the connection */
|
---|
145 | };
|
---|
146 |
|
---|
147 | /*
|
---|
148 | transport calls up to the ctdb layer
|
---|
149 | */
|
---|
150 | struct ctdb_upcalls {
|
---|
151 | /* recv_pkt is called when a packet comes in */
|
---|
152 | void (*recv_pkt)(struct ctdb_context *, uint8_t *data, uint32_t length);
|
---|
153 |
|
---|
154 | /* node_dead is called when an attempt to send to a node fails */
|
---|
155 | void (*node_dead)(struct ctdb_node *);
|
---|
156 |
|
---|
157 | /* node_connected is called when a connection to a node is established */
|
---|
158 | void (*node_connected)(struct ctdb_node *);
|
---|
159 | };
|
---|
160 |
|
---|
161 | /* additional data required for the daemon mode */
|
---|
162 | struct ctdb_daemon_data {
|
---|
163 | int sd;
|
---|
164 | char *name;
|
---|
165 | struct ctdb_queue *queue;
|
---|
166 | };
|
---|
167 |
|
---|
168 |
|
---|
169 | #define CTDB_UPDATE_STAT(ctdb, counter, value) \
|
---|
170 | { \
|
---|
171 | if (value > ctdb->statistics.counter) { \
|
---|
172 | ctdb->statistics.counter = c->hopcount; \
|
---|
173 | } \
|
---|
174 | if (value > ctdb->statistics_current.counter) { \
|
---|
175 | ctdb->statistics_current.counter = c->hopcount; \
|
---|
176 | } \
|
---|
177 | }
|
---|
178 |
|
---|
179 | #define CTDB_INCREMENT_STAT(ctdb, counter) \
|
---|
180 | { \
|
---|
181 | ctdb->statistics.counter++; \
|
---|
182 | ctdb->statistics_current.counter++; \
|
---|
183 | }
|
---|
184 |
|
---|
185 | #define CTDB_DECREMENT_STAT(ctdb, counter) \
|
---|
186 | { \
|
---|
187 | if (ctdb->statistics.counter > 0) \
|
---|
188 | ctdb->statistics.counter--; \
|
---|
189 | if (ctdb->statistics_current.counter > 0) \
|
---|
190 | ctdb->statistics_current.counter--; \
|
---|
191 | }
|
---|
192 |
|
---|
193 | #define CTDB_INCREMENT_DB_STAT(ctdb_db, counter) \
|
---|
194 | { \
|
---|
195 | ctdb_db->statistics.counter++; \
|
---|
196 | }
|
---|
197 |
|
---|
198 | #define CTDB_DECREMENT_DB_STAT(ctdb_db, counter) \
|
---|
199 | { \
|
---|
200 | if (ctdb_db->statistics.counter > 0) \
|
---|
201 | ctdb_db->statistics.counter--; \
|
---|
202 | }
|
---|
203 |
|
---|
204 | #define CTDB_UPDATE_RECLOCK_LATENCY(ctdb, name, counter, value) \
|
---|
205 | { \
|
---|
206 | if (value > ctdb->statistics.counter.max) \
|
---|
207 | ctdb->statistics.counter.max = value; \
|
---|
208 | if (value > ctdb->statistics_current.counter.max) \
|
---|
209 | ctdb->statistics_current.counter.max = value; \
|
---|
210 | \
|
---|
211 | if (ctdb->statistics.counter.num == 0 || \
|
---|
212 | value < ctdb->statistics.counter.min) \
|
---|
213 | ctdb->statistics.counter.min = value; \
|
---|
214 | if (ctdb->statistics_current.counter.num == 0 || \
|
---|
215 | value < ctdb->statistics_current.counter.min) \
|
---|
216 | ctdb->statistics_current.counter.min = value; \
|
---|
217 | \
|
---|
218 | ctdb->statistics.counter.total += value; \
|
---|
219 | ctdb->statistics_current.counter.total += value; \
|
---|
220 | \
|
---|
221 | ctdb->statistics.counter.num++; \
|
---|
222 | ctdb->statistics_current.counter.num++; \
|
---|
223 | \
|
---|
224 | if (ctdb->tunable.reclock_latency_ms != 0) { \
|
---|
225 | if (value*1000 > ctdb->tunable.reclock_latency_ms) { \
|
---|
226 | DEBUG(DEBUG_ERR, \
|
---|
227 | ("High RECLOCK latency %fs for operation %s\n", \
|
---|
228 | value, name)); \
|
---|
229 | } \
|
---|
230 | } \
|
---|
231 | }
|
---|
232 |
|
---|
233 | #define CTDB_UPDATE_DB_LATENCY(ctdb_db, operation, counter, value) \
|
---|
234 | { \
|
---|
235 | if (value > ctdb_db->statistics.counter.max) \
|
---|
236 | ctdb_db->statistics.counter.max = value; \
|
---|
237 | if (ctdb_db->statistics.counter.num == 0 || \
|
---|
238 | value < ctdb_db->statistics.counter.min) \
|
---|
239 | ctdb_db->statistics.counter.min = value; \
|
---|
240 | \
|
---|
241 | ctdb_db->statistics.counter.total += value; \
|
---|
242 | ctdb_db->statistics.counter.num++; \
|
---|
243 | \
|
---|
244 | if (ctdb_db->ctdb->tunable.log_latency_ms != 0) { \
|
---|
245 | if (value*1000 > ctdb_db->ctdb->tunable.log_latency_ms) { \
|
---|
246 | DEBUG(DEBUG_ERR, \
|
---|
247 | ("High latency %.6fs for operation %s on database %s\n",\
|
---|
248 | value, operation, ctdb_db->db_name)); \
|
---|
249 | } \
|
---|
250 | } \
|
---|
251 | }
|
---|
252 |
|
---|
253 | #define CTDB_UPDATE_LATENCY(ctdb, db, operation, counter, t) \
|
---|
254 | { \
|
---|
255 | double l = timeval_elapsed(&t); \
|
---|
256 | \
|
---|
257 | if (l > ctdb->statistics.counter.max) \
|
---|
258 | ctdb->statistics.counter.max = l; \
|
---|
259 | if (l > ctdb->statistics_current.counter.max) \
|
---|
260 | ctdb->statistics_current.counter.max = l; \
|
---|
261 | \
|
---|
262 | if (ctdb->statistics.counter.num == 0 || \
|
---|
263 | l < ctdb->statistics.counter.min) \
|
---|
264 | ctdb->statistics.counter.min = l; \
|
---|
265 | if (ctdb->statistics_current.counter.num == 0 || \
|
---|
266 | l < ctdb->statistics_current.counter.min) \
|
---|
267 | ctdb->statistics_current.counter.min = l; \
|
---|
268 | \
|
---|
269 | ctdb->statistics.counter.total += l; \
|
---|
270 | ctdb->statistics_current.counter.total += l; \
|
---|
271 | \
|
---|
272 | ctdb->statistics.counter.num++; \
|
---|
273 | ctdb->statistics_current.counter.num++; \
|
---|
274 | \
|
---|
275 | if (ctdb->tunable.log_latency_ms != 0) { \
|
---|
276 | if (l*1000 > ctdb->tunable.log_latency_ms) { \
|
---|
277 | DEBUG(DEBUG_WARNING, \
|
---|
278 | ("High latency %.6fs for operation %s on database %s\n",\
|
---|
279 | l, operation, db->db_name)); \
|
---|
280 | } \
|
---|
281 | } \
|
---|
282 | }
|
---|
283 |
|
---|
284 |
|
---|
285 | enum ctdb_freeze_mode {CTDB_FREEZE_NONE, CTDB_FREEZE_PENDING, CTDB_FREEZE_FROZEN};
|
---|
286 |
|
---|
287 | #define NUM_DB_PRIORITIES 3
|
---|
288 | /* main state of the ctdb daemon */
|
---|
289 | struct ctdb_context {
|
---|
290 | struct tevent_context *ev;
|
---|
291 | struct timeval ctdbd_start_time;
|
---|
292 | struct timeval last_recovery_started;
|
---|
293 | struct timeval last_recovery_finished;
|
---|
294 | uint32_t recovery_mode;
|
---|
295 | TALLOC_CTX *tickle_update_context;
|
---|
296 | TALLOC_CTX *keepalive_ctx;
|
---|
297 | TALLOC_CTX *check_public_ifaces_ctx;
|
---|
298 | struct ctdb_tunable_list tunable;
|
---|
299 | enum ctdb_freeze_mode freeze_mode[NUM_DB_PRIORITIES+1];
|
---|
300 | struct ctdb_freeze_handle *freeze_handles[NUM_DB_PRIORITIES+1];
|
---|
301 | bool freeze_transaction_started;
|
---|
302 | uint32_t freeze_transaction_id;
|
---|
303 | ctdb_sock_addr *address;
|
---|
304 | const char *name;
|
---|
305 | const char *db_directory;
|
---|
306 | const char *db_directory_persistent;
|
---|
307 | const char *db_directory_state;
|
---|
308 | struct tdb_wrap *db_persistent_health;
|
---|
309 | uint32_t db_persistent_startup_generation;
|
---|
310 | uint64_t db_persistent_check_errors;
|
---|
311 | uint64_t max_persistent_check_errors;
|
---|
312 | const char *transport;
|
---|
313 | char *recovery_lock_file;
|
---|
314 | int recovery_lock_fd;
|
---|
315 | uint32_t pnn; /* our own pnn */
|
---|
316 | uint32_t num_nodes;
|
---|
317 | uint32_t num_connected;
|
---|
318 | unsigned flags;
|
---|
319 | uint32_t capabilities;
|
---|
320 | struct reqid_context *idr;
|
---|
321 | struct ctdb_node **nodes; /* array of nodes in the cluster - indexed by vnn */
|
---|
322 | struct ctdb_vnn *vnn; /* list of public ip addresses and interfaces */
|
---|
323 | struct ctdb_vnn *single_ip_vnn; /* a structure for the single ip */
|
---|
324 | struct ctdb_interface *ifaces; /* list of local interfaces */
|
---|
325 | char *err_msg;
|
---|
326 | const struct ctdb_methods *methods; /* transport methods */
|
---|
327 | const struct ctdb_upcalls *upcalls; /* transport upcalls */
|
---|
328 | void *private_data; /* private to transport */
|
---|
329 | struct ctdb_db_context *db_list;
|
---|
330 | struct srvid_context *srv;
|
---|
331 | struct ctdb_daemon_data daemon;
|
---|
332 | struct ctdb_statistics statistics;
|
---|
333 | struct ctdb_statistics statistics_current;
|
---|
334 | #define MAX_STAT_HISTORY 100
|
---|
335 | struct ctdb_statistics statistics_history[MAX_STAT_HISTORY];
|
---|
336 | struct ctdb_vnn_map *vnn_map;
|
---|
337 | uint32_t num_clients;
|
---|
338 | uint32_t recovery_master;
|
---|
339 | struct ctdb_client_ip *client_ip_list;
|
---|
340 | bool do_checkpublicip;
|
---|
341 | struct trbt_tree *server_ids;
|
---|
342 | bool do_setsched;
|
---|
343 | const char *event_script_dir;
|
---|
344 | const char *notification_script;
|
---|
345 | const char *default_public_interface;
|
---|
346 | pid_t ctdbd_pid;
|
---|
347 | pid_t recoverd_pid;
|
---|
348 | enum ctdb_runstate runstate;
|
---|
349 | struct ctdb_monitor_state *monitor;
|
---|
350 | int start_as_disabled;
|
---|
351 | int start_as_stopped;
|
---|
352 | bool valgrinding;
|
---|
353 | uint32_t *recd_ping_count;
|
---|
354 | TALLOC_CTX *recd_ctx; /* a context used to track recoverd monitoring events */
|
---|
355 | TALLOC_CTX *release_ips_ctx; /* a context used to automatically drop all IPs if we fail to recover the node */
|
---|
356 |
|
---|
357 | TALLOC_CTX *event_script_ctx;
|
---|
358 | int active_events;
|
---|
359 |
|
---|
360 | struct ctdb_event_script_state *current_monitor;
|
---|
361 | struct ctdb_script_list_old *last_status[CTDB_EVENT_MAX];
|
---|
362 |
|
---|
363 | TALLOC_CTX *banning_ctx;
|
---|
364 |
|
---|
365 | struct ctdb_vacuum_child_context *vacuumers;
|
---|
366 |
|
---|
367 | /* mapping from pid to ctdb_client * */
|
---|
368 | struct ctdb_client_pid_list *client_pids;
|
---|
369 |
|
---|
370 | /* used in the recovery daemon to remember the ip allocation */
|
---|
371 | struct trbt_tree *ip_tree;
|
---|
372 |
|
---|
373 | /* Used to defer db attach requests while in recovery mode */
|
---|
374 | struct ctdb_deferred_attach_context *deferred_attach;
|
---|
375 |
|
---|
376 | /* if we are a child process, do we have a domain socket to send controls on */
|
---|
377 | bool can_send_controls;
|
---|
378 |
|
---|
379 | /* list of event script callback functions that are active */
|
---|
380 | struct event_script_callback *script_callbacks;
|
---|
381 |
|
---|
382 | struct ctdb_reloadips_handle *reload_ips;
|
---|
383 |
|
---|
384 | const char *nodes_file;
|
---|
385 | const char *public_addresses_file;
|
---|
386 | struct trbt_tree *child_processes;
|
---|
387 |
|
---|
388 | /* Used for locking record/db/alldb */
|
---|
389 | struct lock_context *lock_current;
|
---|
390 | struct lock_context *lock_pending;
|
---|
391 | };
|
---|
392 |
|
---|
393 | struct ctdb_db_context {
|
---|
394 | struct ctdb_db_context *next, *prev;
|
---|
395 | struct ctdb_context *ctdb;
|
---|
396 | uint32_t db_id;
|
---|
397 | uint32_t priority;
|
---|
398 | bool persistent;
|
---|
399 | bool readonly; /* Do we support read-only delegations ? */
|
---|
400 | bool sticky; /* Do we support sticky records ? */
|
---|
401 | const char *db_name;
|
---|
402 | const char *db_path;
|
---|
403 | struct tdb_wrap *ltdb;
|
---|
404 | struct tdb_context *rottdb; /* ReadOnly tracking TDB */
|
---|
405 | struct ctdb_registered_call *calls; /* list of registered calls */
|
---|
406 | uint32_t seqnum;
|
---|
407 | struct tevent_timer *seqnum_update;
|
---|
408 | struct ctdb_traverse_local_handle *traverse;
|
---|
409 | struct ctdb_vacuum_handle *vacuum_handle;
|
---|
410 | char *unhealthy_reason;
|
---|
411 | int pending_requests;
|
---|
412 | struct revokechild_handle *revokechild_active;
|
---|
413 | struct ctdb_persistent_state *persistent_state;
|
---|
414 | struct trbt_tree *delete_queue;
|
---|
415 | struct trbt_tree *sticky_records;
|
---|
416 | int (*ctdb_ltdb_store_fn)(struct ctdb_db_context *ctdb_db,
|
---|
417 | TDB_DATA key,
|
---|
418 | struct ctdb_ltdb_header *header,
|
---|
419 | TDB_DATA data);
|
---|
420 |
|
---|
421 | /* used to track which records we are currently fetching
|
---|
422 | so we can avoid sending duplicate fetch requests
|
---|
423 | */
|
---|
424 | struct trbt_tree *deferred_fetch;
|
---|
425 | struct trbt_tree *defer_dmaster;
|
---|
426 |
|
---|
427 | struct ctdb_db_statistics_old statistics;
|
---|
428 |
|
---|
429 | struct lock_context *lock_current;
|
---|
430 | struct lock_context *lock_pending;
|
---|
431 | int lock_num_current;
|
---|
432 |
|
---|
433 | struct ctdb_call_state *pending_calls;
|
---|
434 |
|
---|
435 | enum ctdb_freeze_mode freeze_mode;
|
---|
436 | struct ctdb_db_freeze_handle *freeze_handle;
|
---|
437 | bool freeze_transaction_started;
|
---|
438 | uint32_t freeze_transaction_id;
|
---|
439 | uint32_t generation;
|
---|
440 |
|
---|
441 | bool push_started;
|
---|
442 | void *push_state;
|
---|
443 | };
|
---|
444 |
|
---|
445 |
|
---|
446 | #define CTDB_NO_MEMORY(ctdb, p) do { if (!(p)) { \
|
---|
447 | DEBUG(0,("Out of memory for %s at %s\n", #p, __location__)); \
|
---|
448 | ctdb_set_error(ctdb, "Out of memory at %s:%d", __FILE__, __LINE__); \
|
---|
449 | return -1; }} while (0)
|
---|
450 |
|
---|
451 | #define CTDB_NO_MEMORY_VOID(ctdb, p) do { if (!(p)) { \
|
---|
452 | DEBUG(0,("Out of memory for %s at %s\n", #p, __location__)); \
|
---|
453 | ctdb_set_error(ctdb, "Out of memory at %s:%d", __FILE__, __LINE__); \
|
---|
454 | return; }} while (0)
|
---|
455 |
|
---|
456 | #define CTDB_NO_MEMORY_NULL(ctdb, p) do { if (!(p)) { \
|
---|
457 | DEBUG(0,("Out of memory for %s at %s\n", #p, __location__)); \
|
---|
458 | ctdb_set_error(ctdb, "Out of memory at %s:%d", __FILE__, __LINE__); \
|
---|
459 | return NULL; }} while (0)
|
---|
460 |
|
---|
461 | #define CTDB_NO_MEMORY_FATAL(ctdb, p) do { if (!(p)) { \
|
---|
462 | DEBUG(0,("Out of memory for %s at %s\n", #p, __location__)); \
|
---|
463 | ctdb_fatal(ctdb, "Out of memory in " __location__ ); \
|
---|
464 | }} while (0)
|
---|
465 |
|
---|
466 |
|
---|
467 | enum call_state {CTDB_CALL_WAIT, CTDB_CALL_DONE, CTDB_CALL_ERROR};
|
---|
468 |
|
---|
469 | /*
|
---|
470 | state of a in-progress ctdb call
|
---|
471 | */
|
---|
472 | struct ctdb_call_state {
|
---|
473 | struct ctdb_call_state *next, *prev;
|
---|
474 | enum call_state state;
|
---|
475 | uint32_t reqid;
|
---|
476 | struct ctdb_req_call_old *c;
|
---|
477 | struct ctdb_db_context *ctdb_db;
|
---|
478 | const char *errmsg;
|
---|
479 | struct ctdb_call *call;
|
---|
480 | uint32_t generation;
|
---|
481 | struct {
|
---|
482 | void (*fn)(struct ctdb_call_state *);
|
---|
483 | void *private_data;
|
---|
484 | } async;
|
---|
485 | };
|
---|
486 |
|
---|
487 | /* internal prototypes */
|
---|
488 |
|
---|
489 | #define CHECK_CONTROL_DATA_SIZE(size) do { \
|
---|
490 | if (indata.dsize != size) { \
|
---|
491 | DEBUG(0,(__location__ " Invalid data size in opcode %u. Got %u expected %u\n", \
|
---|
492 | opcode, (unsigned)indata.dsize, (unsigned)size)); \
|
---|
493 | return -1; \
|
---|
494 | } \
|
---|
495 | } while (0)
|
---|
496 |
|
---|
497 | #define CHECK_CONTROL_MIN_DATA_SIZE(size) do { \
|
---|
498 | if (indata.dsize < size) { \
|
---|
499 | DEBUG(0,(__location__ " Invalid data size in opcode %u. Got %u expected >= %u\n", \
|
---|
500 | opcode, (unsigned)indata.dsize, (unsigned)size)); \
|
---|
501 | return -1; \
|
---|
502 | } \
|
---|
503 | } while (0)
|
---|
504 |
|
---|
505 | /*
|
---|
506 | state of a in-progress ctdb call in client
|
---|
507 | */
|
---|
508 | struct ctdb_client_call_state {
|
---|
509 | enum call_state state;
|
---|
510 | uint32_t reqid;
|
---|
511 | struct ctdb_db_context *ctdb_db;
|
---|
512 | struct ctdb_call *call;
|
---|
513 | struct {
|
---|
514 | void (*fn)(struct ctdb_client_call_state *);
|
---|
515 | void *private_data;
|
---|
516 | } async;
|
---|
517 | };
|
---|
518 |
|
---|
519 | extern int script_log_level;
|
---|
520 | extern bool fast_start;
|
---|
521 | extern const char *ctdbd_pidfile;
|
---|
522 |
|
---|
523 | typedef void (*deferred_requeue_fn)(void *call_context, struct ctdb_req_header *hdr);
|
---|
524 |
|
---|
525 |
|
---|
526 | /* from tcp/ and ib/ */
|
---|
527 |
|
---|
528 | int ctdb_tcp_init(struct ctdb_context *ctdb);
|
---|
529 | int ctdb_ibw_init(struct ctdb_context *ctdb);
|
---|
530 |
|
---|
531 | /* from ctdb_banning.c */
|
---|
532 |
|
---|
533 | void ctdb_local_node_got_banned(struct ctdb_context *ctdb);
|
---|
534 | int32_t ctdb_control_set_ban_state(struct ctdb_context *ctdb, TDB_DATA indata);
|
---|
535 | int32_t ctdb_control_get_ban_state(struct ctdb_context *ctdb, TDB_DATA *outdata);
|
---|
536 | void ctdb_ban_self(struct ctdb_context *ctdb);
|
---|
537 |
|
---|
538 | /* from ctdb_call.c */
|
---|
539 |
|
---|
540 | struct ctdb_db_context *find_ctdb_db(struct ctdb_context *ctdb, uint32_t id);
|
---|
541 |
|
---|
542 | void ctdb_request_dmaster(struct ctdb_context *ctdb,
|
---|
543 | struct ctdb_req_header *hdr);
|
---|
544 | void ctdb_reply_dmaster(struct ctdb_context *ctdb,
|
---|
545 | struct ctdb_req_header *hdr);
|
---|
546 | void ctdb_request_call(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
|
---|
547 | void ctdb_reply_call(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
|
---|
548 | void ctdb_reply_error(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
|
---|
549 |
|
---|
550 | void ctdb_call_resend_db(struct ctdb_db_context *ctdb);
|
---|
551 | void ctdb_call_resend_all(struct ctdb_context *ctdb);
|
---|
552 |
|
---|
553 | struct ctdb_call_state *ctdb_call_local_send(struct ctdb_db_context *ctdb_db,
|
---|
554 | struct ctdb_call *call,
|
---|
555 | struct ctdb_ltdb_header *header,
|
---|
556 | TDB_DATA *data);
|
---|
557 |
|
---|
558 | struct ctdb_call_state *ctdb_daemon_call_send_remote(
|
---|
559 | struct ctdb_db_context *ctdb_db,
|
---|
560 | struct ctdb_call *call,
|
---|
561 | struct ctdb_ltdb_header *header);
|
---|
562 | int ctdb_daemon_call_recv(struct ctdb_call_state *state,
|
---|
563 | struct ctdb_call *call);
|
---|
564 |
|
---|
565 | void ctdb_send_keepalive(struct ctdb_context *ctdb, uint32_t destnode);
|
---|
566 |
|
---|
567 | int ctdb_start_revoke_ro_record(struct ctdb_context *ctdb,
|
---|
568 | struct ctdb_db_context *ctdb_db,
|
---|
569 | TDB_DATA key, struct ctdb_ltdb_header *header,
|
---|
570 | TDB_DATA data);
|
---|
571 |
|
---|
572 | int ctdb_add_revoke_deferred_call(struct ctdb_context *ctdb,
|
---|
573 | struct ctdb_db_context *ctdb_db,
|
---|
574 | TDB_DATA key, struct ctdb_req_header *hdr,
|
---|
575 | deferred_requeue_fn fn, void *call_context);
|
---|
576 |
|
---|
577 | /* from server/ctdb_control.c */
|
---|
578 |
|
---|
579 | int32_t ctdb_dump_memory(struct ctdb_context *ctdb, TDB_DATA *outdata);
|
---|
580 |
|
---|
581 | void ctdb_request_control_reply(struct ctdb_context *ctdb,
|
---|
582 | struct ctdb_req_control_old *c,
|
---|
583 | TDB_DATA *outdata, int32_t status,
|
---|
584 | const char *errormsg);
|
---|
585 |
|
---|
586 | void ctdb_request_control(struct ctdb_context *ctdb,
|
---|
587 | struct ctdb_req_header *hdr);
|
---|
588 | void ctdb_reply_control(struct ctdb_context *ctdb,
|
---|
589 | struct ctdb_req_header *hdr);
|
---|
590 |
|
---|
591 | int ctdb_daemon_send_control(struct ctdb_context *ctdb, uint32_t destnode,
|
---|
592 | uint64_t srvid, uint32_t opcode,
|
---|
593 | uint32_t client_id, uint32_t flags,
|
---|
594 | TDB_DATA data,
|
---|
595 | ctdb_control_callback_fn_t callback,
|
---|
596 | void *private_data);
|
---|
597 |
|
---|
598 | /* from server/ctdb_daemon.c */
|
---|
599 |
|
---|
600 | int daemon_register_message_handler(struct ctdb_context *ctdb,
|
---|
601 | uint32_t client_id, uint64_t srvid);
|
---|
602 | int daemon_deregister_message_handler(struct ctdb_context *ctdb,
|
---|
603 | uint32_t client_id, uint64_t srvid);
|
---|
604 | int daemon_check_srvids(struct ctdb_context *ctdb, TDB_DATA indata,
|
---|
605 | TDB_DATA *outdata);
|
---|
606 |
|
---|
607 | int ctdb_start_daemon(struct ctdb_context *ctdb, bool do_fork);
|
---|
608 |
|
---|
609 | struct ctdb_req_header *_ctdb_transport_allocate(struct ctdb_context *ctdb,
|
---|
610 | TALLOC_CTX *mem_ctx,
|
---|
611 | enum ctdb_operation operation,
|
---|
612 | size_t length, size_t slength,
|
---|
613 | const char *type);
|
---|
614 |
|
---|
615 | #define ctdb_transport_allocate(ctdb, mem_ctx, operation, length, type) \
|
---|
616 | (type *)_ctdb_transport_allocate(ctdb, mem_ctx, operation, length, \
|
---|
617 | sizeof(type), #type)
|
---|
618 |
|
---|
619 | void ctdb_daemon_cancel_controls(struct ctdb_context *ctdb,
|
---|
620 | struct ctdb_node *node);
|
---|
621 |
|
---|
622 | int ctdb_daemon_set_call(struct ctdb_context *ctdb, uint32_t db_id,
|
---|
623 | ctdb_fn_t fn, int id);
|
---|
624 |
|
---|
625 | int ctdb_daemon_send_message(struct ctdb_context *ctdb, uint32_t pnn,
|
---|
626 | uint64_t srvid, TDB_DATA data);
|
---|
627 |
|
---|
628 | int32_t ctdb_control_register_notify(struct ctdb_context *ctdb,
|
---|
629 | uint32_t client_id, TDB_DATA indata);
|
---|
630 | int32_t ctdb_control_deregister_notify(struct ctdb_context *ctdb,
|
---|
631 | uint32_t client_id, TDB_DATA indata);
|
---|
632 |
|
---|
633 | struct ctdb_client *ctdb_find_client_by_pid(struct ctdb_context *ctdb,
|
---|
634 | pid_t pid);
|
---|
635 |
|
---|
636 | int32_t ctdb_control_process_exists(struct ctdb_context *ctdb, pid_t pid);
|
---|
637 |
|
---|
638 | int ctdb_control_getnodesfile(struct ctdb_context *ctdb, uint32_t opcode,
|
---|
639 | TDB_DATA indata, TDB_DATA *outdata);
|
---|
640 |
|
---|
641 | void ctdb_shutdown_sequence(struct ctdb_context *ctdb, int exit_code);
|
---|
642 |
|
---|
643 | int switch_from_server_to_client(struct ctdb_context *ctdb,
|
---|
644 | const char *fmt, ...);
|
---|
645 |
|
---|
646 | /* From server/ctdb_fork.c */
|
---|
647 |
|
---|
648 | void ctdb_set_child_info(TALLOC_CTX *mem_ctx, const char *child_name_fmt, ...);
|
---|
649 |
|
---|
650 | void ctdb_track_child(struct ctdb_context *ctdb, pid_t pid);
|
---|
651 |
|
---|
652 | pid_t ctdb_fork(struct ctdb_context *ctdb);
|
---|
653 |
|
---|
654 | struct tevent_signal *ctdb_init_sigchld(struct ctdb_context *ctdb);
|
---|
655 |
|
---|
656 | int ctdb_kill(struct ctdb_context *ctdb, pid_t pid, int signum);
|
---|
657 |
|
---|
658 | /* from server/ctdb_freeze.c */
|
---|
659 |
|
---|
660 | int32_t ctdb_control_db_freeze(struct ctdb_context *ctdb,
|
---|
661 | struct ctdb_req_control_old *c,
|
---|
662 | uint32_t db_id, bool *async_reply);
|
---|
663 | int32_t ctdb_control_db_thaw(struct ctdb_context *ctdb, uint32_t db_id);
|
---|
664 |
|
---|
665 | int32_t ctdb_control_freeze(struct ctdb_context *ctdb,
|
---|
666 | struct ctdb_req_control_old *c, bool *async_reply);
|
---|
667 | int32_t ctdb_control_thaw(struct ctdb_context *ctdb, uint32_t priority,
|
---|
668 | bool check_recmode);
|
---|
669 |
|
---|
670 | bool ctdb_blocking_freeze(struct ctdb_context *ctdb);
|
---|
671 |
|
---|
672 | int32_t ctdb_control_db_transaction_start(struct ctdb_context *ctdb,
|
---|
673 | TDB_DATA indata);
|
---|
674 | int32_t ctdb_control_db_transaction_cancel(struct ctdb_context *ctdb,
|
---|
675 | TDB_DATA indata);
|
---|
676 | int32_t ctdb_control_db_transaction_commit(struct ctdb_context *ctdb,
|
---|
677 | TDB_DATA indata);
|
---|
678 |
|
---|
679 | int32_t ctdb_control_transaction_start(struct ctdb_context *ctdb, uint32_t id);
|
---|
680 | int32_t ctdb_control_transaction_cancel(struct ctdb_context *ctdb);
|
---|
681 | int32_t ctdb_control_transaction_commit(struct ctdb_context *ctdb, uint32_t id);
|
---|
682 |
|
---|
683 | int32_t ctdb_control_wipe_database(struct ctdb_context *ctdb, TDB_DATA indata);
|
---|
684 |
|
---|
685 | bool ctdb_db_frozen(struct ctdb_db_context *ctdb_db);
|
---|
686 | bool ctdb_db_prio_frozen(struct ctdb_context *ctdb, uint32_t priority);
|
---|
687 | bool ctdb_db_all_frozen(struct ctdb_context *ctdb);
|
---|
688 |
|
---|
689 | /* from server/ctdb_keepalive.c */
|
---|
690 |
|
---|
691 | void ctdb_start_keepalive(struct ctdb_context *ctdb);
|
---|
692 | void ctdb_stop_keepalive(struct ctdb_context *ctdb);
|
---|
693 |
|
---|
694 | /* from server/ctdb_lock.c */
|
---|
695 |
|
---|
696 | struct lock_request;
|
---|
697 |
|
---|
698 | typedef int (*ctdb_db_handler_t)(struct ctdb_db_context *ctdb_db,
|
---|
699 | void *private_data);
|
---|
700 |
|
---|
701 | int ctdb_db_prio_iterator(struct ctdb_context *ctdb, uint32_t priority,
|
---|
702 | ctdb_db_handler_t handler, void *private_data);
|
---|
703 | int ctdb_db_iterator(struct ctdb_context *ctdb, ctdb_db_handler_t handler,
|
---|
704 | void *private_data);
|
---|
705 |
|
---|
706 | int ctdb_lockdb_mark(struct ctdb_db_context *ctdb_db);
|
---|
707 | int ctdb_lockall_mark_prio(struct ctdb_context *ctdb, uint32_t priority);
|
---|
708 |
|
---|
709 | int ctdb_lockdb_unmark(struct ctdb_db_context *ctdb_db);
|
---|
710 | int ctdb_lockall_unmark_prio(struct ctdb_context *ctdb, uint32_t priority);
|
---|
711 |
|
---|
712 | struct lock_request *ctdb_lock_record(TALLOC_CTX *mem_ctx,
|
---|
713 | struct ctdb_db_context *ctdb_db,
|
---|
714 | TDB_DATA key,
|
---|
715 | bool auto_mark,
|
---|
716 | void (*callback)(void *, bool),
|
---|
717 | void *private_data);
|
---|
718 |
|
---|
719 | struct lock_request *ctdb_lock_db(TALLOC_CTX *mem_ctx,
|
---|
720 | struct ctdb_db_context *ctdb_db,
|
---|
721 | bool auto_mark,
|
---|
722 | void (*callback)(void *, bool),
|
---|
723 | void *private_data);
|
---|
724 |
|
---|
725 | struct lock_request *ctdb_lock_alldb_prio(TALLOC_CTX *mem_ctx,
|
---|
726 | struct ctdb_context *ctdb,
|
---|
727 | uint32_t priority,
|
---|
728 | bool auto_mark,
|
---|
729 | void (*callback)(void *, bool),
|
---|
730 | void *private_data);
|
---|
731 |
|
---|
732 | struct lock_request *ctdb_lock_alldb(TALLOC_CTX *mem_ctx,
|
---|
733 | struct ctdb_context *ctdb,
|
---|
734 | bool auto_mark,
|
---|
735 | void (*callback)(void *, bool),
|
---|
736 | void *private_data);
|
---|
737 |
|
---|
738 | /* from ctdb_logging.c */
|
---|
739 |
|
---|
740 | extern const char *debug_extra;
|
---|
741 |
|
---|
742 | typedef int (*ctdb_log_setup_fn_t)(TALLOC_CTX *mem_ctx,
|
---|
743 | const char *logging,
|
---|
744 | const char *app_name);
|
---|
745 |
|
---|
746 | void ctdb_log_register_backend(const char *prefix, ctdb_log_setup_fn_t init);
|
---|
747 |
|
---|
748 | bool ctdb_logging_init(TALLOC_CTX *mem_ctx, const char *logging);
|
---|
749 |
|
---|
750 | struct ctdb_log_state *ctdb_vfork_with_logging(TALLOC_CTX *mem_ctx,
|
---|
751 | struct ctdb_context *ctdb,
|
---|
752 | const char *log_prefix,
|
---|
753 | const char *helper,
|
---|
754 | int helper_argc,
|
---|
755 | const char **helper_argv,
|
---|
756 | void (*logfn)(const char *,
|
---|
757 | uint16_t, void *),
|
---|
758 | void *logfn_private, pid_t *pid);
|
---|
759 |
|
---|
760 | int ctdb_set_child_logging(struct ctdb_context *ctdb);
|
---|
761 | int ctdb_init_tevent_logging(struct ctdb_context *ctdb);
|
---|
762 |
|
---|
763 | /* from ctdb_logging_file.c */
|
---|
764 |
|
---|
765 | void ctdb_log_init_file(void);
|
---|
766 |
|
---|
767 | /* from ctdb_logging_syslog.c */
|
---|
768 |
|
---|
769 | void ctdb_log_init_syslog(void);
|
---|
770 |
|
---|
771 | /* from ctdb_ltdb_server.c */
|
---|
772 |
|
---|
773 | int ctdb_ltdb_lock_requeue(struct ctdb_db_context *ctdb_db,
|
---|
774 | TDB_DATA key, struct ctdb_req_header *hdr,
|
---|
775 | void (*recv_pkt)(void *, struct ctdb_req_header *),
|
---|
776 | void *recv_context, bool ignore_generation);
|
---|
777 |
|
---|
778 | int ctdb_ltdb_lock_fetch_requeue(struct ctdb_db_context *ctdb_db,
|
---|
779 | TDB_DATA key, struct ctdb_ltdb_header *header,
|
---|
780 | struct ctdb_req_header *hdr, TDB_DATA *data,
|
---|
781 | void (*recv_pkt)(void *, struct ctdb_req_header *),
|
---|
782 | void *recv_context, bool ignore_generation);
|
---|
783 |
|
---|
784 | int ctdb_load_persistent_health(struct ctdb_context *ctdb,
|
---|
785 | struct ctdb_db_context *ctdb_db);
|
---|
786 | int ctdb_update_persistent_health(struct ctdb_context *ctdb,
|
---|
787 | struct ctdb_db_context *ctdb_db,
|
---|
788 | const char *reason,/* NULL means healthy */
|
---|
789 | int num_healthy_nodes);
|
---|
790 | int ctdb_recheck_persistent_health(struct ctdb_context *ctdb);
|
---|
791 |
|
---|
792 | int32_t ctdb_control_db_set_healthy(struct ctdb_context *ctdb,
|
---|
793 | TDB_DATA indata);
|
---|
794 | int32_t ctdb_control_db_get_health(struct ctdb_context *ctdb,
|
---|
795 | TDB_DATA indata, TDB_DATA *outdata);
|
---|
796 |
|
---|
797 | int ctdb_set_db_readonly(struct ctdb_context *ctdb,
|
---|
798 | struct ctdb_db_context *ctdb_db);
|
---|
799 |
|
---|
800 | int ctdb_process_deferred_attach(struct ctdb_context *ctdb);
|
---|
801 |
|
---|
802 | int32_t ctdb_control_db_attach(struct ctdb_context *ctdb, TDB_DATA indata,
|
---|
803 | TDB_DATA *outdata, uint64_t tdb_flags,
|
---|
804 | bool persistent, uint32_t client_id,
|
---|
805 | struct ctdb_req_control_old *c,
|
---|
806 | bool *async_reply);
|
---|
807 | int32_t ctdb_control_db_detach(struct ctdb_context *ctdb, TDB_DATA indata,
|
---|
808 | uint32_t client_id);
|
---|
809 |
|
---|
810 | int ctdb_attach_databases(struct ctdb_context *ctdb);
|
---|
811 |
|
---|
812 | int32_t ctdb_ltdb_update_seqnum(struct ctdb_context *ctdb, uint32_t db_id,
|
---|
813 | uint32_t srcnode);
|
---|
814 | int32_t ctdb_ltdb_enable_seqnum(struct ctdb_context *ctdb, uint32_t db_id);
|
---|
815 |
|
---|
816 | int32_t ctdb_control_set_db_priority(struct ctdb_context *ctdb, TDB_DATA indata,
|
---|
817 | uint32_t client_id);
|
---|
818 |
|
---|
819 | int ctdb_set_db_sticky(struct ctdb_context *ctdb,
|
---|
820 | struct ctdb_db_context *ctdb_db);
|
---|
821 |
|
---|
822 | void ctdb_db_statistics_reset(struct ctdb_db_context *ctdb_db);
|
---|
823 |
|
---|
824 | int32_t ctdb_control_get_db_statistics(struct ctdb_context *ctdb,
|
---|
825 | uint32_t db_id, TDB_DATA *outdata);
|
---|
826 |
|
---|
827 | /* from ctdb_monitor.c */
|
---|
828 |
|
---|
829 | int ctdb_set_notification_script(struct ctdb_context *ctdb, const char *script);
|
---|
830 | void ctdb_run_notification_script(struct ctdb_context *ctdb, const char *event);
|
---|
831 |
|
---|
832 | void ctdb_disable_monitoring(struct ctdb_context *ctdb);
|
---|
833 | void ctdb_enable_monitoring(struct ctdb_context *ctdb);
|
---|
834 | void ctdb_stop_monitoring(struct ctdb_context *ctdb);
|
---|
835 |
|
---|
836 | void ctdb_wait_for_first_recovery(struct ctdb_context *ctdb);
|
---|
837 |
|
---|
838 | int32_t ctdb_control_modflags(struct ctdb_context *ctdb, TDB_DATA indata);
|
---|
839 |
|
---|
840 | int32_t ctdb_monitoring_mode(struct ctdb_context *ctdb);
|
---|
841 | bool ctdb_stopped_monitoring(struct ctdb_context *ctdb);
|
---|
842 |
|
---|
843 | /* from ctdb_persistent.c */
|
---|
844 |
|
---|
845 | void ctdb_persistent_finish_trans3_commits(struct ctdb_context *ctdb);
|
---|
846 |
|
---|
847 | int32_t ctdb_control_trans3_commit(struct ctdb_context *ctdb,
|
---|
848 | struct ctdb_req_control_old *c,
|
---|
849 | TDB_DATA recdata, bool *async_reply);
|
---|
850 |
|
---|
851 | int32_t ctdb_control_start_persistent_update(struct ctdb_context *ctdb,
|
---|
852 | struct ctdb_req_control_old *c,
|
---|
853 | TDB_DATA recdata);
|
---|
854 | int32_t ctdb_control_cancel_persistent_update(struct ctdb_context *ctdb,
|
---|
855 | struct ctdb_req_control_old *c,
|
---|
856 | TDB_DATA recdata);
|
---|
857 |
|
---|
858 | int32_t ctdb_control_get_db_seqnum(struct ctdb_context *ctdb,
|
---|
859 | TDB_DATA indata, TDB_DATA *outdata);
|
---|
860 |
|
---|
861 | /* from ctdb_recover.c */
|
---|
862 |
|
---|
863 | int ctdb_control_getvnnmap(struct ctdb_context *ctdb, uint32_t opcode,
|
---|
864 | TDB_DATA indata, TDB_DATA *outdata);
|
---|
865 | int ctdb_control_setvnnmap(struct ctdb_context *ctdb, uint32_t opcode,
|
---|
866 | TDB_DATA indata, TDB_DATA *outdata);
|
---|
867 |
|
---|
868 | int ctdb_control_getdbmap(struct ctdb_context *ctdb, uint32_t opcode,
|
---|
869 | TDB_DATA indata, TDB_DATA *outdata);
|
---|
870 | int ctdb_control_getnodemap(struct ctdb_context *ctdb, uint32_t opcode,
|
---|
871 | TDB_DATA indata, TDB_DATA *outdata);
|
---|
872 |
|
---|
873 | int ctdb_control_reload_nodes_file(struct ctdb_context *ctdb, uint32_t opcode);
|
---|
874 |
|
---|
875 | int32_t ctdb_control_pull_db(struct ctdb_context *ctdb, TDB_DATA indata,
|
---|
876 | TDB_DATA *outdata);
|
---|
877 | int32_t ctdb_control_push_db(struct ctdb_context *ctdb, TDB_DATA indata);
|
---|
878 |
|
---|
879 | int32_t ctdb_control_db_pull(struct ctdb_context *ctdb,
|
---|
880 | struct ctdb_req_control_old *c,
|
---|
881 | TDB_DATA indata, TDB_DATA *outdata);
|
---|
882 | int32_t ctdb_control_db_push_start(struct ctdb_context *ctdb,
|
---|
883 | TDB_DATA indata);
|
---|
884 | int32_t ctdb_control_db_push_confirm(struct ctdb_context *ctdb,
|
---|
885 | TDB_DATA indata, TDB_DATA *outdata);
|
---|
886 |
|
---|
887 | int ctdb_deferred_drop_all_ips(struct ctdb_context *ctdb);
|
---|
888 |
|
---|
889 | int32_t ctdb_control_set_recmode(struct ctdb_context *ctdb,
|
---|
890 | struct ctdb_req_control_old *c,
|
---|
891 | TDB_DATA indata, bool *async_reply,
|
---|
892 | const char **errormsg);
|
---|
893 |
|
---|
894 | bool ctdb_recovery_have_lock(struct ctdb_context *ctdb);
|
---|
895 | bool ctdb_recovery_lock(struct ctdb_context *ctdb);
|
---|
896 | void ctdb_recovery_unlock(struct ctdb_context *ctdb);
|
---|
897 |
|
---|
898 | int32_t ctdb_control_end_recovery(struct ctdb_context *ctdb,
|
---|
899 | struct ctdb_req_control_old *c,
|
---|
900 | bool *async_reply);
|
---|
901 | int32_t ctdb_control_start_recovery(struct ctdb_context *ctdb,
|
---|
902 | struct ctdb_req_control_old *c,
|
---|
903 | bool *async_reply);
|
---|
904 |
|
---|
905 | int32_t ctdb_control_try_delete_records(struct ctdb_context *ctdb,
|
---|
906 | TDB_DATA indata, TDB_DATA *outdata);
|
---|
907 | int32_t ctdb_control_receive_records(struct ctdb_context *ctdb,
|
---|
908 | TDB_DATA indata, TDB_DATA *outdata);
|
---|
909 |
|
---|
910 | int32_t ctdb_control_get_capabilities(struct ctdb_context *ctdb,
|
---|
911 | TDB_DATA *outdata);
|
---|
912 |
|
---|
913 | int32_t ctdb_control_recd_ping(struct ctdb_context *ctdb);
|
---|
914 | int32_t ctdb_control_set_recmaster(struct ctdb_context *ctdb,
|
---|
915 | uint32_t opcode, TDB_DATA indata);
|
---|
916 |
|
---|
917 | int32_t ctdb_control_stop_node(struct ctdb_context *ctdb);
|
---|
918 | int32_t ctdb_control_continue_node(struct ctdb_context *ctdb);
|
---|
919 |
|
---|
920 | /* from ctdb_recoverd.c */
|
---|
921 |
|
---|
922 | int ctdb_start_recoverd(struct ctdb_context *ctdb);
|
---|
923 | void ctdb_stop_recoverd(struct ctdb_context *ctdb);
|
---|
924 |
|
---|
925 | /* from ctdb_server.c */
|
---|
926 |
|
---|
927 | int ctdb_set_transport(struct ctdb_context *ctdb, const char *transport);
|
---|
928 |
|
---|
929 | int ctdb_ip_to_nodeid(struct ctdb_context *ctdb, const ctdb_sock_addr *nodeip);
|
---|
930 |
|
---|
931 | int ctdb_set_recovery_lock_file(struct ctdb_context *ctdb, const char *file);
|
---|
932 |
|
---|
933 | void ctdb_load_nodes_file(struct ctdb_context *ctdb);
|
---|
934 |
|
---|
935 | int ctdb_set_address(struct ctdb_context *ctdb, const char *address);
|
---|
936 |
|
---|
937 | uint32_t ctdb_get_num_active_nodes(struct ctdb_context *ctdb);
|
---|
938 |
|
---|
939 | void ctdb_input_pkt(struct ctdb_context *ctdb, struct ctdb_req_header *);
|
---|
940 |
|
---|
941 | void ctdb_node_dead(struct ctdb_node *node);
|
---|
942 | void ctdb_node_connected(struct ctdb_node *node);
|
---|
943 |
|
---|
944 | void ctdb_queue_packet(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
|
---|
945 | void ctdb_queue_packet_opcode(struct ctdb_context *ctdb,
|
---|
946 | struct ctdb_req_header *hdr, unsigned opcode);
|
---|
947 |
|
---|
948 | /* from ctdb_serverids.c */
|
---|
949 |
|
---|
950 | int32_t ctdb_control_register_server_id(struct ctdb_context *ctdb,
|
---|
951 | uint32_t client_id, TDB_DATA indata);
|
---|
952 | int32_t ctdb_control_check_server_id(struct ctdb_context *ctdb,
|
---|
953 | TDB_DATA indata);
|
---|
954 | int32_t ctdb_control_unregister_server_id(struct ctdb_context *ctdb,
|
---|
955 | TDB_DATA indata);
|
---|
956 | int32_t ctdb_control_get_server_id_list(struct ctdb_context *ctdb,
|
---|
957 | TDB_DATA *outdata);
|
---|
958 |
|
---|
959 | /* from ctdb_statistics.c */
|
---|
960 |
|
---|
961 | int ctdb_statistics_init(struct ctdb_context *ctdb);
|
---|
962 |
|
---|
963 | int32_t ctdb_control_get_stat_history(struct ctdb_context *ctdb,
|
---|
964 | struct ctdb_req_control_old *c,
|
---|
965 | TDB_DATA *outdata);
|
---|
966 |
|
---|
967 | /* from ctdb_takeover.c */
|
---|
968 |
|
---|
969 | int32_t ctdb_control_takeover_ip(struct ctdb_context *ctdb,
|
---|
970 | struct ctdb_req_control_old *c,
|
---|
971 | TDB_DATA indata,
|
---|
972 | bool *async_reply);
|
---|
973 | int32_t ctdb_control_release_ip(struct ctdb_context *ctdb,
|
---|
974 | struct ctdb_req_control_old *c,
|
---|
975 | TDB_DATA indata,
|
---|
976 | bool *async_reply);
|
---|
977 | int32_t ctdb_control_ipreallocated(struct ctdb_context *ctdb,
|
---|
978 | struct ctdb_req_control_old *c,
|
---|
979 | bool *async_reply);
|
---|
980 |
|
---|
981 | int ctdb_set_public_addresses(struct ctdb_context *ctdb, bool check_addresses);
|
---|
982 | int ctdb_set_single_public_ip(struct ctdb_context *ctdb, const char *iface,
|
---|
983 | const char *ip);
|
---|
984 |
|
---|
985 | int ctdb_takeover_run(struct ctdb_context *ctdb, struct ctdb_node_map_old *nodemap,
|
---|
986 | uint32_t *force_rebalance_nodes,
|
---|
987 | client_async_callback fail_callback, void *callback_data);
|
---|
988 |
|
---|
989 | int32_t ctdb_control_tcp_client(struct ctdb_context *ctdb, uint32_t client_id,
|
---|
990 | TDB_DATA indata);
|
---|
991 | int32_t ctdb_control_tcp_add(struct ctdb_context *ctdb, TDB_DATA indata,
|
---|
992 | bool tcp_update_needed);
|
---|
993 | int32_t ctdb_control_tcp_remove(struct ctdb_context *ctdb, TDB_DATA indata);
|
---|
994 | int32_t ctdb_control_startup(struct ctdb_context *ctdb, uint32_t vnn);
|
---|
995 |
|
---|
996 | void ctdb_takeover_client_destructor_hook(struct ctdb_client *client);
|
---|
997 |
|
---|
998 | void ctdb_release_all_ips(struct ctdb_context *ctdb);
|
---|
999 |
|
---|
1000 | int32_t ctdb_control_get_public_ips(struct ctdb_context *ctdb,
|
---|
1001 | struct ctdb_req_control_old *c,
|
---|
1002 | TDB_DATA *outdata);
|
---|
1003 | int32_t ctdb_control_get_public_ip_info(struct ctdb_context *ctdb,
|
---|
1004 | struct ctdb_req_control_old *c,
|
---|
1005 | TDB_DATA indata, TDB_DATA *outdata);
|
---|
1006 |
|
---|
1007 | int32_t ctdb_control_get_ifaces(struct ctdb_context *ctdb,
|
---|
1008 | struct ctdb_req_control_old *c,
|
---|
1009 | TDB_DATA *outdata);
|
---|
1010 | int32_t ctdb_control_set_iface_link(struct ctdb_context *ctdb,
|
---|
1011 | struct ctdb_req_control_old *c,
|
---|
1012 | TDB_DATA indata);
|
---|
1013 |
|
---|
1014 | int32_t ctdb_control_kill_tcp(struct ctdb_context *ctdb, TDB_DATA indata);
|
---|
1015 | int32_t ctdb_control_set_tcp_tickle_list(struct ctdb_context *ctdb,
|
---|
1016 | TDB_DATA indata);
|
---|
1017 | int32_t ctdb_control_get_tcp_tickle_list(struct ctdb_context *ctdb,
|
---|
1018 | TDB_DATA indata, TDB_DATA *outdata);
|
---|
1019 |
|
---|
1020 | void ctdb_start_tcp_tickle_update(struct ctdb_context *ctdb);
|
---|
1021 |
|
---|
1022 | int32_t ctdb_control_send_gratious_arp(struct ctdb_context *ctdb,
|
---|
1023 | TDB_DATA indata);
|
---|
1024 |
|
---|
1025 | int32_t ctdb_control_add_public_address(struct ctdb_context *ctdb,
|
---|
1026 | TDB_DATA indata);
|
---|
1027 | int32_t ctdb_control_del_public_address(struct ctdb_context *ctdb,
|
---|
1028 | struct ctdb_req_control_old *c,
|
---|
1029 | TDB_DATA recdata, bool *async_reply);
|
---|
1030 |
|
---|
1031 | int update_ip_assignment_tree(struct ctdb_context *ctdb,
|
---|
1032 | struct ctdb_public_ip *ip);
|
---|
1033 | void clear_ip_assignment_tree(struct ctdb_context *ctdb);
|
---|
1034 |
|
---|
1035 | int32_t ctdb_control_reload_public_ips(struct ctdb_context *ctdb,
|
---|
1036 | struct ctdb_req_control_old *c,
|
---|
1037 | bool *async_reply);
|
---|
1038 |
|
---|
1039 | /* from ctdb_traverse.c */
|
---|
1040 |
|
---|
1041 | int32_t ctdb_control_traverse_all_ext(struct ctdb_context *ctdb,
|
---|
1042 | TDB_DATA data, TDB_DATA *outdata);
|
---|
1043 | int32_t ctdb_control_traverse_all(struct ctdb_context *ctdb,
|
---|
1044 | TDB_DATA data, TDB_DATA *outdata);
|
---|
1045 | int32_t ctdb_control_traverse_data(struct ctdb_context *ctdb,
|
---|
1046 | TDB_DATA data, TDB_DATA *outdata);
|
---|
1047 | int32_t ctdb_control_traverse_kill(struct ctdb_context *ctdb, TDB_DATA indata,
|
---|
1048 | TDB_DATA *outdata, uint32_t srcnode);
|
---|
1049 |
|
---|
1050 | int32_t ctdb_control_traverse_start_ext(struct ctdb_context *ctdb,
|
---|
1051 | TDB_DATA indata, TDB_DATA *outdata,
|
---|
1052 | uint32_t srcnode, uint32_t client_id);
|
---|
1053 | int32_t ctdb_control_traverse_start(struct ctdb_context *ctdb,
|
---|
1054 | TDB_DATA indata, TDB_DATA *outdata,
|
---|
1055 | uint32_t srcnode, uint32_t client_id);
|
---|
1056 |
|
---|
1057 | /* from ctdb_tunables.c */
|
---|
1058 |
|
---|
1059 | void ctdb_tunables_set_defaults(struct ctdb_context *ctdb);
|
---|
1060 |
|
---|
1061 | int32_t ctdb_control_get_tunable(struct ctdb_context *ctdb, TDB_DATA indata,
|
---|
1062 | TDB_DATA *outdata);
|
---|
1063 | int32_t ctdb_control_set_tunable(struct ctdb_context *ctdb, TDB_DATA indata);
|
---|
1064 | int32_t ctdb_control_list_tunables(struct ctdb_context *ctdb,
|
---|
1065 | TDB_DATA *outdata);
|
---|
1066 |
|
---|
1067 | /* from ctdb_update_record.c */
|
---|
1068 |
|
---|
1069 | int32_t ctdb_control_update_record(struct ctdb_context *ctdb,
|
---|
1070 | struct ctdb_req_control_old *c,
|
---|
1071 | TDB_DATA recdata, bool *async_reply);
|
---|
1072 |
|
---|
1073 | /* from ctdb_uptime.c */
|
---|
1074 |
|
---|
1075 | int32_t ctdb_control_uptime(struct ctdb_context *ctdb, TDB_DATA *outdata);
|
---|
1076 |
|
---|
1077 | /* from ctdb_vacuum.c */
|
---|
1078 |
|
---|
1079 | void ctdb_stop_vacuuming(struct ctdb_context *ctdb);
|
---|
1080 | int ctdb_vacuum_init(struct ctdb_db_context *ctdb_db);
|
---|
1081 |
|
---|
1082 | int32_t ctdb_control_schedule_for_deletion(struct ctdb_context *ctdb,
|
---|
1083 | TDB_DATA indata);
|
---|
1084 | int32_t ctdb_local_schedule_for_deletion(struct ctdb_db_context *ctdb_db,
|
---|
1085 | const struct ctdb_ltdb_header *hdr,
|
---|
1086 | TDB_DATA key);
|
---|
1087 |
|
---|
1088 | void ctdb_local_remove_from_delete_queue(struct ctdb_db_context *ctdb_db,
|
---|
1089 | const struct ctdb_ltdb_header *hdr,
|
---|
1090 | const TDB_DATA key);
|
---|
1091 |
|
---|
1092 | /* from eventscript.c */
|
---|
1093 |
|
---|
1094 | int32_t ctdb_control_get_event_script_status(struct ctdb_context *ctdb,
|
---|
1095 | uint32_t call_type,
|
---|
1096 | TDB_DATA *outdata);
|
---|
1097 |
|
---|
1098 | int ctdb_event_script_callback(struct ctdb_context *ctdb,
|
---|
1099 | TALLOC_CTX *mem_ctx,
|
---|
1100 | void (*callback)(struct ctdb_context *,
|
---|
1101 | int, void *),
|
---|
1102 | void *private_data,
|
---|
1103 | enum ctdb_event call,
|
---|
1104 | const char *fmt, ...) PRINTF_ATTRIBUTE(6,7);
|
---|
1105 |
|
---|
1106 | int ctdb_event_script_args(struct ctdb_context *ctdb,
|
---|
1107 | enum ctdb_event call,
|
---|
1108 | const char *fmt, ...) PRINTF_ATTRIBUTE(3,4);
|
---|
1109 |
|
---|
1110 | int ctdb_event_script(struct ctdb_context *ctdb,
|
---|
1111 | enum ctdb_event call);
|
---|
1112 |
|
---|
1113 | int32_t ctdb_run_eventscripts(struct ctdb_context *ctdb,
|
---|
1114 | struct ctdb_req_control_old *c,
|
---|
1115 | TDB_DATA data, bool *async_reply);
|
---|
1116 |
|
---|
1117 | int32_t ctdb_control_enable_script(struct ctdb_context *ctdb, TDB_DATA indata);
|
---|
1118 | int32_t ctdb_control_disable_script(struct ctdb_context *ctdb, TDB_DATA indata);
|
---|
1119 |
|
---|
1120 | #endif
|
---|