3 provide API to do non-blocking locks for single or all databases
5 Copyright (C) Amitay Isaacs 2012
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, see <http://www.gnu.org/licenses/>.
21 #include "include/ctdb_private.h"
22 #include "include/ctdb_protocol.h"
26 #include "system/filesys.h"
27 #include "lib/util/dlinklist.h"
30 * Non-blocking Locking API
32 * 1. Create a child process to do blocking locks.
33 * 2. Once the locks are obtained, signal parent process via fd.
34 * 3. Invoke registered callback routine with locking status.
35 * 4. If the child process cannot get locks within certain time,
36 * diagnose using /proc/locks and log warning message
38 * ctdb_lock_record() - get a lock on a record
39 * ctdb_lock_db() - get a lock on a DB
40 * ctdb_lock_alldb_prio() - get a lock on all DBs with given priority
41 * ctdb_lock_alldb() - get a lock on all DBs
43 * auto_mark - whether to mark/unmark DBs in before/after callback
46 /* FIXME: Add a tunable max_lock_processes_per_db */
47 #define MAX_LOCK_PROCESSES_PER_DB (100)
56 static const char * const lock_type_str[] = {
65 /* lock_context is the common part for a lock request */
67 struct lock_context *next, *prev;
69 struct ctdb_context *ctdb;
70 struct ctdb_db_context *ctdb_db;
74 struct lock_request *req_queue;
77 struct tevent_fd *tfd;
78 struct tevent_timer *ttimer;
79 struct timeval start_time;
83 /* lock_request is the client specific part for a lock request */
85 struct lock_request *next, *prev;
86 struct lock_context *lctx;
87 void (*callback)(void *, bool);
93 * Support samba 3.6.x (and older) versions which do not set db priority.
95 * By default, all databases are set to priority 1. So only when priority
96 * is set to 1, check for databases that need higher priority.
98 static bool later_db(struct ctdb_context *ctdb, const char *name)
100 if (ctdb->tunable.samba3_hack == 0) {
104 if (strstr(name, "brlock") ||
105 strstr(name, "g_lock") ||
106 strstr(name, "notify_onelevel") ||
107 strstr(name, "serverid") ||
108 strstr(name, "xattr_tdb")) {
115 typedef int (*db_handler_t)(struct ctdb_db_context *ctdb_db,
119 static int ctdb_db_iterator(struct ctdb_context *ctdb, uint32_t priority,
120 db_handler_t handler, void *private_data)
122 struct ctdb_db_context *ctdb_db;
125 for (ctdb_db = ctdb->db_list; ctdb_db; ctdb_db = ctdb_db->next) {
126 if (ctdb_db->priority != priority) {
129 if (later_db(ctdb, ctdb_db->db_name)) {
132 ret = handler(ctdb_db, priority, private_data);
138 /* If priority != 1, later_db check is not required and can return */
143 for (ctdb_db = ctdb->db_list; ctdb_db; ctdb_db = ctdb_db->next) {
144 if (!later_db(ctdb, ctdb_db->db_name)) {
147 ret = handler(ctdb_db, priority, private_data);
158 * lock all databases - mark only
160 static int db_lock_mark_handler(struct ctdb_db_context *ctdb_db, uint32_t priority,
163 int tdb_transaction_write_lock_mark(struct tdb_context *);
165 DEBUG(DEBUG_INFO, ("marking locked database %s, priority:%u\n",
166 ctdb_db->db_name, priority));
168 if (tdb_transaction_write_lock_mark(ctdb_db->ltdb->tdb) != 0) {
169 DEBUG(DEBUG_ERR, ("Failed to mark (transaction lock) database %s\n",
174 if (tdb_lockall_mark(ctdb_db->ltdb->tdb) != 0) {
175 DEBUG(DEBUG_ERR, ("Failed to mark (all lock) database %s\n",
183 int ctdb_lockall_mark_prio(struct ctdb_context *ctdb, uint32_t priority)
186 * This function is only used by the main dameon during recovery.
187 * At this stage, the databases have already been locked, by a
188 * dedicated child process. The freeze_mode variable is used to track
189 * whether the actual locks are held by the child process or not.
192 if (ctdb->freeze_mode[priority] != CTDB_FREEZE_FROZEN) {
193 DEBUG(DEBUG_ERR, ("Attempt to mark all databases locked when not frozen\n"));
197 return ctdb_db_iterator(ctdb, priority, db_lock_mark_handler, NULL);
200 static int ctdb_lockall_mark(struct ctdb_context *ctdb)
204 for (priority=1; priority<=NUM_DB_PRIORITIES; priority++) {
205 if (ctdb_db_iterator(ctdb, priority, db_lock_mark_handler, NULL) != 0) {
215 * lock all databases - unmark only
217 static int db_lock_unmark_handler(struct ctdb_db_context *ctdb_db, uint32_t priority,
220 int tdb_transaction_write_lock_unmark(struct tdb_context *);
222 DEBUG(DEBUG_INFO, ("unmarking locked database %s, priority:%u\n",
223 ctdb_db->db_name, priority));
225 if (tdb_transaction_write_lock_unmark(ctdb_db->ltdb->tdb) != 0) {
226 DEBUG(DEBUG_ERR, ("Failed to unmark (transaction lock) database %s\n",
231 if (tdb_lockall_unmark(ctdb_db->ltdb->tdb) != 0) {
232 DEBUG(DEBUG_ERR, ("Failed to unmark (all lock) database %s\n",
240 int ctdb_lockall_unmark_prio(struct ctdb_context *ctdb, uint32_t priority)
243 * This function is only used by the main daemon during recovery.
244 * At this stage, the databases have already been locked, by a
245 * dedicated child process. The freeze_mode variable is used to track
246 * whether the actual locks are held by the child process or not.
249 if (ctdb->freeze_mode[priority] != CTDB_FREEZE_FROZEN) {
250 DEBUG(DEBUG_ERR, ("Attempt to unmark all databases locked when not frozen\n"));
254 return ctdb_db_iterator(ctdb, priority, db_lock_unmark_handler, NULL);
257 static int ctdb_lockall_unmark(struct ctdb_context *ctdb)
261 for (priority=NUM_DB_PRIORITIES; priority>0; priority--) {
262 if (ctdb_db_iterator(ctdb, priority, db_lock_unmark_handler, NULL) != 0) {
271 static void ctdb_lock_schedule(struct ctdb_context *ctdb);
274 * Destructor to kill the child locking process
276 static int ctdb_lock_context_destructor(struct lock_context *lock_ctx)
278 if (lock_ctx->child > 0) {
279 ctdb_kill(lock_ctx->ctdb, lock_ctx->child, SIGKILL);
280 DLIST_REMOVE(lock_ctx->ctdb->lock_current, lock_ctx);
281 if (lock_ctx->ctdb_db) {
282 lock_ctx->ctdb_db->lock_num_current--;
284 CTDB_DECREMENT_STAT(lock_ctx->ctdb, locks.num_current);
285 if (lock_ctx->type == LOCK_RECORD || lock_ctx->type == LOCK_DB) {
286 CTDB_DECREMENT_DB_STAT(lock_ctx->ctdb_db, locks.num_current);
289 DLIST_REMOVE(lock_ctx->ctdb->lock_pending, lock_ctx);
290 lock_ctx->ctdb->lock_num_pending--;
291 CTDB_DECREMENT_STAT(lock_ctx->ctdb, locks.num_pending);
292 if (lock_ctx->type == LOCK_RECORD || lock_ctx->type == LOCK_DB) {
293 CTDB_DECREMENT_DB_STAT(lock_ctx->ctdb_db, locks.num_pending);
297 ctdb_lock_schedule(lock_ctx->ctdb);
304 * Destructor to remove lock request
306 static int ctdb_lock_request_destructor(struct lock_request *lock_request)
308 DLIST_REMOVE(lock_request->lctx->req_queue, lock_request);
313 void ctdb_lock_free_request_context(struct lock_request *lock_req)
315 struct lock_context *lock_ctx;
317 lock_ctx = lock_req->lctx;
318 talloc_free(lock_req);
319 talloc_free(lock_ctx);
324 * Process all the callbacks waiting for lock
326 * If lock has failed, callback is executed with locked=false
328 static void process_callbacks(struct lock_context *lock_ctx, bool locked)
330 struct lock_request *request, *next;
332 if (lock_ctx->auto_mark && locked) {
333 switch (lock_ctx->type) {
335 tdb_chainlock_mark(lock_ctx->ctdb_db->ltdb->tdb, lock_ctx->key);
339 tdb_lockall_mark(lock_ctx->ctdb_db->ltdb->tdb);
342 case LOCK_ALLDB_PRIO:
343 ctdb_lockall_mark_prio(lock_ctx->ctdb, lock_ctx->priority);
347 ctdb_lockall_mark(lock_ctx->ctdb);
352 /* Iterate through all callbacks */
353 request = lock_ctx->req_queue;
355 if (lock_ctx->auto_mark) {
356 /* Reset the destructor, so request is not removed from the list */
357 talloc_set_destructor(request, NULL);
360 /* In case, callback frees the request, store next */
361 next = request->next;
362 request->callback(request->private_data, locked);
366 if (lock_ctx->auto_mark && locked) {
367 switch (lock_ctx->type) {
369 tdb_chainlock_unmark(lock_ctx->ctdb_db->ltdb->tdb, lock_ctx->key);
373 tdb_lockall_unmark(lock_ctx->ctdb_db->ltdb->tdb);
376 case LOCK_ALLDB_PRIO:
377 ctdb_lockall_unmark_prio(lock_ctx->ctdb, lock_ctx->priority);
381 ctdb_lockall_unmark(lock_ctx->ctdb);
388 static int lock_bucket_id(double t)
390 double ms = 1.e-3, s = 1;
395 } else if (t < 10*ms) {
397 } else if (t < 100*ms) {
399 } else if (t < 1*s) {
401 } else if (t < 2*s) {
403 } else if (t < 4*s) {
405 } else if (t < 8*s) {
407 } else if (t < 16*s) {
409 } else if (t < 32*s) {
411 } else if (t < 64*s) {
421 * Callback routine when the required locks are obtained.
422 * Called from parent context
424 static void ctdb_lock_handler(struct tevent_context *ev,
425 struct tevent_fd *tfd,
429 struct lock_context *lock_ctx;
430 TALLOC_CTX *tmp_ctx = NULL;
436 lock_ctx = talloc_get_type_abort(private_data, struct lock_context);
438 /* cancel the timeout event */
439 if (lock_ctx->ttimer) {
440 TALLOC_FREE(lock_ctx->ttimer);
443 t = timeval_elapsed(&lock_ctx->start_time);
444 id = lock_bucket_id(t);
446 if (lock_ctx->auto_mark) {
447 tmp_ctx = talloc_new(ev);
448 talloc_steal(tmp_ctx, lock_ctx);
451 /* Read the status from the child process */
452 if (read(lock_ctx->fd[0], &c, 1) != 1) {
455 locked = (c == 0 ? true : false);
458 /* Update statistics */
459 CTDB_DECREMENT_STAT(lock_ctx->ctdb, locks.num_pending);
460 CTDB_INCREMENT_STAT(lock_ctx->ctdb, locks.num_calls);
461 if (lock_ctx->ctdb_db) {
462 CTDB_DECREMENT_DB_STAT(lock_ctx->ctdb_db, locks.num_pending);
463 CTDB_INCREMENT_DB_STAT(lock_ctx->ctdb_db, locks.num_calls);
467 if (lock_ctx->ctdb_db) {
468 CTDB_INCREMENT_STAT(lock_ctx->ctdb, locks.buckets[id]);
469 CTDB_UPDATE_LATENCY(lock_ctx->ctdb, lock_ctx->ctdb_db,
470 lock_type_str[lock_ctx->type], locks.latency,
471 lock_ctx->start_time);
473 CTDB_UPDATE_DB_LATENCY(lock_ctx->ctdb_db, lock_type_str[lock_ctx->type], locks.latency, t);
474 CTDB_INCREMENT_DB_STAT(lock_ctx->ctdb_db, locks.buckets[id]);
477 CTDB_INCREMENT_STAT(lock_ctx->ctdb, locks.num_failed);
478 if (lock_ctx->ctdb_db) {
479 CTDB_INCREMENT_DB_STAT(lock_ctx->ctdb_db, locks.num_failed);
483 process_callbacks(lock_ctx, locked);
485 if (lock_ctx->auto_mark) {
486 talloc_free(tmp_ctx);
492 * Callback routine when required locks are not obtained within timeout
493 * Called from parent context
495 static void ctdb_lock_timeout_handler(struct tevent_context *ev,
496 struct tevent_timer *ttimer,
497 struct timeval current_time,
500 static const char * debug_locks = NULL;
501 struct lock_context *lock_ctx;
502 struct ctdb_context *ctdb;
505 lock_ctx = talloc_get_type_abort(private_data, struct lock_context);
506 ctdb = lock_ctx->ctdb;
508 if (lock_ctx->type == LOCK_RECORD || lock_ctx->type == LOCK_DB) {
510 ("Unable to get %s lock on database %s for %.0lf seconds\n",
511 (lock_ctx->type == LOCK_RECORD ? "RECORD" : "DB"),
512 lock_ctx->ctdb_db->db_name,
513 timeval_elapsed(&lock_ctx->start_time)));
516 ("Unable to get ALLDB locks for %.0lf seconds\n",
517 timeval_elapsed(&lock_ctx->start_time)));
520 /* Fire a child process to find the blocking process. */
521 if (debug_locks == NULL) {
522 debug_locks = getenv("CTDB_DEBUG_LOCKS");
523 if (debug_locks == NULL) {
524 debug_locks = talloc_asprintf(ctdb,
526 getenv("CTDB_BASE"));
529 if (debug_locks != NULL) {
532 execl(debug_locks, debug_locks, NULL);
535 ctdb_track_child(ctdb, pid);
539 " Unable to setup lock debugging - no memory?\n"));
542 /* reset the timeout timer */
543 // talloc_free(lock_ctx->ttimer);
544 lock_ctx->ttimer = tevent_add_timer(ctdb->ev,
546 timeval_current_ofs(10, 0),
547 ctdb_lock_timeout_handler,
552 static int db_count_handler(struct ctdb_db_context *ctdb_db, uint32_t priority,
555 int *count = (int *)private_data;
567 static int db_name_handler(struct ctdb_db_context *ctdb_db, uint32_t priority,
570 struct db_namelist *list = (struct db_namelist *)private_data;
572 list->names[list->n] = talloc_strdup(list->names, ctdb_db->db_path);
578 static char **lock_helper_args(TALLOC_CTX *mem_ctx, struct lock_context *lock_ctx, int fd)
580 struct ctdb_context *ctdb = lock_ctx->ctdb;
584 struct db_namelist list;
586 switch (lock_ctx->type) {
595 case LOCK_ALLDB_PRIO:
597 ctdb_db_iterator(ctdb, lock_ctx->priority, db_count_handler, &nargs);
602 for (priority=1; priority<NUM_DB_PRIORITIES; priority++) {
603 ctdb_db_iterator(ctdb, priority, db_count_handler, &nargs);
608 /* Add extra argument for null termination */
611 args = talloc_array(mem_ctx, char *, nargs);
616 args[0] = talloc_strdup(args, "ctdb_lock_helper");
617 args[1] = talloc_asprintf(args, "%d", getpid());
618 args[2] = talloc_asprintf(args, "%d", fd);
620 switch (lock_ctx->type) {
622 args[3] = talloc_strdup(args, "RECORD");
623 args[4] = talloc_strdup(args, lock_ctx->ctdb_db->db_path);
624 if (lock_ctx->key.dsize == 0) {
625 args[5] = talloc_strdup(args, "NULL");
627 args[5] = hex_encode_talloc(args, lock_ctx->key.dptr, lock_ctx->key.dsize);
632 args[3] = talloc_strdup(args, "DB");
633 args[4] = talloc_strdup(args, lock_ctx->ctdb_db->db_path);
636 case LOCK_ALLDB_PRIO:
637 args[3] = talloc_strdup(args, "DB");
640 ctdb_db_iterator(ctdb, lock_ctx->priority, db_name_handler, &list);
644 args[3] = talloc_strdup(args, "DB");
647 for (priority=1; priority<NUM_DB_PRIORITIES; priority++) {
648 ctdb_db_iterator(ctdb, priority, db_name_handler, &list);
653 /* Make sure last argument is NULL */
654 args[nargs-1] = NULL;
656 for (i=0; i<nargs-1; i++) {
657 if (args[i] == NULL) {
668 * Find the lock context of a given type
670 static struct lock_context *find_lock_context(struct lock_context *lock_list,
671 struct ctdb_db_context *ctdb_db,
677 struct lock_context *lock_ctx;
679 /* Search active locks */
680 for (lock_ctx=lock_list; lock_ctx; lock_ctx=lock_ctx->next) {
681 if (lock_ctx->type != type) {
685 switch (lock_ctx->type) {
687 if (ctdb_db == lock_ctx->ctdb_db &&
688 key_hash == lock_ctx->key_hash) {
694 if (ctdb_db == lock_ctx->ctdb_db) {
699 case LOCK_ALLDB_PRIO:
700 if (priority == lock_ctx->priority) {
711 /* Did not find the lock context we are searching for */
721 * Schedule a new lock child process
722 * Set up callback handler and timeout handler
724 static void ctdb_lock_schedule(struct ctdb_context *ctdb)
726 struct lock_context *lock_ctx, *next_ctx, *active_ctx;
729 const char *helper = BINDIR "/ctdb_lock_helper";
730 static const char *prog = NULL;
736 t = getenv("CTDB_LOCK_HELPER");
738 prog = talloc_strdup(ctdb, t);
740 prog = talloc_strdup(ctdb, helper);
742 CTDB_NO_MEMORY_VOID(ctdb, prog);
745 if (ctdb->lock_pending == NULL) {
749 /* Find a lock context with requests */
750 lock_ctx = ctdb->lock_pending;
751 while (lock_ctx != NULL) {
752 next_ctx = lock_ctx->next;
753 if (! lock_ctx->req_queue) {
754 DEBUG(DEBUG_INFO, ("Removing lock context without lock requests\n"));
755 DLIST_REMOVE(ctdb->lock_pending, lock_ctx);
756 ctdb->lock_num_pending--;
757 CTDB_DECREMENT_STAT(ctdb, locks.num_pending);
758 if (lock_ctx->ctdb_db) {
759 CTDB_DECREMENT_DB_STAT(lock_ctx->ctdb_db, locks.num_pending);
761 talloc_free(lock_ctx);
763 active_ctx = find_lock_context(ctdb->lock_current, lock_ctx->ctdb_db,
764 lock_ctx->key, lock_ctx->priority,
765 lock_ctx->type, lock_ctx->key_hash);
766 if (active_ctx == NULL) {
767 if (lock_ctx->ctdb_db == NULL ||
768 lock_ctx->ctdb_db->lock_num_current < MAX_LOCK_PROCESSES_PER_DB) {
769 /* Found a lock context with lock requests */
774 /* There is already a child waiting for the
775 * same key. So don't schedule another child
782 if (lock_ctx == NULL) {
786 lock_ctx->child = -1;
787 ret = pipe(lock_ctx->fd);
789 DEBUG(DEBUG_ERR, ("Failed to create pipe in ctdb_lock_schedule\n"));
793 set_close_on_exec(lock_ctx->fd[0]);
795 /* Create data for child process */
796 tmp_ctx = talloc_new(lock_ctx);
797 if (tmp_ctx == NULL) {
798 DEBUG(DEBUG_ERR, ("Failed to allocate memory for helper args\n"));
799 close(lock_ctx->fd[0]);
800 close(lock_ctx->fd[1]);
804 /* Create arguments for lock helper */
805 args = lock_helper_args(tmp_ctx, lock_ctx, lock_ctx->fd[1]);
807 DEBUG(DEBUG_ERR, ("Failed to create lock helper args\n"));
808 close(lock_ctx->fd[0]);
809 close(lock_ctx->fd[1]);
810 talloc_free(tmp_ctx);
814 lock_ctx->child = vfork();
816 if (lock_ctx->child == (pid_t)-1) {
817 DEBUG(DEBUG_ERR, ("Failed to create a child in ctdb_lock_schedule\n"));
818 close(lock_ctx->fd[0]);
819 close(lock_ctx->fd[1]);
820 talloc_free(tmp_ctx);
826 if (lock_ctx->child == 0) {
827 ret = execv(prog, args);
829 DEBUG(DEBUG_ERR, ("Failed to execute helper %s (%d, %s)\n",
830 prog, errno, strerror(errno)));
836 ctdb_track_child(ctdb, lock_ctx->child);
837 close(lock_ctx->fd[1]);
839 talloc_set_destructor(lock_ctx, ctdb_lock_context_destructor);
841 talloc_free(tmp_ctx);
843 /* Set up timeout handler */
844 lock_ctx->ttimer = tevent_add_timer(ctdb->ev,
846 timeval_current_ofs(10, 0),
847 ctdb_lock_timeout_handler,
849 if (lock_ctx->ttimer == NULL) {
850 ctdb_kill(ctdb, lock_ctx->child, SIGKILL);
851 lock_ctx->child = -1;
852 talloc_set_destructor(lock_ctx, NULL);
853 close(lock_ctx->fd[0]);
857 /* Set up callback */
858 lock_ctx->tfd = tevent_add_fd(ctdb->ev,
864 if (lock_ctx->tfd == NULL) {
865 TALLOC_FREE(lock_ctx->ttimer);
866 ctdb_kill(ctdb, lock_ctx->child, SIGKILL);
867 lock_ctx->child = -1;
868 talloc_set_destructor(lock_ctx, NULL);
869 close(lock_ctx->fd[0]);
872 tevent_fd_set_auto_close(lock_ctx->tfd);
874 /* Move the context from pending to current */
875 DLIST_REMOVE(ctdb->lock_pending, lock_ctx);
876 ctdb->lock_num_pending--;
877 DLIST_ADD_END(ctdb->lock_current, lock_ctx, NULL);
878 if (lock_ctx->ctdb_db) {
879 lock_ctx->ctdb_db->lock_num_current++;
880 CTDB_INCREMENT_STAT(lock_ctx->ctdb, locks.num_current);
881 CTDB_INCREMENT_DB_STAT(lock_ctx->ctdb_db, locks.num_current);
887 * Lock record / db depending on type
889 static struct lock_request *ctdb_lock_internal(struct ctdb_context *ctdb,
890 struct ctdb_db_context *ctdb_db,
893 void (*callback)(void *, bool),
898 struct lock_context *lock_ctx = NULL;
899 struct lock_request *request;
901 if (callback == NULL) {
902 DEBUG(DEBUG_WARNING, ("No callback function specified, not locking\n"));
906 lock_ctx = talloc_zero(ctdb, struct lock_context);
907 if (lock_ctx == NULL) {
908 DEBUG(DEBUG_ERR, ("Failed to create a new lock context\n"));
912 lock_ctx->type = type;
913 lock_ctx->ctdb = ctdb;
914 lock_ctx->ctdb_db = ctdb_db;
915 lock_ctx->key.dsize = key.dsize;
917 lock_ctx->key.dptr = talloc_memdup(lock_ctx, key.dptr, key.dsize);
918 if (lock_ctx->key.dptr == NULL) {
919 DEBUG(DEBUG_ERR, (__location__ "Memory allocation error\n"));
920 talloc_free(lock_ctx);
923 lock_ctx->key_hash = ctdb_hash(&key);
925 lock_ctx->key.dptr = NULL;
927 lock_ctx->priority = priority;
928 lock_ctx->auto_mark = auto_mark;
930 lock_ctx->child = -1;
932 DLIST_ADD_END(ctdb->lock_pending, lock_ctx, NULL);
933 ctdb->lock_num_pending++;
934 CTDB_INCREMENT_STAT(ctdb, locks.num_pending);
936 CTDB_INCREMENT_DB_STAT(ctdb_db, locks.num_pending);
939 /* Start the timer when we activate the context */
940 lock_ctx->start_time = timeval_current();
942 if ((request = talloc_zero(lock_ctx, struct lock_request)) == NULL) {
943 talloc_free(lock_ctx);
947 request->lctx = lock_ctx;
948 request->callback = callback;
949 request->private_data = private_data;
951 talloc_set_destructor(request, ctdb_lock_request_destructor);
952 DLIST_ADD_END(lock_ctx->req_queue, request, NULL);
954 ctdb_lock_schedule(ctdb);
961 * obtain a lock on a record in a database
963 struct lock_request *ctdb_lock_record(struct ctdb_db_context *ctdb_db,
966 void (*callback)(void *, bool),
969 return ctdb_lock_internal(ctdb_db->ctdb,
981 * obtain a lock on a database
983 struct lock_request *ctdb_lock_db(struct ctdb_db_context *ctdb_db,
985 void (*callback)(void *, bool),
988 return ctdb_lock_internal(ctdb_db->ctdb,
1000 * obtain locks on all databases of specified priority
1002 struct lock_request *ctdb_lock_alldb_prio(struct ctdb_context *ctdb,
1005 void (*callback)(void *, bool),
1008 if (priority < 1 || priority > NUM_DB_PRIORITIES) {
1009 DEBUG(DEBUG_ERR, ("Invalid db priority: %u\n", priority));
1013 return ctdb_lock_internal(ctdb,
1025 * obtain locks on all databases
1027 struct lock_request *ctdb_lock_alldb(struct ctdb_context *ctdb,
1029 void (*callback)(void *, bool),
1032 return ctdb_lock_internal(ctdb,