ctdb-daemon: Support per-node robust mutex feature
authorAmitay Isaacs <amitay@gmail.com>
Sun, 10 Nov 2013 13:32:31 +0000 (00:32 +1100)
committerAmitay Isaacs <amitay@samba.org>
Wed, 9 Jul 2014 04:45:17 +0000 (06:45 +0200)
To enable TDB mutex support, set tunable TDBMutexEnabled=1.

When databases are attached for the first time, attach flags must include
TDB_MUTEX_LOCKING and TDBMutexEnabled must set to enable mutex support.

However, when CTDB attaches databases internally for recovery, it will
enable mutex support if TDBMutexEnabled is set.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Autobuild-User(master): Amitay Isaacs <amitay@samba.org>
Autobuild-Date(master): Wed Jul  9 06:45:17 CEST 2014 on sn-devel-104

ctdb/client/ctdb_client.c
ctdb/include/ctdb_private.h
ctdb/server/ctdb_ltdb_server.c
ctdb/server/ctdb_tunables.c

index c8ab1cd6cb1b9bac33e879fd03fac770c88400d2..df57302de0481839406b178c51ca2b354d91810d 100644 (file)
@@ -1926,6 +1926,12 @@ int ctdb_ctrl_createdb(struct ctdb_context *ctdb, struct timeval timeout, uint32
                tdb_flags = TDB_INCOMPATIBLE_HASH;
        }
 
+#ifdef TDB_MUTEX_LOCKING
+       if (!persistent && ctdb->tunable.mutex_enabled == 1) {
+               tdb_flags |= TDB_MUTEX_LOCKING;
+       }
+#endif
+
        ret = ctdb_control(ctdb, destnode, tdb_flags,
                           persistent?CTDB_CONTROL_DB_ATTACH_PERSISTENT:CTDB_CONTROL_DB_ATTACH, 
                           0, data, 
@@ -2073,6 +2079,12 @@ struct ctdb_db_context *ctdb_attach(struct ctdb_context *ctdb,
                tdb_flags |= TDB_INCOMPATIBLE_HASH;
        }
 
+#ifdef TDB_MUTEX_LOCKING
+       if (!persistent && ctdb->tunable.mutex_enabled == 1) {
+               tdb_flags |= TDB_MUTEX_LOCKING;
+       }
+#endif
+
        /* tell ctdb daemon to attach */
        ret = ctdb_control(ctdb, CTDB_CURRENT_NODE, tdb_flags, 
                           persistent?CTDB_CONTROL_DB_ATTACH_PERSISTENT:CTDB_CONTROL_DB_ATTACH,
index aeebed1b51679a271bb259d69e37bc2a57ff0420..e94d2c84f67b01a5013786f68c9427a67a7fe51f 100644 (file)
@@ -126,6 +126,7 @@ struct ctdb_tunable {
        uint32_t pulldb_preallocation_size;
        uint32_t no_ip_host_on_all_disabled;
        uint32_t samba3_hack;
+       uint32_t mutex_enabled;
 };
 
 /*
index afa33d148522ce2ceaaa504fc8b3b4e1e348b92e..55abf1f54400c74f849eedbd1fc5e121b8b9370d 100644 (file)
@@ -837,7 +837,8 @@ static int ctdb_local_attach(struct ctdb_context *ctdb, const char *db_name,
                tdb_flags |= TDB_INCOMPATIBLE_HASH;
        }
 #ifdef TDB_MUTEX_LOCKING
-       if (mutexes && tdb_runtime_check_for_robust_mutexes()) {
+       if (ctdb->tunable.mutex_enabled && mutexes &&
+           tdb_runtime_check_for_robust_mutexes()) {
                tdb_flags |= TDB_MUTEX_LOCKING;
        }
 #endif
index f760cb57bd6bc21a0df80cd87f315a1b11aac8af..4a252b61adadc9656b72f427c0090f52c3827d82 100644 (file)
@@ -82,6 +82,7 @@ static const struct {
        { "PullDBPreallocation", 10*1024*1024,  offsetof(struct ctdb_tunable, pulldb_preallocation_size), false },
        { "NoIPHostOnAllDisabled",    0,  offsetof(struct ctdb_tunable, no_ip_host_on_all_disabled), false },
        { "Samba3AvoidDeadlocks", 0, offsetof(struct ctdb_tunable, samba3_hack), false },
+       { "TDBMutexEnabled", 0, offsetof(struct ctdb_tunable, mutex_enabled), false },
 };
 
 /*