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)
committerMartin Schwenke <martins@samba.org>
Fri, 25 Aug 2017 07:41:25 +0000 (09:41 +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>
ctdb/client/ctdb_client.c
ctdb/include/ctdb_client.h
ctdb/server/ctdb_recoverd.c

index 47f99bc08b53cf9e2b957cad317acbd1639e5e7b..74874bab2b288b6ff94cc1159794251a247fc842 100644 (file)
@@ -1910,31 +1910,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 329e3544ab617123a034f9b7bc88bb0128cc46e6..8aaf9c4d64352448bd5599c5db0588a5d65f59b1 100644 (file)
@@ -251,7 +251,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;