summaryrefslogtreecommitdiffstats
path: root/ctdb/server/ctdb_lock.c
diff options
context:
space:
mode:
authorAmitay Isaacs <amitay@gmail.com>2013-01-04 14:32:55 +1100
committerMichael Adam <obnox@samba.org>2013-01-05 01:14:57 +0100
commita73f13ada7acf1cad75851264357d9ca6ccdec4b (patch)
tree2eff321105943566742b7b62a1b4ae8895ed4a66 /ctdb/server/ctdb_lock.c
parent13518b9e331b44981906d92c6cbe3a8ed3c5474a (diff)
downloadsamba-a73f13ada7acf1cad75851264357d9ca6ccdec4b.tar.gz
samba-a73f13ada7acf1cad75851264357d9ca6ccdec4b.tar.xz
samba-a73f13ada7acf1cad75851264357d9ca6ccdec4b.zip
daemon: Add a tunable to enable automatic database priority setting
Samba versions 3.6.x and older do not set the database priority. This can cause deadlock between Samba and CTDB since the locking order of database will be different. A hack was added for automatic promotion of priority for specific databases to avoid deadlock. This code should not be invoked with Samba version 4.x which correctly specifies the priority for each database. Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Michael Adam <obnox@samba.org> (This used to be ctdb commit 4a9e96ad3d8fc46da1cd44cd82309c1b54301eb7)
Diffstat (limited to 'ctdb/server/ctdb_lock.c')
-rw-r--r--ctdb/server/ctdb_lock.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/ctdb/server/ctdb_lock.c b/ctdb/server/ctdb_lock.c
index e78f3fc15fb..8a2ba5cded6 100644
--- a/ctdb/server/ctdb_lock.c
+++ b/ctdb/server/ctdb_lock.c
@@ -96,8 +96,12 @@ struct lock_request {
* 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)
+static bool later_db(struct ctdb_context *ctdb, const char *name)
{
+ if (ctdb->tunable.samba3_hack == 0) {
+ return false;
+ }
+
if (strstr(name, "brlock") ||
strstr(name, "g_lock") ||
strstr(name, "notify_onelevel") ||
@@ -120,7 +124,7 @@ int ctdb_lockall_prio(struct ctdb_context *ctdb, uint32_t priority)
if (ctdb_db->priority != priority) {
continue;
}
- if (later_db(ctdb_db->db_name)) {
+ if (later_db(ctdb, ctdb_db->db_name)) {
continue;
}
DEBUG(DEBUG_INFO, ("locking database %s, priority:%u\n",
@@ -138,7 +142,7 @@ int ctdb_lockall_prio(struct ctdb_context *ctdb, uint32_t priority)
}
for (ctdb_db = ctdb->db_list; ctdb_db; ctdb_db = ctdb_db->next) {
- if (!later_db(ctdb_db->db_name)) {
+ if (!later_db(ctdb, ctdb_db->db_name)) {
continue;
}
DEBUG(DEBUG_INFO, ("locking database %s, priority:%u\n",
@@ -228,7 +232,7 @@ 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)) {
+ if (later_db(ctdb, ctdb_db->db_name)) {
continue;
}
if (tdb_transaction_write_lock_mark(ctdb_db->ltdb->tdb) != 0) {
@@ -246,7 +250,7 @@ int ctdb_lockall_mark_prio(struct ctdb_context *ctdb, uint32_t priority)
}
for (ctdb_db = ctdb->db_list; ctdb_db; ctdb_db = ctdb_db->next) {
- if (!later_db(ctdb_db->db_name)) {
+ if (!later_db(ctdb, ctdb_db->db_name)) {
continue;
}
if (tdb_transaction_write_lock_mark(ctdb_db->ltdb->tdb) != 0) {