1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-10 01:18:15 +03:00

ctdb-client: Fix ctdb_ctrl_createdb() to use database flags

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>
This commit is contained in:
Amitay Isaacs 2017-08-18 13:50:39 +10:00 committed by Martin Schwenke
parent 9a92d71270
commit 4bd0a20a75
3 changed files with 16 additions and 19 deletions

View 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;
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;
}
#ifdef TDB_MUTEX_LOCKING
if (!persistent && ctdb->tunable.mutex_enabled == 1) {
tdb_flags |= (TDB_MUTEX_LOCKING | TDB_CLEAR_IF_FIRST);
}
#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) {

View 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);

View 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;