smbd: Remove an unused parameter from defer_open()
[Samba.git] / ctdb / client / client_control_sync.c
blobe56a2b2f18d506f2db5782db4f7c821f916c696f
1 /*
2 CTDB client code
4 Copyright (C) Amitay Isaacs 2015
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, see <http://www.gnu.org/licenses/>.
20 #include "replace.h"
21 #include "system/network.h"
22 #include "system/filesys.h"
24 #include <talloc.h>
25 #include <tevent.h>
26 #include <tdb.h>
28 #include "common/logging.h"
30 #include "lib/util/debug.h"
32 #include "protocol/protocol.h"
33 #include "protocol/protocol_api.h"
34 #include "client/client_private.h"
35 #include "client/client.h"
36 #include "client/client_sync.h"
38 int ctdb_ctrl_process_exists(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
39 struct ctdb_client_context *client,
40 int destnode, struct timeval timeout,
41 pid_t pid, int *status)
43 struct ctdb_req_control request;
44 struct ctdb_reply_control *reply;
45 int ret;
47 ctdb_req_control_process_exists(&request, pid);
48 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
49 &request, &reply);
50 if (ret != 0) {
51 DEBUG(DEBUG_ERR,
52 ("Control PROCESS_EXISTS failed to node %u, ret=%d\n",
53 destnode, ret));
54 return ret;
57 ret = ctdb_reply_control_process_exists(reply, status);
58 if (ret != 0) {
59 DEBUG(DEBUG_ERR,
60 ("Control PROCESS_EXISTS failed, ret=%d\n", ret));
61 return ret;
64 return 0;
67 int ctdb_ctrl_statistics(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
68 struct ctdb_client_context *client,
69 int destnode, struct timeval timeout,
70 struct ctdb_statistics **stats)
72 struct ctdb_req_control request;
73 struct ctdb_reply_control *reply;
74 int ret;
76 ctdb_req_control_statistics(&request);
77 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
78 &request, &reply);
79 if (ret != 0) {
80 DEBUG(DEBUG_ERR,
81 ("Control STATISTICS failed to node %u, ret=%d\n",
82 destnode, ret));
83 return ret;
86 ret = ctdb_reply_control_statistics(reply, mem_ctx, stats);
87 if (ret != 0) {
88 DEBUG(DEBUG_ERR,
89 ("Control STATISTICS failed, ret=%d\n", ret));
90 return ret;
93 return 0;
96 int ctdb_ctrl_ping(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
97 struct ctdb_client_context *client,
98 int destnode, struct timeval timeout,
99 int *num_clients)
101 struct ctdb_req_control request;
102 struct ctdb_reply_control *reply;
103 int ret;
105 ctdb_req_control_ping(&request);
106 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
107 &request, &reply);
108 if (ret != 0) {
109 DEBUG(DEBUG_ERR,
110 ("Control PING failed to node %u, ret=%d\n",
111 destnode, ret));
112 return ret;
115 ret = ctdb_reply_control_ping(reply, num_clients);
116 if (ret != 0) {
117 DEBUG(DEBUG_ERR,
118 ("Control PING failed, ret=%d\n", ret));
119 return ret;
122 return 0;
125 int ctdb_ctrl_getdbpath(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
126 struct ctdb_client_context *client,
127 int destnode, struct timeval timeout,
128 uint32_t db_id,
129 const char **db_path)
131 struct ctdb_req_control request;
132 struct ctdb_reply_control *reply;
133 int ret;
135 ctdb_req_control_getdbpath(&request, db_id);
136 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
137 &request, &reply);
138 if (ret != 0) {
139 DEBUG(DEBUG_ERR,
140 ("Control GETDBPATH failed to node %u, ret=%d\n",
141 destnode, ret));
142 return ret;
145 ret = ctdb_reply_control_getdbpath(reply, mem_ctx, db_path);
146 if (ret != 0) {
147 DEBUG(DEBUG_ERR,
148 ("Control GETDBPATH failed, ret=%d\n", ret));
149 return ret;
152 return 0;
155 int ctdb_ctrl_getvnnmap(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
156 struct ctdb_client_context *client,
157 int destnode, struct timeval timeout,
158 struct ctdb_vnn_map **vnnmap)
160 struct ctdb_req_control request;
161 struct ctdb_reply_control *reply;
162 int ret;
164 ctdb_req_control_getvnnmap(&request);
165 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
166 &request, &reply);
167 if (ret != 0) {
168 DEBUG(DEBUG_ERR,
169 ("Control GETVNNMAP failed to node %u, ret=%d\n",
170 destnode, ret));
171 return ret;
174 ret = ctdb_reply_control_getvnnmap(reply, mem_ctx, vnnmap);
175 if (ret != 0) {
176 DEBUG(DEBUG_ERR,
177 ("Control GETVNNMAP failed, ret=%d\n", ret));
178 return ret;
181 return 0;
184 int ctdb_ctrl_getdebug(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
185 struct ctdb_client_context *client,
186 int destnode, struct timeval timeout,
187 int *loglevel)
189 struct ctdb_req_control request;
190 struct ctdb_reply_control *reply;
191 int ret;
193 ctdb_req_control_get_debug(&request);
194 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
195 &request, &reply);
196 if (ret != 0) {
197 DEBUG(DEBUG_ERR,
198 ("Control GET_DEBUG failed to node %u, ret=%d\n",
199 destnode, ret));
200 return ret;
203 ret = ctdb_reply_control_get_debug(reply, loglevel);
204 if (ret != 0) {
205 DEBUG(DEBUG_ERR,
206 ("Control GET_DEBUG failed, ret=%d\n", ret));
207 return ret;
210 return 0;
213 int ctdb_ctrl_setdebug(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
214 struct ctdb_client_context *client,
215 int destnode, struct timeval timeout,
216 int loglevel)
218 struct ctdb_req_control request;
219 struct ctdb_reply_control *reply;
220 int ret;
222 ctdb_req_control_set_debug(&request, loglevel);
223 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
224 &request, &reply);
225 if (ret != 0) {
226 DEBUG(DEBUG_ERR,
227 ("Control SET_DEBUG failed to node %u, ret=%d\n",
228 destnode, ret));
229 return ret;
232 ret = ctdb_reply_control_set_debug(reply);
233 if (ret != 0) {
234 DEBUG(DEBUG_ERR,
235 ("Control SET_DEBUG failed, ret=%d\n", ret));
236 return ret;
239 return 0;
242 int ctdb_ctrl_get_dbmap(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
243 struct ctdb_client_context *client,
244 int destnode, struct timeval timeout,
245 struct ctdb_dbid_map **dbmap)
247 struct ctdb_req_control request;
248 struct ctdb_reply_control *reply;
249 int ret;
251 ctdb_req_control_get_dbmap(&request);
252 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
253 &request, &reply);
254 if (ret != 0) {
255 DEBUG(DEBUG_ERR,
256 ("Control GET_DBMAP failed to node %u, ret=%d\n",
257 destnode, ret));
258 return ret;
261 ret = ctdb_reply_control_get_dbmap(reply, mem_ctx, dbmap);
262 if (ret != 0) {
263 DEBUG(DEBUG_ERR,
264 ("Control GET_DBMAP failed, ret=%d\n", ret));
265 return ret;
268 return 0;
271 int ctdb_ctrl_pull_db(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
272 struct ctdb_client_context *client, int destnode,
273 struct timeval timeout, struct ctdb_pulldb *pulldb,
274 struct ctdb_rec_buffer **recbuf)
276 struct ctdb_req_control request;
277 struct ctdb_reply_control *reply;
278 int ret;
280 ctdb_req_control_pull_db(&request, pulldb);
281 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
282 &request, &reply);
283 if (ret != 0) {
284 DEBUG(DEBUG_ERR,
285 ("Control PULL_DB failed to node %u, ret=%d\n",
286 destnode, ret));
287 return ret;
290 ret = ctdb_reply_control_pull_db(reply, mem_ctx, recbuf);
291 if (ret != 0) {
292 DEBUG(DEBUG_ERR,
293 ("Control PULL_DB failed, ret=%d\n", ret));
294 return ret;
297 return 0;
300 int ctdb_ctrl_push_db(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
301 struct ctdb_client_context *client, int destnode,
302 struct timeval timeout, struct ctdb_rec_buffer *recbuf)
304 struct ctdb_req_control request;
305 struct ctdb_reply_control *reply;
306 int ret;
308 ctdb_req_control_push_db(&request, recbuf);
309 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
310 &request, &reply);
311 if (ret != 0) {
312 DEBUG(DEBUG_ERR,
313 ("Control PUSH_DB failed to node %u, ret=%d\n",
314 destnode, ret));
315 return ret;
318 ret = ctdb_reply_control_push_db(reply);
319 if (ret != 0) {
320 DEBUG(DEBUG_ERR,
321 ("Control PUSH_DB failed, ret=%d\n", ret));
322 return ret;
325 return 0;
329 int ctdb_ctrl_get_recmode(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
330 struct ctdb_client_context *client,
331 int destnode, struct timeval timeout,
332 int *recmode)
334 struct ctdb_req_control request;
335 struct ctdb_reply_control *reply;
336 int ret;
338 ctdb_req_control_get_recmode(&request);
339 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
340 &request, &reply);
341 if (ret != 0) {
342 DEBUG(DEBUG_ERR,
343 ("Control GET_RECMODE failed to node %u, ret=%d\n",
344 destnode, ret));
345 return ret;
348 ret = ctdb_reply_control_get_recmode(reply, recmode);
349 if (ret != 0) {
350 DEBUG(DEBUG_ERR,
351 ("Control GET_RECMODE failed, ret=%d\n", ret));
352 return ret;
355 return 0;
358 int ctdb_ctrl_set_recmode(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
359 struct ctdb_client_context *client,
360 int destnode, struct timeval timeout,
361 int recmode)
363 struct ctdb_req_control request;
364 struct ctdb_reply_control *reply;
365 int ret;
367 ctdb_req_control_set_recmode(&request, recmode);
368 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
369 &request, &reply);
370 if (ret != 0) {
371 DEBUG(DEBUG_ERR,
372 ("Control SET_RECMODE failed to node %u, ret=%d\n",
373 destnode, ret));
374 return ret;
377 ret = ctdb_reply_control_set_recmode(reply);
378 if (ret != 0) {
379 DEBUG(DEBUG_ERR,
380 ("Control SET_RECMODE failed, ret=%d\n", ret));
381 return ret;
384 return 0;
387 int ctdb_ctrl_statistics_reset(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
388 struct ctdb_client_context *client,
389 int destnode, struct timeval timeout)
391 struct ctdb_req_control request;
392 struct ctdb_reply_control *reply;
393 int ret;
395 ctdb_req_control_statistics_reset(&request);
396 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
397 &request, &reply);
398 if (ret != 0) {
399 DEBUG(DEBUG_ERR,
400 ("Control STATISTICS_RESET failed to node %u, ret=%d\n",
401 destnode, ret));
402 return ret;
405 ret = ctdb_reply_control_statistics_reset(reply);
406 if (ret != 0) {
407 DEBUG(DEBUG_ERR,
408 ("Control STATISTICS_RESET failed, ret=%d\n", ret));
409 return ret;
412 return 0;
415 int ctdb_ctrl_db_attach(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
416 struct ctdb_client_context *client,
417 int destnode, struct timeval timeout,
418 const char *db_name, uint32_t *db_id)
420 struct ctdb_req_control request;
421 struct ctdb_reply_control *reply;
422 int ret;
424 ctdb_req_control_db_attach(&request, db_name);
425 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
426 &request, &reply);
427 if (ret != 0) {
428 DEBUG(DEBUG_ERR,
429 ("Control DB_ATTACH failed to node %u, ret=%d\n",
430 destnode, ret));
431 return ret;
434 ret = ctdb_reply_control_db_attach(reply, db_id);
435 if (ret != 0) {
436 DEBUG(DEBUG_ERR,
437 ("Control DB_ATTACH failed, ret=%d\n", ret));
438 return ret;
441 return 0;
444 int ctdb_ctrl_traverse_start(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
445 struct ctdb_client_context *client,
446 int destnode, struct timeval timeout,
447 struct ctdb_traverse_start *traverse)
449 struct ctdb_req_control request;
450 struct ctdb_reply_control *reply;
451 int ret;
453 ctdb_req_control_traverse_start(&request, traverse);
454 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
455 &request, &reply);
456 if (ret != 0) {
457 DEBUG(DEBUG_ERR,
458 ("Control TRAVERSE_START failed to node %u, ret=%d\n",
459 destnode, ret));
460 return ret;
463 ret = ctdb_reply_control_traverse_start(reply);
464 if (ret != 0) {
465 DEBUG(DEBUG_ERR,
466 ("Control TRAVERSE_START failed, ret=%d\n", ret));
467 return ret;
470 return 0;
473 int ctdb_ctrl_register_srvid(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
474 struct ctdb_client_context *client,
475 int destnode, struct timeval timeout,
476 uint64_t srvid)
478 struct ctdb_req_control request;
479 struct ctdb_reply_control *reply;
480 int ret;
482 ctdb_req_control_register_srvid(&request, srvid);
483 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
484 &request, &reply);
485 if (ret != 0) {
486 DEBUG(DEBUG_ERR,
487 ("Control REGISTER_SRVID failed to node %u, ret=%d\n",
488 destnode, ret));
489 return ret;
492 ret = ctdb_reply_control_register_srvid(reply);
493 if (ret != 0) {
494 DEBUG(DEBUG_ERR,
495 ("Control REGISTER_SRVID failed, ret=%d\n", ret));
496 return ret;
499 return 0;
502 int ctdb_ctrl_deregister_srvid(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
503 struct ctdb_client_context *client,
504 int destnode, struct timeval timeout,
505 uint64_t srvid)
507 struct ctdb_req_control request;
508 struct ctdb_reply_control *reply;
509 int ret;
511 ctdb_req_control_deregister_srvid(&request, srvid);
512 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
513 &request, &reply);
514 if (ret != 0) {
515 DEBUG(DEBUG_ERR,
516 ("Control DEREGISTER_SRVID failed to node %u, ret=%d\n",
517 destnode, ret));
518 return ret;
521 ret = ctdb_reply_control_deregister_srvid(reply);
522 if (ret != 0) {
523 DEBUG(DEBUG_ERR,
524 ("Control DEREGISTER_SRVID failed, ret=%d\n", ret));
525 return ret;
528 return 0;
531 int ctdb_ctrl_get_dbname(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
532 struct ctdb_client_context *client,
533 int destnode, struct timeval timeout,
534 uint32_t db_id, const char **db_name)
536 struct ctdb_req_control request;
537 struct ctdb_reply_control *reply;
538 int ret;
540 ctdb_req_control_get_dbname(&request, db_id);
541 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
542 &request, &reply);
543 if (ret != 0) {
544 DEBUG(DEBUG_ERR,
545 ("Control GET_DBNAME failed to node %u, ret=%d\n",
546 destnode, ret));
547 return ret;
550 ret = ctdb_reply_control_get_dbname(reply, mem_ctx, db_name);
551 if (ret != 0) {
552 DEBUG(DEBUG_ERR,
553 ("Control GET_DBNAME failed, ret=%d\n", ret));
554 return ret;
557 return 0;
560 int ctdb_ctrl_enable_seqnum(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
561 struct ctdb_client_context *client,
562 int destnode, struct timeval timeout,
563 uint32_t db_id)
565 struct ctdb_req_control request;
566 struct ctdb_reply_control *reply;
567 int ret;
569 ctdb_req_control_enable_seqnum(&request, db_id);
570 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
571 &request, &reply);
572 if (ret != 0) {
573 DEBUG(DEBUG_ERR,
574 ("Control ENABLE_SEQNUM failed to node %u, ret=%d\n",
575 destnode, ret));
576 return ret;
579 ret = ctdb_reply_control_enable_seqnum(reply);
580 if (ret != 0) {
581 DEBUG(DEBUG_ERR,
582 ("Control ENABLE_SEQNUM failed, ret=%d\n", ret));
583 return ret;
586 return 0;
589 int ctdb_ctrl_update_seqnum(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
590 struct ctdb_client_context *client,
591 int destnode, struct timeval timeout,
592 uint32_t db_id)
594 struct ctdb_req_control request;
595 struct ctdb_reply_control *reply;
596 int ret;
598 ctdb_req_control_update_seqnum(&request, db_id);
599 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
600 &request, &reply);
601 if (ret != 0) {
602 DEBUG(DEBUG_ERR,
603 ("Control UPDATE_SEQNUM failed to node %u, ret=%d\n",
604 destnode, ret));
605 return ret;
608 ret = ctdb_reply_control_update_seqnum(reply);
609 if (ret != 0) {
610 DEBUG(DEBUG_ERR,
611 ("Control UPDATE_SEQNUM failed, ret=%d\n", ret));
612 return ret;
615 return 0;
618 int ctdb_ctrl_dump_memory(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
619 struct ctdb_client_context *client,
620 int destnode, struct timeval timeout,
621 const char **mem_str)
623 struct ctdb_req_control request;
624 struct ctdb_reply_control *reply;
625 int ret;
627 ctdb_req_control_dump_memory(&request);
628 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
629 &request, &reply);
630 if (ret != 0) {
631 DEBUG(DEBUG_ERR,
632 ("Control DUMP_MEMORY failed to node %u, ret=%d\n",
633 destnode, ret));
634 return ret;
637 ret = ctdb_reply_control_dump_memory(reply, mem_ctx, mem_str);
638 if (ret != 0) {
639 DEBUG(DEBUG_ERR,
640 ("Control DUMP_MEMORY failed, ret=%d\n", ret));
641 return ret;
644 return 0;
647 int ctdb_ctrl_get_pid(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
648 struct ctdb_client_context *client,
649 int destnode, struct timeval timeout,
650 pid_t *pid)
652 struct ctdb_req_control request;
653 struct ctdb_reply_control *reply;
654 int ret;
656 ctdb_req_control_get_pid(&request);
657 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
658 &request, &reply);
659 if (ret != 0) {
660 DEBUG(DEBUG_ERR,
661 ("Control GET_PID failed to node %u, ret=%d\n",
662 destnode, ret));
663 return ret;
666 ret = ctdb_reply_control_get_pid(reply, pid);
667 if (ret != 0) {
668 DEBUG(DEBUG_ERR,
669 ("Control GET_PID failed, ret=%d\n", ret));
670 return ret;
673 return 0;
676 int ctdb_ctrl_get_recmaster(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
677 struct ctdb_client_context *client,
678 int destnode, struct timeval timeout,
679 uint32_t *recmaster)
681 struct ctdb_req_control request;
682 struct ctdb_reply_control *reply;
683 int ret;
685 ctdb_req_control_get_recmaster(&request);
686 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
687 &request, &reply);
688 if (ret != 0) {
689 DEBUG(DEBUG_ERR,
690 ("Control GET_RECMASTER failed to node %u, ret=%d\n",
691 destnode, ret));
692 return ret;
695 ret = ctdb_reply_control_get_recmaster(reply, recmaster);
696 if (ret != 0) {
697 DEBUG(DEBUG_ERR,
698 ("Control GET_RECMASTER failed, ret=%d\n", ret));
699 return ret;
702 return 0;
705 int ctdb_ctrl_set_recmaster(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
706 struct ctdb_client_context *client,
707 int destnode, struct timeval timeout,
708 uint32_t recmaster)
710 struct ctdb_req_control request;
711 struct ctdb_reply_control *reply;
712 int ret;
714 ctdb_req_control_set_recmaster(&request, recmaster);
715 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
716 &request, &reply);
717 if (ret != 0) {
718 DEBUG(DEBUG_ERR,
719 ("Control SET_RECMASTER failed to node %u, ret=%d\n",
720 destnode, ret));
721 return ret;
724 ret = ctdb_reply_control_set_recmaster(reply);
725 if (ret != 0) {
726 DEBUG(DEBUG_ERR,
727 ("Control SET_RECMASTER failed, ret=%d\n", ret));
728 return ret;
731 return 0;
734 int ctdb_ctrl_freeze(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
735 struct ctdb_client_context *client,
736 int destnode, struct timeval timeout,
737 int priority)
739 struct ctdb_req_control request;
740 struct ctdb_reply_control *reply;
741 int ret;
743 ctdb_req_control_freeze(&request, priority);
744 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
745 &request, &reply);
746 if (ret != 0) {
747 DEBUG(DEBUG_ERR,
748 ("Control FREEZE failed to node %u, ret=%d\n",
749 destnode, ret));
750 return ret;
753 ret = ctdb_reply_control_freeze(reply);
754 if (ret != 0) {
755 DEBUG(DEBUG_ERR,
756 ("Control FREEZE failed, ret=%d\n", ret));
757 return ret;
760 return 0;
763 int ctdb_ctrl_get_pnn(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
764 struct ctdb_client_context *client,
765 int destnode, struct timeval timeout,
766 uint32_t *pnn)
768 struct ctdb_req_control request;
769 struct ctdb_reply_control *reply;
770 int ret;
772 ctdb_req_control_get_pnn(&request);
773 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
774 &request, &reply);
775 if (ret != 0) {
776 DEBUG(DEBUG_ERR,
777 ("Control GET_PNN failed to node %u, ret=%d\n",
778 destnode, ret));
779 return ret;
782 ret = ctdb_reply_control_get_pnn(reply, pnn);
783 if (ret != 0) {
784 DEBUG(DEBUG_ERR,
785 ("Control GET_PNN failed, ret=%d\n", ret));
786 return ret;
789 return 0;
792 int ctdb_ctrl_shutdown(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
793 struct ctdb_client_context *client,
794 int destnode, struct timeval timeout)
796 struct ctdb_req_control request;
797 struct ctdb_reply_control *reply;
798 int ret;
800 ctdb_req_control_shutdown(&request);
801 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
802 &request, &reply);
803 if (ret != 0) {
804 DEBUG(DEBUG_ERR,
805 ("Control SHUTDOWN failed to node %u, ret=%d\n",
806 destnode, ret));
807 return ret;
810 ret = ctdb_reply_control_shutdown(reply);
811 if (ret != 0) {
812 DEBUG(DEBUG_ERR,
813 ("Control SHUTDOWN failed, ret=%d\n", ret));
814 return ret;
817 return 0;
820 int ctdb_ctrl_tcp_add(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
821 struct ctdb_client_context *client,
822 int destnode, struct timeval timeout,
823 struct ctdb_connection *conn)
825 struct ctdb_req_control request;
826 struct ctdb_reply_control *reply;
827 int ret;
829 ctdb_req_control_tcp_add(&request, conn);
830 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
831 &request, &reply);
832 if (ret != 0) {
833 DEBUG(DEBUG_ERR,
834 ("Control TCP_ADD failed to node %u, ret=%d\n",
835 destnode, ret));
836 return ret;
839 ret = ctdb_reply_control_tcp_add(reply);
840 if (ret != 0) {
841 DEBUG(DEBUG_ERR,
842 ("Control TCP_ADD failed, ret=%d\n", ret));
843 return ret;
846 return 0;
849 int ctdb_ctrl_tcp_remove(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
850 struct ctdb_client_context *client,
851 int destnode, struct timeval timeout,
852 struct ctdb_connection *conn)
854 struct ctdb_req_control request;
855 struct ctdb_reply_control *reply;
856 int ret;
858 ctdb_req_control_tcp_remove(&request, conn);
859 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
860 &request, &reply);
861 if (ret != 0) {
862 DEBUG(DEBUG_ERR,
863 ("Control TCP_REMOVE failed to node %u, ret=%d\n",
864 destnode, ret));
865 return ret;
868 ret = ctdb_reply_control_tcp_remove(reply);
869 if (ret != 0) {
870 DEBUG(DEBUG_ERR,
871 ("Control TCP_REMOVE failed, ret=%d\n", ret));
872 return ret;
875 return 0;
878 int ctdb_ctrl_set_tunable(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
879 struct ctdb_client_context *client,
880 int destnode, struct timeval timeout,
881 struct ctdb_tunable *tunable)
883 struct ctdb_req_control request;
884 struct ctdb_reply_control *reply;
885 int ret;
887 ctdb_req_control_set_tunable(&request, tunable);
888 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
889 &request, &reply);
890 if (ret != 0) {
891 DEBUG(DEBUG_ERR,
892 ("Control SET_TUNABLE failed to node %u, ret=%d\n",
893 destnode, ret));
894 return ret;
897 ret = ctdb_reply_control_set_tunable(reply);
898 if (ret != 0) {
899 DEBUG(DEBUG_ERR,
900 ("Control SET_TUNABLE failed, ret=%d\n", ret));
901 return ret;
904 return 0;
907 int ctdb_ctrl_get_tunable(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
908 struct ctdb_client_context *client,
909 int destnode, struct timeval timeout,
910 const char *var, uint32_t *value)
912 struct ctdb_req_control request;
913 struct ctdb_reply_control *reply;
914 int ret;
916 ctdb_req_control_get_tunable(&request, var);
917 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
918 &request, &reply);
919 if (ret != 0) {
920 DEBUG(DEBUG_ERR,
921 ("Control GET_TUNABLE failed to node %u, ret=%d\n",
922 destnode, ret));
923 return ret;
926 ret = ctdb_reply_control_get_tunable(reply, value);
927 if (ret != 0) {
928 DEBUG(DEBUG_ERR,
929 ("Control GET_TUNABLE failed, ret=%d\n", ret));
930 return ret;
933 return 0;
936 int ctdb_ctrl_list_tunables(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
937 struct ctdb_client_context *client,
938 int destnode, struct timeval timeout,
939 struct ctdb_var_list **var_list)
941 struct ctdb_req_control request;
942 struct ctdb_reply_control *reply;
943 int ret;
945 ctdb_req_control_list_tunables(&request);
946 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
947 &request, &reply);
948 if (ret != 0) {
949 DEBUG(DEBUG_ERR,
950 ("Control LIST_TUNABLES failed to node %u, ret=%d\n",
951 destnode, ret));
952 return ret;
955 ret = ctdb_reply_control_list_tunables(reply, mem_ctx, var_list);
956 if (ret != 0) {
957 DEBUG(DEBUG_ERR,
958 ("Control LIST_TUNABLES failed, ret=%d\n", ret));
959 return ret;
962 return 0;
965 int ctdb_ctrl_modify_flags(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
966 struct ctdb_client_context *client,
967 int destnode, struct timeval timeout,
968 uint32_t pnn, uint32_t old_flags,
969 uint32_t new_flags)
971 struct ctdb_req_control request;
972 struct ctdb_reply_control *reply;
973 struct ctdb_node_flag_change flag_change;
974 int ret;
976 flag_change.pnn = pnn;
977 flag_change.old_flags = old_flags;
978 flag_change.new_flags = new_flags;
980 ctdb_req_control_modify_flags(&request, &flag_change);
981 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
982 &request, &reply);
983 if (ret != 0) {
984 DEBUG(DEBUG_ERR,
985 ("Control MODIFY_FLAGS failed to node %u, ret=%d\n",
986 destnode, ret));
987 return ret;
990 ret = ctdb_reply_control_modify_flags(reply);
991 if (ret != 0) {
992 DEBUG(DEBUG_ERR,
993 ("Control MODIFY_FLAGS failed, ret=%d\n", ret));
994 return ret;
997 return 0;
1000 int ctdb_ctrl_get_all_tunables(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
1001 struct ctdb_client_context *client,
1002 int destnode, struct timeval timeout,
1003 struct ctdb_tunable_list **tun_list)
1005 struct ctdb_req_control request;
1006 struct ctdb_reply_control *reply;
1007 int ret;
1009 ctdb_req_control_get_all_tunables(&request);
1010 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
1011 &request, &reply);
1012 if (ret != 0) {
1013 DEBUG(DEBUG_ERR,
1014 ("Control GET_ALL_TUNABLES failed to node %u, ret=%d\n",
1015 destnode, ret));
1016 return ret;
1019 ret = ctdb_reply_control_get_all_tunables(reply, mem_ctx, tun_list);
1020 if (ret != 0) {
1021 DEBUG(DEBUG_ERR,
1022 ("Control GET_ALL_TUNABLES failed, ret=%d\n", ret));
1023 return ret;
1026 return 0;
1029 int ctdb_ctrl_get_tcp_tickle_list(TALLOC_CTX *mem_ctx,
1030 struct tevent_context *ev,
1031 struct ctdb_client_context *client,
1032 int destnode, struct timeval timeout,
1033 ctdb_sock_addr *addr,
1034 struct ctdb_tickle_list **tickles)
1036 struct ctdb_req_control request;
1037 struct ctdb_reply_control *reply;
1038 int ret;
1040 ctdb_req_control_get_tcp_tickle_list(&request, addr);
1041 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
1042 &request, &reply);
1043 if (ret != 0) {
1044 DEBUG(DEBUG_ERR,
1045 ("Control GET_TCP_TICKLE_LIST failed to node %u, ret=%d\n",
1046 destnode, ret));
1047 return ret;
1050 ret = ctdb_reply_control_get_tcp_tickle_list(reply, mem_ctx, tickles);
1051 if (ret != 0) {
1052 DEBUG(DEBUG_ERR,
1053 ("Control GET_TCP_TICKLE_LIST failed, ret=%d\n", ret));
1054 return ret;
1057 return 0;
1060 int ctdb_ctrl_set_tcp_tickle_list(TALLOC_CTX *mem_ctx,
1061 struct tevent_context *ev,
1062 struct ctdb_client_context *client,
1063 int destnode, struct timeval timeout,
1064 struct ctdb_tickle_list *tickles)
1066 struct ctdb_req_control request;
1067 struct ctdb_reply_control *reply;
1068 int ret;
1070 ctdb_req_control_set_tcp_tickle_list(&request, tickles);
1071 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
1072 &request, &reply);
1073 if (ret != 0) {
1074 DEBUG(DEBUG_ERR,
1075 ("Control SET_TCP_TICKLE_LIST failed to node %u, ret=%d\n",
1076 destnode, ret));
1077 return ret;
1080 ret = ctdb_reply_control_set_tcp_tickle_list(reply);
1081 if (ret != 0) {
1082 DEBUG(DEBUG_ERR,
1083 ("Control SET_TCP_TICKLE_LIST failed, ret=%d\n", ret));
1084 return ret;
1087 return 0;
1090 int ctdb_ctrl_db_attach_persistent(TALLOC_CTX *mem_ctx,
1091 struct tevent_context *ev,
1092 struct ctdb_client_context *client,
1093 int destnode, struct timeval timeout,
1094 const char *db_name, uint32_t *db_id)
1096 struct ctdb_req_control request;
1097 struct ctdb_reply_control *reply;
1098 int ret;
1100 ctdb_req_control_db_attach_persistent(&request, db_name);
1101 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
1102 &request, &reply);
1103 if (ret != 0) {
1104 DEBUG(DEBUG_ERR,
1105 ("Control DB_ATTACH_PERSISTENT failed to node %u, ret=%d\n",
1106 destnode, ret));
1107 return ret;
1110 ret = ctdb_reply_control_db_attach_persistent(reply, db_id);
1111 if (ret != 0) {
1112 DEBUG(DEBUG_ERR,
1113 ("Control DB_ATTACH_PERSISTENT failed, ret=%d\n", ret));
1114 return ret;
1117 return 0;
1120 int ctdb_ctrl_send_gratuitous_arp(TALLOC_CTX *mem_ctx,
1121 struct tevent_context *ev,
1122 struct ctdb_client_context *client,
1123 int destnode, struct timeval timeout,
1124 struct ctdb_addr_info *addr_info)
1126 struct ctdb_req_control request;
1127 struct ctdb_reply_control *reply;
1128 int ret;
1130 ctdb_req_control_send_gratuitous_arp(&request, addr_info);
1131 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
1132 &request, &reply);
1133 if (ret != 0) {
1134 DEBUG(DEBUG_ERR,
1135 ("Control SEND_GRATUITOUS_ARP failed to node %u, ret=%d\n",
1136 destnode, ret));
1137 return ret;
1140 ret = ctdb_reply_control_send_gratuitous_arp(reply);
1141 if (ret != 0) {
1142 DEBUG(DEBUG_ERR,
1143 ("Control SEND_GRATUITOUS_ARP failed, ret=%d\n", ret));
1144 return ret;
1147 return 0;
1150 int ctdb_ctrl_wipe_database(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
1151 struct ctdb_client_context *client,
1152 int destnode, struct timeval timeout,
1153 uint32_t db_id, uint32_t tid)
1155 struct ctdb_req_control request;
1156 struct ctdb_reply_control *reply;
1157 struct ctdb_transdb transdb;
1158 int ret;
1160 transdb.db_id = db_id;
1161 transdb.tid = tid;
1163 ctdb_req_control_wipe_database(&request, &transdb);
1164 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
1165 &request, &reply);
1166 if (ret != 0) {
1167 DEBUG(DEBUG_ERR,
1168 ("Control WIPE_DATABASE failed to node %u, ret=%d\n",
1169 destnode, ret));
1170 return ret;
1173 ret = ctdb_reply_control_wipe_database(reply);
1174 if (ret != 0) {
1175 DEBUG(DEBUG_ERR,
1176 ("Control WIPE_DATABASE failed, ret=%d\n", ret));
1177 return ret;
1180 return 0;
1183 int ctdb_ctrl_uptime(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
1184 struct ctdb_client_context *client,
1185 int destnode, struct timeval timeout,
1186 struct ctdb_uptime **uptime)
1188 struct ctdb_req_control request;
1189 struct ctdb_reply_control *reply;
1190 int ret;
1192 ctdb_req_control_uptime(&request);
1193 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
1194 &request, &reply);
1195 if (ret != 0) {
1196 DEBUG(DEBUG_ERR,
1197 ("Control UPTIME failed to node %u, ret=%d\n",
1198 destnode, ret));
1199 return ret;
1202 ret = ctdb_reply_control_uptime(reply, mem_ctx, uptime);
1203 if (ret != 0) {
1204 DEBUG(DEBUG_ERR,
1205 ("Control UPTIME failed, ret=%d\n", ret));
1206 return ret;
1209 return 0;
1212 int ctdb_ctrl_start_recovery(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
1213 struct ctdb_client_context *client,
1214 int destnode, struct timeval timeout)
1216 struct ctdb_req_control request;
1217 struct ctdb_reply_control *reply;
1218 int ret;
1220 ctdb_req_control_start_recovery(&request);
1221 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
1222 &request, &reply);
1223 if (ret != 0) {
1224 DEBUG(DEBUG_ERR,
1225 ("Control START_RECOVERY failed to node %u, ret=%d\n",
1226 destnode, ret));
1227 return ret;
1230 ret = ctdb_reply_control_start_recovery(reply);
1231 if (ret != 0) {
1232 DEBUG(DEBUG_ERR,
1233 ("Control START_RECOVERY failed, ret=%d\n", ret));
1234 return ret;
1237 return 0;
1240 int ctdb_ctrl_end_recovery(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
1241 struct ctdb_client_context *client,
1242 int destnode, struct timeval timeout)
1244 struct ctdb_req_control request;
1245 struct ctdb_reply_control *reply;
1246 int ret;
1248 ctdb_req_control_end_recovery(&request);
1249 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
1250 &request, &reply);
1251 if (ret != 0) {
1252 DEBUG(DEBUG_ERR,
1253 ("Control END_RECOVERY failed to node %u, ret=%d\n",
1254 destnode, ret));
1255 return ret;
1258 ret = ctdb_reply_control_end_recovery(reply);
1259 if (ret != 0) {
1260 DEBUG(DEBUG_ERR,
1261 ("Control END_RECOVERY failed, ret=%d\n", ret));
1262 return ret;
1265 return 0;
1268 int ctdb_ctrl_reload_nodes_file(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
1269 struct ctdb_client_context *client,
1270 int destnode, struct timeval timeout)
1272 struct ctdb_req_control request;
1273 struct ctdb_reply_control *reply;
1274 int ret;
1276 ctdb_req_control_reload_nodes_file(&request);
1277 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
1278 &request, &reply);
1279 if (ret != 0) {
1280 DEBUG(DEBUG_ERR,
1281 ("Control RELOAD_NODES_FILE failed to node %u, ret=%d\n",
1282 destnode, ret));
1283 return ret;
1286 ret = ctdb_reply_control_reload_nodes_file(reply);
1287 if (ret != 0) {
1288 DEBUG(DEBUG_ERR,
1289 ("Control RELOAD_NODES_FILE failed, ret=%d\n", ret));
1290 return ret;
1293 return 0;
1296 int ctdb_ctrl_add_public_ip(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
1297 struct ctdb_client_context *client,
1298 int destnode, struct timeval timeout,
1299 struct ctdb_addr_info *addr_info)
1301 struct ctdb_req_control request;
1302 struct ctdb_reply_control *reply;
1303 int ret;
1305 ctdb_req_control_add_public_ip(&request, addr_info);
1306 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
1307 &request, &reply);
1308 if (ret != 0) {
1309 DEBUG(DEBUG_ERR,
1310 ("Control ADD_PUBLIC_IP failed to node %u, ret=%d\n",
1311 destnode, ret));
1312 return ret;
1315 ret = ctdb_reply_control_add_public_ip(reply);
1316 if (ret != 0) {
1317 DEBUG(DEBUG_ERR,
1318 ("Control ADD_PUBLIC_IP failed, ret=%d\n", ret));
1319 return ret;
1322 return 0;
1325 int ctdb_ctrl_del_public_ip(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
1326 struct ctdb_client_context *client,
1327 int destnode, struct timeval timeout,
1328 struct ctdb_addr_info *addr_info)
1330 struct ctdb_req_control request;
1331 struct ctdb_reply_control *reply;
1332 int ret;
1334 ctdb_req_control_del_public_ip(&request, addr_info);
1335 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
1336 &request, &reply);
1337 if (ret != 0) {
1338 DEBUG(DEBUG_ERR,
1339 ("Control DEL_PUBLIC_IP failed to node %u, ret=%d\n",
1340 destnode, ret));
1341 return ret;
1344 ret = ctdb_reply_control_del_public_ip(reply);
1345 if (ret != 0) {
1346 DEBUG(DEBUG_ERR,
1347 ("Control DEL_PUBLIC_IP failed, ret=%d\n", ret));
1348 return ret;
1351 return 0;
1354 int ctdb_ctrl_get_capabilities(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
1355 struct ctdb_client_context *client,
1356 int destnode, struct timeval timeout,
1357 uint32_t *caps)
1359 struct ctdb_req_control request;
1360 struct ctdb_reply_control *reply;
1361 int ret;
1363 ctdb_req_control_get_capabilities(&request);
1364 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
1365 &request, &reply);
1366 if (ret != 0) {
1367 DEBUG(DEBUG_ERR,
1368 ("Control GET_CAPABILITIES failed to node %u, ret=%d\n",
1369 destnode, ret));
1370 return ret;
1373 ret = ctdb_reply_control_get_capabilities(reply, caps);
1374 if (ret != 0) {
1375 DEBUG(DEBUG_ERR,
1376 ("Control GET_CAPABILITIES failed, ret=%d\n", ret));
1377 return ret;
1380 return 0;
1383 int ctdb_ctrl_release_ip(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
1384 struct ctdb_client_context *client,
1385 int destnode, struct timeval timeout,
1386 struct ctdb_public_ip *pubip)
1388 struct ctdb_req_control request;
1389 struct ctdb_reply_control *reply;
1390 int ret;
1392 ctdb_req_control_release_ip(&request, pubip);
1393 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
1394 &request, &reply);
1395 if (ret != 0) {
1396 DEBUG(DEBUG_ERR,
1397 ("Control RELEASE_IP failed to node %u, ret=%d\n",
1398 destnode, ret));
1399 return ret;
1402 ret = ctdb_reply_control_release_ip(reply);
1403 if (ret != 0) {
1404 DEBUG(DEBUG_ERR,
1405 ("Control RELEASE_IP failed, ret=%d\n", ret));
1406 return ret;
1409 return 0;
1412 int ctdb_ctrl_takeover_ip(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
1413 struct ctdb_client_context *client,
1414 int destnode, struct timeval timeout,
1415 struct ctdb_public_ip *pubip)
1417 struct ctdb_req_control request;
1418 struct ctdb_reply_control *reply;
1419 int ret;
1421 ctdb_req_control_takeover_ip(&request, pubip);
1422 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
1423 &request, &reply);
1424 if (ret != 0) {
1425 DEBUG(DEBUG_ERR,
1426 ("Control TAKEOVER_IP failed to node %u, ret=%d\n",
1427 destnode, ret));
1428 return ret;
1431 ret = ctdb_reply_control_takeover_ip(reply);
1432 if (ret != 0) {
1433 DEBUG(DEBUG_ERR,
1434 ("Control TAKEOVER_IP failed, ret=%d\n", ret));
1435 return ret;
1438 return 0;
1441 int ctdb_ctrl_get_public_ips(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
1442 struct ctdb_client_context *client,
1443 int destnode, struct timeval timeout,
1444 bool available_only,
1445 struct ctdb_public_ip_list **pubip_list)
1447 struct ctdb_req_control request;
1448 struct ctdb_reply_control *reply;
1449 int ret;
1451 ctdb_req_control_get_public_ips(&request, available_only);
1452 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
1453 &request, &reply);
1454 if (ret != 0) {
1455 DEBUG(DEBUG_ERR,
1456 ("Control GET_PUBLIC_IPS failed to node %u, ret=%d\n",
1457 destnode, ret));
1458 return ret;
1461 ret = ctdb_reply_control_get_public_ips(reply, mem_ctx, pubip_list);
1462 if (ret != 0) {
1463 DEBUG(DEBUG_ERR,
1464 ("Control GET_PUBLIC_IPS failed, ret=%d\n", ret));
1465 return ret;
1468 return 0;
1471 int ctdb_ctrl_get_nodemap(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
1472 struct ctdb_client_context *client,
1473 int destnode, struct timeval timeout,
1474 struct ctdb_node_map **nodemap)
1476 struct ctdb_req_control request;
1477 struct ctdb_reply_control *reply;
1478 int ret;
1480 ctdb_req_control_get_nodemap(&request);
1481 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
1482 &request, &reply);
1483 if (ret != 0) {
1484 DEBUG(DEBUG_ERR,
1485 ("Control GET_NODEMAP failed to node %u, ret=%d\n",
1486 destnode, ret));
1487 return ret;
1490 ret = ctdb_reply_control_get_nodemap(reply, mem_ctx, nodemap);
1491 if (ret != 0) {
1492 DEBUG(DEBUG_ERR,
1493 ("Control GET_NODEMAP failed, ret=%d\n", ret));
1494 return ret;
1497 return 0;
1500 int ctdb_ctrl_traverse_kill(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
1501 struct ctdb_client_context *client,
1502 int destnode, struct timeval timeout,
1503 struct ctdb_traverse_start *traverse)
1505 struct ctdb_req_control request;
1506 struct ctdb_reply_control *reply;
1507 int ret;
1509 ctdb_req_control_traverse_kill(&request, traverse);
1510 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
1511 &request, &reply);
1512 if (ret != 0) {
1513 DEBUG(DEBUG_ERR,
1514 ("Control TRAVERSE_KILL failed to node %u, ret=%d\n",
1515 destnode, ret));
1516 return ret;
1519 ret = ctdb_reply_control_traverse_kill(reply);
1520 if (ret != 0) {
1521 DEBUG(DEBUG_ERR,
1522 ("Control TRAVERSE_KILL failed, ret=%d\n", ret));
1523 return ret;
1526 return 0;
1529 int ctdb_ctrl_get_reclock_file(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
1530 struct ctdb_client_context *client,
1531 int destnode, struct timeval timeout,
1532 const char **reclock_file)
1534 struct ctdb_req_control request;
1535 struct ctdb_reply_control *reply;
1536 int ret;
1538 ctdb_req_control_get_reclock_file(&request);
1539 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
1540 &request, &reply);
1541 if (ret != 0) {
1542 DEBUG(DEBUG_ERR,
1543 ("Control GET_RECLOCK_FILE failed to node %u, ret=%d\n",
1544 destnode, ret));
1545 return ret;
1548 ret = ctdb_reply_control_get_reclock_file(reply, mem_ctx, reclock_file);
1549 if (ret != 0) {
1550 DEBUG(DEBUG_ERR,
1551 ("Control GET_RECLOCK_FILE failed, ret=%d\n", ret));
1552 return ret;
1555 return 0;
1558 int ctdb_ctrl_stop_node(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
1559 struct ctdb_client_context *client,
1560 int destnode, struct timeval timeout)
1562 struct ctdb_req_control request;
1563 struct ctdb_reply_control *reply;
1564 int ret;
1566 ctdb_req_control_stop_node(&request);
1567 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
1568 &request, &reply);
1569 if (ret != 0) {
1570 DEBUG(DEBUG_ERR,
1571 ("Control STOP_NODE failed to node %u, ret=%d\n",
1572 destnode, ret));
1573 return ret;
1576 ret = ctdb_reply_control_stop_node(reply);
1577 if (ret != 0) {
1578 DEBUG(DEBUG_ERR,
1579 ("Control STOP_NODE failed, ret=%d\n", ret));
1580 return ret;
1583 return 0;
1586 int ctdb_ctrl_continue_node(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
1587 struct ctdb_client_context *client,
1588 int destnode, struct timeval timeout)
1590 struct ctdb_req_control request;
1591 struct ctdb_reply_control *reply;
1592 int ret;
1594 ctdb_req_control_continue_node(&request);
1595 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
1596 &request, &reply);
1597 if (ret != 0) {
1598 DEBUG(DEBUG_ERR,
1599 ("Control CONTINUE_NODE failed to node %u, ret=%d\n",
1600 destnode, ret));
1601 return ret;
1604 ret = ctdb_reply_control_continue_node(reply);
1605 if (ret != 0) {
1606 DEBUG(DEBUG_ERR,
1607 ("Control CONTINUE_NODE failed, ret=%d\n", ret));
1608 return ret;
1611 return 0;
1614 int ctdb_ctrl_set_lmasterrole(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
1615 struct ctdb_client_context *client,
1616 int destnode, struct timeval timeout,
1617 uint32_t lmaster_role)
1619 struct ctdb_req_control request;
1620 struct ctdb_reply_control *reply;
1621 int ret;
1623 ctdb_req_control_set_lmasterrole(&request, lmaster_role);
1624 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
1625 &request, &reply);
1626 if (ret != 0) {
1627 DEBUG(DEBUG_ERR,
1628 ("Control SET_LMASTERROLE failed to node %u, ret=%d\n",
1629 destnode, ret));
1630 return ret;
1633 ret = ctdb_reply_control_set_lmasterrole(reply);
1634 if (ret != 0) {
1635 DEBUG(DEBUG_ERR,
1636 ("Control SET_LMASTERROLE failed, ret=%d\n", ret));
1637 return ret;
1640 return 0;
1643 int ctdb_ctrl_set_recmasterrole(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
1644 struct ctdb_client_context *client,
1645 int destnode, struct timeval timeout,
1646 uint32_t recmaster_role)
1648 struct ctdb_req_control request;
1649 struct ctdb_reply_control *reply;
1650 int ret;
1652 ctdb_req_control_set_recmasterrole(&request, recmaster_role);
1653 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
1654 &request, &reply);
1655 if (ret != 0) {
1656 DEBUG(DEBUG_ERR,
1657 ("Control SET_RECMASTERROLE failed to node %u, ret=%d\n",
1658 destnode, ret));
1659 return ret;
1662 ret = ctdb_reply_control_set_recmasterrole(reply);
1663 if (ret != 0) {
1664 DEBUG(DEBUG_ERR,
1665 ("Control SET_RECMASTERROLE failed, ret=%d\n", ret));
1666 return ret;
1669 return 0;
1672 int ctdb_ctrl_set_ban_state(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
1673 struct ctdb_client_context *client,
1674 int destnode, struct timeval timeout,
1675 struct ctdb_ban_state *ban_state)
1677 struct ctdb_req_control request;
1678 struct ctdb_reply_control *reply;
1679 int ret;
1681 ctdb_req_control_set_ban_state(&request, ban_state);
1682 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
1683 &request, &reply);
1684 if (ret != 0) {
1685 DEBUG(DEBUG_ERR,
1686 ("Control SET_BAN_STATE failed to node %u, ret=%d\n",
1687 destnode, ret));
1688 return ret;
1691 ret = ctdb_reply_control_set_ban_state(reply);
1692 if (ret != 0) {
1693 DEBUG(DEBUG_ERR,
1694 ("Control SET_BAN_STATE failed, ret=%d\n", ret));
1695 return ret;
1698 return 0;
1701 int ctdb_ctrl_get_ban_state(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
1702 struct ctdb_client_context *client,
1703 int destnode, struct timeval timeout,
1704 struct ctdb_ban_state **ban_state)
1706 struct ctdb_req_control request;
1707 struct ctdb_reply_control *reply;
1708 int ret;
1710 ctdb_req_control_get_ban_state(&request);
1711 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
1712 &request, &reply);
1713 if (ret != 0) {
1714 DEBUG(DEBUG_ERR,
1715 ("Control GET_BAN_STATE failed to node %u, ret=%d\n",
1716 destnode, ret));
1717 return ret;
1720 ret = ctdb_reply_control_get_ban_state(reply, mem_ctx, ban_state);
1721 if (ret != 0) {
1722 DEBUG(DEBUG_ERR,
1723 ("Control GET_BAN_STATE failed, ret=%d\n", ret));
1724 return ret;
1727 return 0;
1730 int ctdb_ctrl_register_notify(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
1731 struct ctdb_client_context *client,
1732 int destnode, struct timeval timeout,
1733 struct ctdb_notify_data *notify)
1735 struct ctdb_req_control request;
1736 struct ctdb_reply_control *reply;
1737 int ret;
1739 ctdb_req_control_register_notify(&request, notify);
1740 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
1741 &request, &reply);
1742 if (ret != 0) {
1743 DEBUG(DEBUG_ERR,
1744 ("Control REGISTER_NOTIFY failed to node %u, ret=%d\n",
1745 destnode, ret));
1746 return ret;
1749 ret = ctdb_reply_control_register_notify(reply);
1750 if (ret != 0) {
1751 DEBUG(DEBUG_ERR,
1752 ("Control REGISTER_NOTIFY failed, ret=%d\n", ret));
1753 return ret;
1756 return 0;
1759 int ctdb_ctrl_deregister_notify(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
1760 struct ctdb_client_context *client,
1761 int destnode, struct timeval timeout,
1762 uint64_t srvid)
1764 struct ctdb_req_control request;
1765 struct ctdb_reply_control *reply;
1766 int ret;
1768 ctdb_req_control_deregister_notify(&request, srvid);
1769 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
1770 &request, &reply);
1771 if (ret != 0) {
1772 DEBUG(DEBUG_ERR,
1773 ("Control DEREGISTER_NOTIFY failed to node %u, ret=%d\n",
1774 destnode, ret));
1775 return ret;
1778 ret = ctdb_reply_control_deregister_notify(reply);
1779 if (ret != 0) {
1780 DEBUG(DEBUG_ERR,
1781 ("Control DEREGISTER_NOTIFY failed, ret=%d\n", ret));
1782 return ret;
1785 return 0;
1788 int ctdb_ctrl_trans3_commit(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
1789 struct ctdb_client_context *client,
1790 int destnode, struct timeval timeout,
1791 struct ctdb_rec_buffer *recbuf)
1793 struct ctdb_req_control request;
1794 struct ctdb_reply_control *reply;
1795 int ret;
1797 ctdb_req_control_trans3_commit(&request, recbuf);
1798 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
1799 &request, &reply);
1800 if (ret != 0) {
1801 DEBUG(DEBUG_ERR,
1802 ("Control TRANS3_COMMIT failed to node %u, ret=%d\n",
1803 destnode, ret));
1804 return ret;
1807 ret = ctdb_reply_control_trans3_commit(reply);
1808 if (ret != 0) {
1809 DEBUG(DEBUG_ERR,
1810 ("Control TRANS3_COMMIT failed, ret=%d\n", ret));
1811 return ret;
1814 return 0;
1817 int ctdb_ctrl_get_db_seqnum(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
1818 struct ctdb_client_context *client,
1819 int destnode, struct timeval timeout,
1820 uint32_t db_id, uint64_t *seqnum)
1822 struct ctdb_req_control request;
1823 struct ctdb_reply_control *reply;
1824 int ret;
1826 ctdb_req_control_get_db_seqnum(&request, db_id);
1827 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
1828 &request, &reply);
1829 if (ret != 0) {
1830 DEBUG(DEBUG_ERR,
1831 ("Control GET_DB_SEQNUM failed to node %u, ret=%d\n",
1832 destnode, ret));
1833 return ret;
1836 ret = ctdb_reply_control_get_db_seqnum(reply, seqnum);
1837 if (ret != 0) {
1838 DEBUG(DEBUG_ERR,
1839 ("Control GET_DB_SEQNUM failed, ret=%d\n", ret));
1840 return ret;
1843 return 0;
1846 int ctdb_ctrl_db_set_healthy(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
1847 struct ctdb_client_context *client,
1848 int destnode, struct timeval timeout,
1849 uint32_t db_id)
1851 struct ctdb_req_control request;
1852 struct ctdb_reply_control *reply;
1853 int ret;
1855 ctdb_req_control_db_set_healthy(&request, db_id);
1856 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
1857 &request, &reply);
1858 if (ret != 0) {
1859 DEBUG(DEBUG_ERR,
1860 ("Control DB_SET_HEALTHY failed to node %u, ret=%d\n",
1861 destnode, ret));
1862 return ret;
1865 ret = ctdb_reply_control_db_set_healthy(reply);
1866 if (ret != 0) {
1867 DEBUG(DEBUG_ERR,
1868 ("Control DB_SET_HEALTHY failed, ret=%d\n", ret));
1869 return ret;
1872 return 0;
1875 int ctdb_ctrl_db_get_health(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
1876 struct ctdb_client_context *client,
1877 int destnode, struct timeval timeout,
1878 uint32_t db_id, const char **reason)
1880 struct ctdb_req_control request;
1881 struct ctdb_reply_control *reply;
1882 int ret;
1884 ctdb_req_control_db_get_health(&request, db_id);
1885 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
1886 &request, &reply);
1887 if (ret != 0) {
1888 DEBUG(DEBUG_ERR,
1889 ("Control DB_GET_HEALTH failed to node %u, ret=%d\n",
1890 destnode, ret));
1891 return ret;
1894 ret = ctdb_reply_control_db_get_health(reply, mem_ctx, reason);
1895 if (ret != 0) {
1896 DEBUG(DEBUG_ERR,
1897 ("Control DB_GET_HEALTH failed, ret=%d\n", ret));
1898 return ret;
1901 return 0;
1904 int ctdb_ctrl_get_public_ip_info(TALLOC_CTX *mem_ctx,
1905 struct tevent_context *ev,
1906 struct ctdb_client_context *client,
1907 int destnode, struct timeval timeout,
1908 ctdb_sock_addr *addr,
1909 struct ctdb_public_ip_info **ipinfo)
1911 struct ctdb_req_control request;
1912 struct ctdb_reply_control *reply;
1913 int ret;
1915 ctdb_req_control_get_public_ip_info(&request, addr);
1916 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
1917 &request, &reply);
1918 if (ret != 0) {
1919 DEBUG(DEBUG_ERR,
1920 ("Control GET_PUBLIC_IP_INFO failed to node %u, ret=%d\n",
1921 destnode, ret));
1922 return ret;
1925 ret = ctdb_reply_control_get_public_ip_info(reply, mem_ctx, ipinfo);
1926 if (ret != 0) {
1927 DEBUG(DEBUG_ERR,
1928 ("Control GET_PUBLIC_IP_INFO failed, ret=%d\n", ret));
1929 return ret;
1932 return 0;
1935 int ctdb_ctrl_get_ifaces(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
1936 struct ctdb_client_context *client,
1937 int destnode, struct timeval timeout,
1938 struct ctdb_iface_list **iface_list)
1940 struct ctdb_req_control request;
1941 struct ctdb_reply_control *reply;
1942 int ret;
1944 ctdb_req_control_get_ifaces(&request);
1945 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
1946 &request, &reply);
1947 if (ret != 0) {
1948 DEBUG(DEBUG_ERR,
1949 ("Control GET_IFACES failed to node %u, ret=%d\n",
1950 destnode, ret));
1951 return ret;
1954 ret = ctdb_reply_control_get_ifaces(reply, mem_ctx, iface_list);
1955 if (ret != 0) {
1956 DEBUG(DEBUG_ERR,
1957 ("Control GET_IFACES failed, ret=%d\n", ret));
1958 return ret;
1961 return 0;
1964 int ctdb_ctrl_set_iface_link_state(TALLOC_CTX *mem_ctx,
1965 struct tevent_context *ev,
1966 struct ctdb_client_context *client,
1967 int destnode, struct timeval timeout,
1968 struct ctdb_iface *iface)
1970 struct ctdb_req_control request;
1971 struct ctdb_reply_control *reply;
1972 int ret;
1974 ctdb_req_control_set_iface_link_state(&request, iface);
1975 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
1976 &request, &reply);
1977 if (ret != 0) {
1978 DEBUG(DEBUG_ERR,
1979 ("Control SET_IFACE_LINK_STATE failed to node %u, ret=%d\n",
1980 destnode, ret));
1981 return ret;
1984 ret = ctdb_reply_control_set_iface_link_state(reply);
1985 if (ret != 0) {
1986 DEBUG(DEBUG_ERR,
1987 ("Control SET_IFACE_LINK_STATE failed, ret=%d\n", ret));
1988 return ret;
1991 return 0;
1994 int ctdb_ctrl_tcp_add_delayed_update(TALLOC_CTX *mem_ctx,
1995 struct tevent_context *ev,
1996 struct ctdb_client_context *client,
1997 int destnode, struct timeval timeout,
1998 struct ctdb_connection *conn)
2000 struct ctdb_req_control request;
2001 struct ctdb_reply_control *reply;
2002 int ret;
2004 ctdb_req_control_tcp_add_delayed_update(&request, conn);
2005 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
2006 &request, &reply);
2007 if (ret != 0) {
2008 DEBUG(DEBUG_ERR,
2009 ("Control TCP_ADD_DELAYED_UPDATE failed to node %u, ret=%d\n",
2010 destnode, ret));
2011 return ret;
2014 ret = ctdb_reply_control_tcp_add_delayed_update(reply);
2015 if (ret != 0) {
2016 DEBUG(DEBUG_ERR,
2017 ("Control TCP_ADD_DELAYED_UPDATE failed, ret=%d\n", ret));
2018 return ret;
2021 return 0;
2024 int ctdb_ctrl_get_stat_history(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
2025 struct ctdb_client_context *client,
2026 int destnode, struct timeval timeout,
2027 struct ctdb_statistics_list **stats_list)
2029 struct ctdb_req_control request;
2030 struct ctdb_reply_control *reply;
2031 int ret;
2033 ctdb_req_control_get_stat_history(&request);
2034 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
2035 &request, &reply);
2036 if (ret != 0) {
2037 DEBUG(DEBUG_ERR,
2038 ("Control GET_STAT_HISTORY failed to node %u, ret=%d\n",
2039 destnode, ret));
2040 return ret;
2043 ret = ctdb_reply_control_get_stat_history(reply, mem_ctx, stats_list);
2044 if (ret != 0) {
2045 DEBUG(DEBUG_ERR,
2046 ("Control GET_STAT_HISTORY failed, ret=%d\n", ret));
2047 return ret;
2050 return 0;
2053 int ctdb_ctrl_schedule_for_deletion(TALLOC_CTX *mem_ctx,
2054 struct tevent_context *ev,
2055 struct ctdb_client_context *client,
2056 int destnode, struct timeval timeout,
2057 struct ctdb_key_data *key)
2059 struct ctdb_req_control request;
2060 struct ctdb_reply_control *reply;
2061 int ret;
2063 ctdb_req_control_schedule_for_deletion(&request, key);
2064 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
2065 &request, &reply);
2066 if (ret != 0) {
2067 DEBUG(DEBUG_ERR,
2068 ("Control SCHEDULE_FOR_DELETION failed to node %u, ret=%d\n",
2069 destnode, ret));
2070 return ret;
2073 ret = ctdb_reply_control_schedule_for_deletion(reply);
2074 if (ret != 0) {
2075 DEBUG(DEBUG_ERR,
2076 ("Control SCHEDULE_FOR_DELETION failed, ret=%d\n", ret));
2077 return ret;
2080 return 0;
2083 int ctdb_ctrl_set_db_readonly(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
2084 struct ctdb_client_context *client,
2085 int destnode, struct timeval timeout,
2086 uint32_t db_id)
2088 struct ctdb_req_control request;
2089 struct ctdb_reply_control *reply;
2090 int ret;
2092 ctdb_req_control_set_db_readonly(&request, db_id);
2093 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
2094 &request, &reply);
2095 if (ret != 0) {
2096 DEBUG(DEBUG_ERR,
2097 ("Control SET_DB_READONY failed to node %u, ret=%d\n",
2098 destnode, ret));
2099 return ret;
2102 ret = ctdb_reply_control_set_db_readonly(reply);
2103 if (ret != 0) {
2104 DEBUG(DEBUG_ERR,
2105 ("Control SET_DB_READONY failed, ret=%d\n", ret));
2106 return ret;
2109 return 0;
2112 int ctdb_ctrl_traverse_start_ext(TALLOC_CTX *mem_ctx,
2113 struct tevent_context *ev,
2114 struct ctdb_client_context *client,
2115 int destnode, struct timeval timeout,
2116 struct ctdb_traverse_start_ext *traverse)
2118 struct ctdb_req_control request;
2119 struct ctdb_reply_control *reply;
2120 int ret;
2122 ctdb_req_control_traverse_start_ext(&request, traverse);
2123 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
2124 &request, &reply);
2125 if (ret != 0) {
2126 DEBUG(DEBUG_ERR,
2127 ("Control TRAVERSE_START_EXT failed to node %u, ret=%d\n",
2128 destnode, ret));
2129 return ret;
2132 ret = ctdb_reply_control_traverse_start_ext(reply);
2133 if (ret != 0) {
2134 DEBUG(DEBUG_ERR,
2135 ("Control TRAVERSE_START_EXT failed, ret=%d\n", ret));
2136 return ret;
2139 return 0;
2142 int ctdb_ctrl_get_db_statistics(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
2143 struct ctdb_client_context *client,
2144 int destnode, struct timeval timeout,
2145 uint32_t db_id,
2146 struct ctdb_db_statistics **dbstats)
2148 struct ctdb_req_control request;
2149 struct ctdb_reply_control *reply;
2150 int ret;
2152 ctdb_req_control_get_db_statistics(&request, db_id);
2153 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
2154 &request, &reply);
2155 if (ret != 0) {
2156 DEBUG(DEBUG_ERR,
2157 ("Control GET_DB_STATISTICS failed to node %u, ret=%d\n",
2158 destnode, ret));
2159 return ret;
2162 ret = ctdb_reply_control_get_db_statistics(reply, mem_ctx, dbstats);
2163 if (ret != 0) {
2164 DEBUG(DEBUG_ERR,
2165 ("Control GET_DB_STATISTICS failed, ret=%d\n", ret));
2166 return ret;
2169 return 0;
2172 int ctdb_ctrl_set_db_sticky(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
2173 struct ctdb_client_context *client,
2174 int destnode, struct timeval timeout,
2175 uint32_t db_id)
2177 struct ctdb_req_control request;
2178 struct ctdb_reply_control *reply;
2179 int ret;
2181 ctdb_req_control_set_db_sticky(&request, db_id);
2182 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
2183 &request, &reply);
2184 if (ret != 0) {
2185 DEBUG(DEBUG_ERR,
2186 ("Control SET_DB_STICKY failed to node %u, ret=%d\n",
2187 destnode, ret));
2188 return ret;
2191 ret = ctdb_reply_control_set_db_sticky(reply);
2192 if (ret != 0) {
2193 DEBUG(DEBUG_ERR,
2194 ("Control SET_DB_STICKY failed, ret=%d\n", ret));
2195 return ret;
2198 return 0;
2201 int ctdb_ctrl_reload_public_ips(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
2202 struct ctdb_client_context *client,
2203 int destnode, struct timeval timeout)
2205 struct ctdb_req_control request;
2206 struct ctdb_reply_control *reply;
2207 int ret;
2209 ctdb_req_control_reload_public_ips(&request);
2210 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
2211 &request, &reply);
2212 if (ret != 0) {
2213 DEBUG(DEBUG_ERR,
2214 ("Control RELOAD_PUBLIC_IPS failed to node %u, ret=%d\n",
2215 destnode, ret));
2216 return ret;
2219 ret = ctdb_reply_control_reload_public_ips(reply);
2220 if (ret != 0) {
2221 DEBUG(DEBUG_ERR,
2222 ("Control RELOAD_PUBLIC_IPS failed, ret=%d\n", ret));
2223 return ret;
2226 return 0;
2229 int ctdb_ctrl_ipreallocated(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
2230 struct ctdb_client_context *client,
2231 int destnode, struct timeval timeout)
2233 struct ctdb_req_control request;
2234 struct ctdb_reply_control *reply;
2235 int ret;
2237 ctdb_req_control_ipreallocated(&request);
2238 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
2239 &request, &reply);
2240 if (ret != 0) {
2241 DEBUG(DEBUG_ERR,
2242 ("Control IPREALLOCATED failed to node %u, ret=%d\n",
2243 destnode, ret));
2244 return ret;
2247 ret = ctdb_reply_control_ipreallocated(reply);
2248 if (ret != 0) {
2249 DEBUG(DEBUG_ERR,
2250 ("Control IPREALLOCATED failed, ret=%d\n", ret));
2251 return ret;
2254 return 0;
2257 int ctdb_ctrl_get_runstate(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
2258 struct ctdb_client_context *client,
2259 int destnode, struct timeval timeout,
2260 enum ctdb_runstate *runstate)
2262 struct ctdb_req_control request;
2263 struct ctdb_reply_control *reply;
2264 int ret;
2266 ctdb_req_control_get_runstate(&request);
2267 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
2268 &request, &reply);
2269 if (ret != 0) {
2270 DEBUG(DEBUG_ERR,
2271 ("Control GET_RUNSTATE failed to node %u, ret=%d\n",
2272 destnode, ret));
2273 return ret;
2276 ret = ctdb_reply_control_get_runstate(reply, runstate);
2277 if (ret != 0) {
2278 DEBUG(DEBUG_ERR,
2279 ("Control GET_RUNSTATE failed, ret=%d\n", ret));
2280 return ret;
2283 return 0;
2286 int ctdb_ctrl_db_detach(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
2287 struct ctdb_client_context *client,
2288 int destnode, struct timeval timeout,
2289 uint32_t db_id)
2291 struct ctdb_req_control request;
2292 struct ctdb_reply_control *reply;
2293 int ret;
2295 ctdb_req_control_db_detach(&request, db_id);
2296 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
2297 &request, &reply);
2298 if (ret != 0) {
2299 DEBUG(DEBUG_ERR,
2300 ("Control DB_DETACH failed to node %u, ret=%d\n",
2301 destnode, ret));
2302 return ret;
2305 ret = ctdb_reply_control_db_detach(reply);
2306 if (ret != 0) {
2307 DEBUG(DEBUG_ERR,
2308 ("Control DB_DETACH failed, ret=%d\n", ret));
2309 return ret;
2312 return 0;
2315 int ctdb_ctrl_get_nodes_file(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
2316 struct ctdb_client_context *client,
2317 int destnode, struct timeval timeout,
2318 struct ctdb_node_map **nodemap)
2320 struct ctdb_req_control request;
2321 struct ctdb_reply_control *reply;
2322 int ret;
2324 ctdb_req_control_get_nodes_file(&request);
2325 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
2326 &request, &reply);
2327 if (ret != 0) {
2328 DEBUG(DEBUG_ERR,
2329 ("Control GET_NODES_FILE failed to node %u, ret=%d\n",
2330 destnode, ret));
2331 return ret;
2334 ret = ctdb_reply_control_get_nodes_file(reply, mem_ctx, nodemap);
2335 if (ret != 0) {
2336 DEBUG(DEBUG_ERR,
2337 ("Control GET_NODES_FILE failed, ret=%d\n", ret));
2338 return ret;
2341 return 0;
2344 int ctdb_ctrl_db_freeze(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
2345 struct ctdb_client_context *client,
2346 int destnode, struct timeval timeout, uint32_t db_id)
2348 struct ctdb_req_control request;
2349 struct ctdb_reply_control *reply;
2350 int ret;
2352 ctdb_req_control_db_freeze(&request, db_id);
2353 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
2354 &request, &reply);
2355 if (ret != 0) {
2356 DEBUG(DEBUG_ERR,
2357 ("Control DB_FREEZE failed to node %u, ret=%d\n",
2358 destnode, ret));
2359 return ret;
2362 ret = ctdb_reply_control_db_freeze(reply);
2363 if (ret != 0) {
2364 DEBUG(DEBUG_ERR,
2365 ("Control DB_FREEZE failed, ret=%d\n", ret));
2366 return ret;
2369 return 0;
2372 int ctdb_ctrl_db_thaw(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
2373 struct ctdb_client_context *client,
2374 int destnode, struct timeval timeout, uint32_t db_id)
2376 struct ctdb_req_control request;
2377 struct ctdb_reply_control *reply;
2378 int ret;
2380 ctdb_req_control_db_thaw(&request, db_id);
2381 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
2382 &request, &reply);
2383 if (ret != 0) {
2384 DEBUG(DEBUG_ERR,
2385 ("Control DB_THAW failed to node %u, ret=%d\n",
2386 destnode, ret));
2387 return ret;
2390 ret = ctdb_reply_control_db_thaw(reply);
2391 if (ret != 0) {
2392 DEBUG(DEBUG_ERR,
2393 ("Control DB_THAW failed, ret=%d\n", ret));
2394 return ret;
2397 return 0;
2400 int ctdb_ctrl_db_transaction_start(TALLOC_CTX *mem_ctx,
2401 struct tevent_context *ev,
2402 struct ctdb_client_context *client,
2403 int destnode, struct timeval timeout,
2404 struct ctdb_transdb *transdb)
2406 struct ctdb_req_control request;
2407 struct ctdb_reply_control *reply;
2408 int ret;
2410 ctdb_req_control_db_transaction_start(&request, transdb);
2411 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
2412 &request, &reply);
2413 if (ret != 0) {
2414 DEBUG(DEBUG_ERR,
2415 ("Control DB_TRANSACTION_START failed to node %u, ret=%d\n",
2416 destnode, ret));
2417 return ret;
2420 ret = ctdb_reply_control_db_transaction_start(reply);
2421 if (ret != 0) {
2422 DEBUG(DEBUG_ERR,
2423 ("Control DB_TRANSACTION_START failed, ret=%d\n", ret));
2424 return ret;
2427 return 0;
2430 int ctdb_ctrl_db_transaction_commit(TALLOC_CTX *mem_ctx,
2431 struct tevent_context *ev,
2432 struct ctdb_client_context *client,
2433 int destnode, struct timeval timeout,
2434 struct ctdb_transdb *transdb)
2436 struct ctdb_req_control request;
2437 struct ctdb_reply_control *reply;
2438 int ret;
2440 ctdb_req_control_db_transaction_commit(&request, transdb);
2441 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
2442 &request, &reply);
2443 if (ret != 0) {
2444 DEBUG(DEBUG_ERR,
2445 ("Control DB_TRANSACTION_COMMIT failed to node %u, ret=%d\n",
2446 destnode, ret));
2447 return ret;
2450 ret = ctdb_reply_control_db_transaction_commit(reply);
2451 if (ret != 0) {
2452 DEBUG(DEBUG_ERR,
2453 ("Control DB_TRANSACTION_COMMIT failed, ret=%d\n", ret));
2454 return ret;
2457 return 0;
2460 int ctdb_ctrl_db_transaction_cancel(TALLOC_CTX *mem_ctx,
2461 struct tevent_context *ev,
2462 struct ctdb_client_context *client,
2463 int destnode, struct timeval timeout,
2464 uint32_t db_id)
2466 struct ctdb_req_control request;
2467 struct ctdb_reply_control *reply;
2468 int ret;
2470 ctdb_req_control_db_transaction_cancel(&request, db_id);
2471 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
2472 &request, &reply);
2473 if (ret != 0) {
2474 DEBUG(DEBUG_ERR,
2475 ("Control DB_TRANSACTION_CANCEL failed to node %u, ret=%d\n",
2476 destnode, ret));
2477 return ret;
2480 ret = ctdb_reply_control_db_transaction_cancel(reply);
2481 if (ret != 0) {
2482 DEBUG(DEBUG_ERR,
2483 ("Control DB_TRANSACTION_CANCEL failed, ret=%d\n", ret));
2484 return ret;
2487 return 0;
2490 int ctdb_ctrl_db_pull(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
2491 struct ctdb_client_context *client,
2492 int destnode, struct timeval timeout,
2493 struct ctdb_pulldb_ext *pulldb, uint32_t *num_records)
2495 struct ctdb_req_control request;
2496 struct ctdb_reply_control *reply;
2497 int ret;
2499 ctdb_req_control_db_pull(&request, pulldb);
2500 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
2501 &request, &reply);
2502 if (ret != 0) {
2503 DEBUG(DEBUG_ERR,
2504 ("Control DB_PULL failed to node %u, ret=%d\n",
2505 destnode, ret));
2506 return ret;
2509 ret = ctdb_reply_control_db_pull(reply, num_records);
2510 if (ret != 0) {
2511 DEBUG(DEBUG_ERR, ("Control DB_PULL failed, ret=%d\n", ret));
2512 return ret;
2515 return 0;
2518 int ctdb_ctrl_db_push_start(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
2519 struct ctdb_client_context *client,
2520 int destnode, struct timeval timeout,
2521 struct ctdb_pulldb_ext *pulldb)
2523 struct ctdb_req_control request;
2524 struct ctdb_reply_control *reply;
2525 int ret;
2527 ctdb_req_control_db_push_start(&request, pulldb);
2528 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
2529 &request, &reply);
2530 if (ret != 0) {
2531 DEBUG(DEBUG_ERR,
2532 ("Control DB_PUSH_START failed to node %u, ret=%d\n",
2533 destnode, ret));
2534 return ret;
2537 ret = ctdb_reply_control_db_push_start(reply);
2538 if (ret != 0) {
2539 DEBUG(DEBUG_ERR,
2540 ("Control DB_PUSH_START failed, ret=%d\n", ret));
2541 return ret;
2544 return 0;
2547 int ctdb_ctrl_db_push_confirm(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
2548 struct ctdb_client_context *client,
2549 int destnode, struct timeval timeout,
2550 uint32_t db_id, uint32_t *num_records)
2552 struct ctdb_req_control request;
2553 struct ctdb_reply_control *reply;
2554 int ret;
2556 ctdb_req_control_db_push_confirm(&request, db_id);
2557 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
2558 &request, &reply);
2559 if (ret != 0) {
2560 DEBUG(DEBUG_ERR,
2561 ("Control DB_PUSH_CONFIRM failed to node %u, ret=%d\n",
2562 destnode, ret));
2563 return ret;
2566 ret = ctdb_reply_control_db_push_confirm(reply, num_records);
2567 if (ret != 0) {
2568 DEBUG(DEBUG_ERR,
2569 ("Control DB_PUSH_CONFIRM failed, ret=%d\n", ret));
2570 return ret;
2573 return 0;
2576 int ctdb_ctrl_db_open_flags(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
2577 struct ctdb_client_context *client,
2578 int destnode, struct timeval timeout,
2579 uint32_t db_id, int *tdb_flags)
2581 struct ctdb_req_control request;
2582 struct ctdb_reply_control *reply;
2583 int ret;
2585 ctdb_req_control_db_open_flags(&request, db_id);
2586 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
2587 &request, &reply);
2588 if (ret != 0) {
2589 DEBUG(DEBUG_ERR,
2590 ("Control DB_OPEN_FLAGS failed to node %u, ret=%d\n",
2591 destnode, ret));
2592 return ret;
2595 ret = ctdb_reply_control_db_open_flags(reply, tdb_flags);
2596 if (ret != 0) {
2597 DEBUG(DEBUG_ERR,
2598 ("Control DB_OPEN_FLAGS failed, ret=%d\n", ret));
2599 return ret;
2602 return 0;
2605 int ctdb_ctrl_db_attach_replicated(TALLOC_CTX *mem_ctx,
2606 struct tevent_context *ev,
2607 struct ctdb_client_context *client,
2608 int destnode, struct timeval timeout,
2609 const char *db_name, uint32_t *db_id)
2611 struct ctdb_req_control request;
2612 struct ctdb_reply_control *reply;
2613 int ret;
2615 ctdb_req_control_db_attach_replicated(&request, db_name);
2616 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
2617 &request, &reply);
2618 if (ret != 0) {
2619 DEBUG(DEBUG_ERR,
2620 ("Control DB_ATTACH_REPLICATED failed to node %u,"
2621 " ret=%d\n", destnode, ret));
2622 return ret;
2625 ret = ctdb_reply_control_db_attach_replicated(reply, db_id);
2626 if (ret != 0) {
2627 DEBUG(DEBUG_ERR,
2628 ("Control DB_ATTACH_REPLICATED failed, ret=%d\n", ret));
2629 return ret;
2632 return 0;
2635 int ctdb_ctrl_check_pid_srvid(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
2636 struct ctdb_client_context *client,
2637 int destnode, struct timeval timeout,
2638 struct ctdb_pid_srvid *pid_srvid, int *status)
2640 struct ctdb_req_control request;
2641 struct ctdb_reply_control *reply;
2642 int ret;
2644 ctdb_req_control_check_pid_srvid(&request, pid_srvid);
2645 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
2646 &request, &reply);
2647 if (ret != 0) {
2648 DEBUG(DEBUG_ERR,
2649 ("Control CHECK_PID_SRVID failed to node %u, ret=%d\n",
2650 destnode, ret));
2651 return ret;
2654 ret = ctdb_reply_control_check_pid_srvid(reply, status);
2655 if (ret != 0) {
2656 DEBUG(DEBUG_ERR,
2657 ("Control CHECK_PID_SRVID failed, ret=%d\n", ret));
2658 return ret;
2661 return 0;
2664 int ctdb_ctrl_tunnel_register(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
2665 struct ctdb_client_context *client,
2666 int destnode, struct timeval timeout,
2667 uint64_t tunnel_id)
2669 struct ctdb_req_control request;
2670 struct ctdb_reply_control *reply;
2671 int ret;
2673 ctdb_req_control_tunnel_register(&request, tunnel_id);
2674 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
2675 &request, &reply);
2676 if (ret != 0) {
2677 DEBUG(DEBUG_ERR,
2678 ("Control TUNNEL_REGISTER failed to node %u, ret=%d\n",
2679 destnode, ret));
2680 return ret;
2683 ret = ctdb_reply_control_tunnel_register(reply);
2684 if (ret != 0) {
2685 DEBUG(DEBUG_ERR,
2686 ("Control TUNNEL_REGISTER failed, ret=%d\n", ret));
2687 return ret;
2690 return 0;
2693 int ctdb_ctrl_tunnel_deregister(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
2694 struct ctdb_client_context *client,
2695 int destnode, struct timeval timeout,
2696 uint64_t tunnel_id)
2698 struct ctdb_req_control request;
2699 struct ctdb_reply_control *reply;
2700 int ret;
2702 ctdb_req_control_tunnel_deregister(&request, tunnel_id);
2703 ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
2704 &request, &reply);
2705 if (ret != 0) {
2706 DEBUG(DEBUG_ERR,
2707 ("Control TUNNEL_DEREGISTER failed to node %u, ret=%d\n",
2708 destnode, ret));
2709 return ret;
2712 ret = ctdb_reply_control_tunnel_deregister(reply);
2713 if (ret != 0) {
2714 DEBUG(DEBUG_ERR,
2715 ("Control TUNNEL_DEREGISTER failed, ret=%d\n", ret));
2716 return ret;
2719 return 0;