summaryrefslogtreecommitdiffstats
path: root/ctdb/include/ctdb_private.h
diff options
context:
space:
mode:
authorAmitay Isaacs <amitay@gmail.com>2012-10-11 11:29:29 +1100
committerAmitay Isaacs <amitay@gmail.com>2012-10-20 02:48:44 +1100
commit83306337df00f11dd03e06c2043e2b27b2f0c17c (patch)
tree00e5c68d7a10d8c2a027285a253f01248313682e /ctdb/include/ctdb_private.h
parent1011d10a515f165c29fb5470ad04acf856a6217a (diff)
downloadsamba-83306337df00f11dd03e06c2043e2b27b2f0c17c.tar.gz
samba-83306337df00f11dd03e06c2043e2b27b2f0c17c.tar.xz
samba-83306337df00f11dd03e06c2043e2b27b2f0c17c.zip
ctdbd: locking: Provide non-blocking API for locking of TDB record/db/alldb
This introduces a consistent API for handling locks on single record, complete db or all dbs. The locks are taken out in a child process. In cases of timeout, find the processes that currently hold the lock and log. Callback functions for locking requests take locked boolean to indicate whether the lock was successfully obtained or not. Signed-off-by: Amitay Isaacs <amitay@gmail.com> (This used to be ctdb commit 1af99cf0de9919dd89af1feab6d1bd18b95d82ff)
Diffstat (limited to 'ctdb/include/ctdb_private.h')
-rw-r--r--ctdb/include/ctdb_private.h39
1 files changed, 39 insertions, 0 deletions
diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h
index 5689c58b2f..35a1210c8e 100644
--- a/ctdb/include/ctdb_private.h
+++ b/ctdb/include/ctdb_private.h
@@ -136,6 +136,7 @@ struct ctdb_tunable {
uint32_t db_size_warn;
uint32_t pulldb_preallocation_size;
uint32_t no_ip_takeover_on_disabled;
+ uint32_t deadlock_timeout;
};
/*
@@ -538,6 +539,12 @@ struct ctdb_context {
const char *public_addresses_file;
struct trbt_tree *child_processes;
TALLOC_CTX *debug_hung_script_ctx;
+
+ /* Used for locking record/db/alldb */
+ int lock_num_current;
+ int lock_num_pending;
+ struct lock_context *lock_current;
+ struct lock_context *lock_pending;
};
struct ctdb_db_context {
@@ -1542,4 +1549,36 @@ int32_t ctdb_control_reload_public_ips(struct ctdb_context *ctdb, struct ctdb_re
int ctdb_start_monitoring_interfaces(struct ctdb_context *ctdb);
+/* from server/ctdb_lock.c */
+struct lock_request;
+
+int ctdb_lockall_prio(struct ctdb_context *ctdb, uint32_t priority);
+int ctdb_unlockall_prio(struct ctdb_context *ctdb, uint32_t priority);
+int ctdb_lockall_mark_prio(struct ctdb_context *ctdb, uint32_t priority);
+int ctdb_lockall_unmark_prio(struct ctdb_context *ctdb, uint32_t priority);
+
+void ctdb_lock_free_request_context(struct lock_request *lock_req);
+
+struct lock_request *ctdb_lock_record(struct ctdb_db_context *ctdb_db,
+ TDB_DATA key,
+ bool auto_mark,
+ void (*callback)(void *, bool),
+ void *private_data);
+
+struct lock_request *ctdb_lock_db(struct ctdb_db_context *ctdb_db,
+ bool auto_mark,
+ void (*callback)(void *, bool),
+ void *private_data);
+
+struct lock_request *ctdb_lock_alldb_prio(struct ctdb_context *ctdb,
+ uint32_t priority,
+ bool auto_mark,
+ void (*callback)(void *, bool),
+ void *private_data);
+
+struct lock_request *ctdb_lock_alldb(struct ctdb_context *ctdb,
+ bool auto_mark,
+ void (*callback)(void *, bool),
+ void *private_data);
+
#endif