summaryrefslogtreecommitdiffstats
path: root/ctdb/server/ctdb_lock.c
diff options
context:
space:
mode:
authorAmitay Isaacs <amitay@gmail.com>2012-07-11 15:15:41 +1000
committerAmitay Isaacs <amitay@gmail.com>2012-10-20 02:48:45 +1100
commit1d83df75168b5b77531850b0d49d3e9650eefc14 (patch)
tree657b89c62323da0db133e4def4ca8a3f71fcd82f /ctdb/server/ctdb_lock.c
parent3c342074817cb5e0c08219e1d54f343d372ecc82 (diff)
downloadsamba-1d83df75168b5b77531850b0d49d3e9650eefc14.tar.gz
samba-1d83df75168b5b77531850b0d49d3e9650eefc14.tar.xz
samba-1d83df75168b5b77531850b0d49d3e9650eefc14.zip
locking: Add database priority handling for older versions of samba
In samba versions 3.6.x and older, database priorities are not set. later_db() function implements higher database priority (locking order) for these databases - brlock, g_lock, notify_onelevel, serverid, xattr_tdb Signed-off-by: Amitay Isaacs <amitay@gmail.com> (This used to be ctdb commit edbc8a6669b594d3c413d603e1c9fada9244c2ee)
Diffstat (limited to 'ctdb/server/ctdb_lock.c')
-rw-r--r--ctdb/server/ctdb_lock.c61
1 files changed, 61 insertions, 0 deletions
diff --git a/ctdb/server/ctdb_lock.c b/ctdb/server/ctdb_lock.c
index 667c11791c3..fd91c63e890 100644
--- a/ctdb/server/ctdb_lock.c
+++ b/ctdb/server/ctdb_lock.c
@@ -84,6 +84,25 @@ struct lock_request {
/*
+ * Support samba 3.6.x (and older) versions which do not set db priority.
+ *
+ * By default, all databases are set to priority 1. So only when priority
+ * is set to 1, check for databases that need higher priority.
+ */
+static bool later_db(const char *name)
+{
+ if (strstr(name, "brlock") ||
+ strstr(name, "g_lock") ||
+ strstr(name, "notify_onelevel") ||
+ strstr(name, "serverid") ||
+ strstr(name, "xattr_tdb")) {
+ return true;
+ }
+
+ return false;
+}
+
+/*
* lock all databases
*/
int ctdb_lockall_prio(struct ctdb_context *ctdb, uint32_t priority)
@@ -94,6 +113,27 @@ int ctdb_lockall_prio(struct ctdb_context *ctdb, uint32_t priority)
if (ctdb_db->priority != priority) {
continue;
}
+ if (later_db(ctdb_db->db_name)) {
+ continue;
+ }
+ DEBUG(DEBUG_INFO, ("locking database %s, priority:%u\n",
+ ctdb_db->db_name, priority));
+ if (tdb_lockall(ctdb_db->ltdb->tdb) != 0) {
+ DEBUG(DEBUG_ERR, ("Failed to lock database %s\n",
+ ctdb_db->db_name));
+ return -1;
+ }
+ }
+
+ /* If priority != 1, later_db check is not required and can return */
+ if (priority != 1) {
+ return 0;
+ }
+
+ for (ctdb_db = ctdb->db_list; ctdb_db; ctdb_db = ctdb_db->next) {
+ if (!later_db(ctdb_db->db_name)) {
+ continue;
+ }
DEBUG(DEBUG_INFO, ("locking database %s, priority:%u\n",
ctdb_db->db_name, priority));
if (tdb_lockall(ctdb_db->ltdb->tdb) != 0) {
@@ -181,6 +221,27 @@ int ctdb_lockall_mark_prio(struct ctdb_context *ctdb, uint32_t priority)
if (ctdb_db->priority != priority) {
continue;
}
+ if (later_db(ctdb_db->db_name)) {
+ continue;
+ }
+ if (tdb_transaction_write_lock_mark(ctdb_db->ltdb->tdb) != 0) {
+ return -1;
+ }
+ if (tdb_lockall_mark(ctdb_db->ltdb->tdb) != 0) {
+ /* FIXME: Shouldn't we unmark here? */
+ return -1;
+ }
+ }
+
+ /* If priority != 1, later_db check is not required and can return */
+ if (priority != 1) {
+ return 0;
+ }
+
+ for (ctdb_db = ctdb->db_list; ctdb_db; ctdb_db = ctdb_db->next) {
+ if (!later_db(ctdb_db->db_name)) {
+ continue;
+ }
if (tdb_transaction_write_lock_mark(ctdb_db->ltdb->tdb) != 0) {
return -1;
}