]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ctdb-client: Fix ctdb_ctrl_createdb() to use database flags
authorAmitay Isaacs <amitay@gmail.com>
Fri, 18 Aug 2017 03:50:39 +0000 (13:50 +1000)
committerKarolin Seeger <kseeger@samba.org>
Mon, 28 Aug 2017 09:04:16 +0000 (11:04 +0200)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12978

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
(cherry picked from commit 4bd0a20a75db3b3c409c25a4bc59aed30464f047)

ctdb/client/ctdb_client.c
ctdb/include/ctdb_client.h
ctdb/server/ctdb_recoverd.c

index 5ec3d0043f3dd3943f8bc4c44bd11334cd44fc01..575ed56ce69c8f543e534a91c87685bb654bd6ca 100644 (file)
@@ -1947,31 +1947,27 @@ int ctdb_ctrl_getdbseqnum(struct ctdb_context *ctdb, struct timeval timeout,
 /*
   create a database
  */
-int ctdb_ctrl_createdb(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, 
-                      TALLOC_CTX *mem_ctx, const char *name, bool persistent)
+int ctdb_ctrl_createdb(struct ctdb_context *ctdb, struct timeval timeout,
+                      uint32_t destnode, TALLOC_CTX *mem_ctx,
+                      const char *name, uint8_t db_flags)
 {
        int ret;
        int32_t res;
        TDB_DATA data;
-       uint64_t tdb_flags = 0;
+       uint32_t opcode;
 
        data.dptr = discard_const(name);
        data.dsize = strlen(name)+1;
 
-       /* Make sure that volatile databases use jenkins hash */
-       if (!persistent) {
-               tdb_flags = TDB_INCOMPATIBLE_HASH;
-       }
-
-#ifdef TDB_MUTEX_LOCKING
-       if (!persistent && ctdb->tunable.mutex_enabled == 1) {
-               tdb_flags |= (TDB_MUTEX_LOCKING | TDB_CLEAR_IF_FIRST);
+       if (db_flags & CTDB_DB_FLAGS_PERSISTENT) {
+               opcode = CTDB_CONTROL_DB_ATTACH_PERSISTENT;
+       } else if (db_flags & CTDB_DB_FLAGS_REPLICATED) {
+               opcode = CTDB_CONTROL_DB_ATTACH_REPLICATED;
+       } else {
+               opcode = CTDB_CONTROL_DB_ATTACH;
        }
-#endif
 
-       ret = ctdb_control(ctdb, destnode, tdb_flags,
-                          persistent?CTDB_CONTROL_DB_ATTACH_PERSISTENT:CTDB_CONTROL_DB_ATTACH, 
-                          0, data, 
+       ret = ctdb_control(ctdb, destnode, 0, opcode, 0, data,
                           mem_ctx, &data, &res, &timeout, NULL);
 
        if (ret != 0 || res != 0) {
index d4fd77142ecfde6fe7bbbccf89db04126504cdca..8f270ddaa4e657d98caae4e75c49fcbdd0c00ad5 100644 (file)
@@ -254,7 +254,7 @@ int ctdb_ctrl_getdbseqnum(struct ctdb_context *ctdb, struct timeval timeout,
 
 int ctdb_ctrl_createdb(struct ctdb_context *ctdb, struct timeval timeout,
                       uint32_t destnode, TALLOC_CTX *mem_ctx,
-                      const char *name, bool persistent);
+                      const char *name, uint8_t db_flags);
 
 int ctdb_ctrl_get_debuglevel(struct ctdb_context *ctdb, uint32_t destnode,
                             int32_t *level);
index b57be0634b8ac44d18b921eb519dc81a5a50d31b..05aee463bef55573e11577f01254b5a807d9689c 100644 (file)
@@ -472,7 +472,7 @@ static int create_missing_remote_databases(struct ctdb_context *ctdb, struct ctd
                        ret = ctdb_ctrl_createdb(ctdb, CONTROL_TIMEOUT(),
                                                 nodemap->nodes[j].pnn,
                                                 mem_ctx, name,
-                                                dbmap->dbs[db].flags & CTDB_DB_FLAGS_PERSISTENT);
+                                                dbmap->dbs[db].flags);
                        if (ret != 0) {
                                DEBUG(DEBUG_ERR, (__location__ " Unable to create remote db:%s\n", name));
                                return -1;
@@ -534,8 +534,9 @@ static int create_missing_local_databases(struct ctdb_context *ctdb, struct ctdb
                                          nodemap->nodes[j].pnn));
                                return -1;
                        }
-                       ctdb_ctrl_createdb(ctdb, CONTROL_TIMEOUT(), pnn, mem_ctx, name, 
-                                          remote_dbmap->dbs[db].flags & CTDB_DB_FLAGS_PERSISTENT);
+                       ctdb_ctrl_createdb(ctdb, CONTROL_TIMEOUT(), pnn,
+                                          mem_ctx, name,
+                                          remote_dbmap->dbs[db].flags);
                        if (ret != 0) {
                                DEBUG(DEBUG_ERR, (__location__ " Unable to create local db:%s\n", name));
                                return -1;