[SCM] Samba Shared Repository - branch master updated
Martin Schwenke
martins at samba.org
Mon Jun 26 18:11:02 UTC 2017
The branch, master has been updated
via bcfa12c ctdb-protocol: Do not pass tdb open flags to DB attach controls
via 4760fff ctdb-client: Do not pass tdb open flags to db attach api
via 38d14fc ctdb-client: Remove calaculation of tdb flags
via 17ca4af ctdb-client: Ask daemon for db open flags
via 43ca0e3 ctdb-client: Ask daemon for db open flags
via 45ac7b3 ctdb-client: Add a function to get db open flags
via 1b0cd3c ctdb-client: Add sync api for control DB_OPEN_FLAGS
via 339b818 ctdb-protocol: Add protocol marshalling for control DB_OPEN_FLAGS
via 0b60752 ctdb-daemon: Implement DB_OPEN_FLAGS control
via af2b06a ctdb-protocol: Add new control to get database open flags
via 8d3f2f6 ctdb-daemon: Drop extra boolean arguments to ctdb_local_attach()
via ea91967 ctdb-client: Drop tdb_flags argument to ctdb_attach()
via 2100008 ctdb-client: Stop sending tdb_flags with DB_ATTACH controls
via 2a33dfc ctdb-daemon: Ignore tdb open flags passed to DB attach controls
via 1be2ff8 ctdb-daemon: Refactor calculation of tdb open flags based on database type
via 45ea951 ctdb-locking: Get tdb open flags from tdb instead of re-calculating
via f5e53f6 ctdb-daemon: Store tdb flags just after tdb is opened in ctdb_local_attach()
via 529142a ctdb-daemon: Once database is attached, do not modify tdb flags
from 27e43e1 auth/ntlmssp: make ntlmssp_server_check_password() shorter
https://git.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit bcfa12c5b26502230a9c27492cf3a607fc41939d
Author: Amitay Isaacs <amitay at gmail.com>
Date: Tue Mar 21 15:02:56 2017 +1100
ctdb-protocol: Do not pass tdb open flags to DB attach controls
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Martin Schwenke <martin at meltin.net>
Autobuild-User(master): Martin Schwenke <martins at samba.org>
Autobuild-Date(master): Mon Jun 26 20:10:38 CEST 2017 on sn-devel-144
commit 4760fff3ae12673fe6db98a9e1c7f883ffacb75e
Author: Amitay Isaacs <amitay at gmail.com>
Date: Tue Mar 21 15:03:24 2017 +1100
ctdb-client: Do not pass tdb open flags to db attach api
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Martin Schwenke <martin at meltin.net>
commit 38d14fcf29d0f22ca8ea782c6515c1f358b0c3cf
Author: Amitay Isaacs <amitay at gmail.com>
Date: Fri Jun 23 16:29:39 2017 +1000
ctdb-client: Remove calaculation of tdb flags
... and there is no need to find out if mutexes are enabled.
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Martin Schwenke <martin at meltin.net>
commit 17ca4af390837d7f2e9dcaa64069e0aa0902f674
Author: Amitay Isaacs <amitay at gmail.com>
Date: Fri Jun 23 16:27:20 2017 +1000
ctdb-client: Ask daemon for db open flags
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Martin Schwenke <martin at meltin.net>
commit 43ca0e3d226dea933bcdb145e37e301e4711d181
Author: Amitay Isaacs <amitay at gmail.com>
Date: Fri Jun 23 16:15:57 2017 +1000
ctdb-client: Ask daemon for db open flags
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Martin Schwenke <martin at meltin.net>
commit 45ac7b357ae69abeafdfc0f92a8fddc87f65f264
Author: Amitay Isaacs <amitay at gmail.com>
Date: Fri Jun 23 16:11:53 2017 +1000
ctdb-client: Add a function to get db open flags
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Martin Schwenke <martin at meltin.net>
commit 1b0cd3c280fe3c4d4bd9f75e801780fb332a7afe
Author: Amitay Isaacs <amitay at gmail.com>
Date: Wed Jun 14 16:37:34 2017 +1000
ctdb-client: Add sync api for control DB_OPEN_FLAGS
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Martin Schwenke <martin at meltin.net>
commit 339b818e56c143a7125491c6394677b0e2069d98
Author: Amitay Isaacs <amitay at gmail.com>
Date: Wed Jun 14 16:24:02 2017 +1000
ctdb-protocol: Add protocol marshalling for control DB_OPEN_FLAGS
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Martin Schwenke <martin at meltin.net>
commit 0b607528ff87c6953c02fd057a2b26815f154d88
Author: Amitay Isaacs <amitay at gmail.com>
Date: Wed Jun 14 16:30:39 2017 +1000
ctdb-daemon: Implement DB_OPEN_FLAGS control
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Martin Schwenke <martin at meltin.net>
commit af2b06af75f7202423588d004771892a9ab2cd68
Author: Amitay Isaacs <amitay at gmail.com>
Date: Wed Jun 14 16:22:52 2017 +1000
ctdb-protocol: Add new control to get database open flags
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Martin Schwenke <martin at meltin.net>
commit 8d3f2f691e1b95fea3965ab40084e327780ff0d5
Author: Amitay Isaacs <amitay at gmail.com>
Date: Thu Mar 2 14:47:20 2017 +1100
ctdb-daemon: Drop extra boolean arguments to ctdb_local_attach()
There is no need for with_jenkinshash and with_mutexes flags, since the
tdb_flags are now calculated based on database type.
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Martin Schwenke <martin at meltin.net>
commit ea91967b0df5f260f7da6532628f015f26f6d0e0
Author: Amitay Isaacs <amitay at gmail.com>
Date: Fri Jun 23 15:59:16 2017 +1000
ctdb-client: Drop tdb_flags argument to ctdb_attach()
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Martin Schwenke <martin at meltin.net>
commit 2100008f81ee3cdb0024b1f2f20eae434083b846
Author: Amitay Isaacs <amitay at gmail.com>
Date: Fri Jun 23 15:58:38 2017 +1000
ctdb-client: Stop sending tdb_flags with DB_ATTACH controls
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Martin Schwenke <martin at meltin.net>
commit 2a33dfc4fb1cac6160cd120bbc85c7c87777d253
Author: Amitay Isaacs <amitay at gmail.com>
Date: Tue Mar 28 17:14:51 2017 +1100
ctdb-daemon: Ignore tdb open flags passed to DB attach controls
The tdb open flags should be calculated based on the database type and
ctdb tunables.
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Martin Schwenke <martin at meltin.net>
commit 1be2ff8b81871c1e2ff8721a0174862573edec38
Author: Amitay Isaacs <amitay at gmail.com>
Date: Tue Mar 21 13:50:07 2017 +1100
ctdb-daemon: Refactor calculation of tdb open flags based on database type
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Martin Schwenke <martin at meltin.net>
commit 45ea95126e370d09f392e79dc8deeac7804636e5
Author: Amitay Isaacs <amitay at gmail.com>
Date: Thu Mar 2 15:37:19 2017 +1100
ctdb-locking: Get tdb open flags from tdb instead of re-calculating
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Martin Schwenke <martin at meltin.net>
commit f5e53f60b8af0239070e6e43c10d289c7a5ca174
Author: Amitay Isaacs <amitay at gmail.com>
Date: Thu Mar 2 14:52:00 2017 +1100
ctdb-daemon: Store tdb flags just after tdb is opened in ctdb_local_attach()
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Martin Schwenke <martin at meltin.net>
commit 529142a7595a885541238ecba92c776927c243ae
Author: Amitay Isaacs <amitay at gmail.com>
Date: Thu Mar 2 11:15:26 2017 +1100
ctdb-daemon: Once database is attached, do not modify tdb flags
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Martin Schwenke <martin at meltin.net>
-----------------------------------------------------------------------
Summary of changes:
ctdb/client/client_control_sync.c | 39 +++++++++++--
ctdb/client/client_db.c | 103 +++++++++++++++-------------------
ctdb/client/client_sync.h | 11 ++--
ctdb/client/ctdb_client.c | 88 ++++++++++++++---------------
ctdb/common/common.h | 2 +
ctdb/common/ctdb_ltdb.c | 31 ++++++++++
ctdb/include/ctdb_client.h | 6 +-
ctdb/include/ctdb_private.h | 2 +-
ctdb/protocol/protocol.h | 2 +
ctdb/protocol/protocol_api.h | 10 +++-
ctdb/protocol/protocol_client.c | 37 ++++++++++--
ctdb/protocol/protocol_control.c | 26 +++++++++
ctdb/server/ctdb_control.c | 28 ++++++++-
ctdb/server/ctdb_lock.c | 16 +-----
ctdb/server/ctdb_ltdb_server.c | 59 ++++++-------------
ctdb/server/ctdb_recoverd.c | 2 +-
ctdb/tests/cunit/protocol_test_002.sh | 2 +-
ctdb/tests/src/protocol_client_test.c | 18 +++++-
18 files changed, 297 insertions(+), 185 deletions(-)
Changeset truncated at 500 lines:
diff --git a/ctdb/client/client_control_sync.c b/ctdb/client/client_control_sync.c
index 3b44c2f..db2d7be 100644
--- a/ctdb/client/client_control_sync.c
+++ b/ctdb/client/client_control_sync.c
@@ -415,14 +415,13 @@ int ctdb_ctrl_statistics_reset(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
int ctdb_ctrl_db_attach(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
struct ctdb_client_context *client,
int destnode, struct timeval timeout,
- const char *db_name, uint32_t tdb_flags,
- uint32_t *db_id)
+ const char *db_name, uint32_t *db_id)
{
struct ctdb_req_control request;
struct ctdb_reply_control *reply;
int ret;
- ctdb_req_control_db_attach(&request, db_name, tdb_flags);
+ ctdb_req_control_db_attach(&request, db_name);
ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
&request, &reply);
if (ret != 0) {
@@ -1121,14 +1120,13 @@ int ctdb_ctrl_db_attach_persistent(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
struct ctdb_client_context *client,
int destnode, struct timeval timeout,
- const char *db_name, int tdb_flags,
- uint32_t *db_id)
+ const char *db_name, uint32_t *db_id)
{
struct ctdb_req_control request;
struct ctdb_reply_control *reply;
int ret;
- ctdb_req_control_db_attach_persistent(&request, db_name, tdb_flags);
+ ctdb_req_control_db_attach_persistent(&request, db_name);
ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
&request, &reply);
if (ret != 0) {
@@ -2701,3 +2699,32 @@ int ctdb_ctrl_db_push_confirm(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
return 0;
}
+
+int ctdb_ctrl_db_open_flags(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
+ struct ctdb_client_context *client,
+ int destnode, struct timeval timeout,
+ uint32_t db_id, int *tdb_flags)
+{
+ struct ctdb_req_control request;
+ struct ctdb_reply_control *reply;
+ int ret;
+
+ ctdb_req_control_db_open_flags(&request, db_id);
+ ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
+ &request, &reply);
+ if (ret != 0) {
+ DEBUG(DEBUG_ERR,
+ ("Control DB_OPEN_FLAGS failed to node %u, ret=%d\n",
+ destnode, ret));
+ return ret;
+ }
+
+ ret = ctdb_reply_control_db_open_flags(reply, tdb_flags);
+ if (ret != 0) {
+ DEBUG(DEBUG_ERR,
+ ("Control DB_OPEN_FLAGS failed, ret=%d\n", ret));
+ return ret;
+ }
+
+ return 0;
+}
diff --git a/ctdb/client/client_db.c b/ctdb/client/client_db.c
index a0a884f..8cf08ae 100644
--- a/ctdb/client/client_db.c
+++ b/ctdb/client/client_db.c
@@ -253,15 +253,14 @@ struct ctdb_attach_state {
struct timeval timeout;
uint32_t destnode;
uint8_t db_flags;
- uint32_t tdb_flags;
struct ctdb_db_context *db;
};
-static void ctdb_attach_mutex_done(struct tevent_req *subreq);
static void ctdb_attach_dbid_done(struct tevent_req *subreq);
static void ctdb_attach_dbpath_done(struct tevent_req *subreq);
static void ctdb_attach_health_done(struct tevent_req *subreq);
static void ctdb_attach_flags_done(struct tevent_req *subreq);
+static void ctdb_attach_open_flags_done(struct tevent_req *subreq);
struct tevent_req *ctdb_attach_send(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
@@ -304,71 +303,22 @@ struct tevent_req *ctdb_attach_send(TALLOC_CTX *mem_ctx,
state->db->persistent = true;
}
- ctdb_req_control_get_tunable(&request, "TDBMutexEnabled");
- subreq = ctdb_client_control_send(state, ev, client,
- ctdb_client_pnn(client), timeout,
- &request);
- if (tevent_req_nomem(subreq, req)) {
- return tevent_req_post(req, ev);
- }
- tevent_req_set_callback(subreq, ctdb_attach_mutex_done, req);
-
- return req;
-}
-
-static void ctdb_attach_mutex_done(struct tevent_req *subreq)
-{
- struct tevent_req *req = tevent_req_callback_data(
- subreq, struct tevent_req);
- struct ctdb_attach_state *state = tevent_req_data(
- req, struct ctdb_attach_state);
- struct ctdb_reply_control *reply;
- struct ctdb_req_control request;
- uint32_t mutex_enabled;
- int ret;
- bool status;
-
- status = ctdb_client_control_recv(subreq, &ret, state, &reply);
- TALLOC_FREE(subreq);
- if (! status) {
- DEBUG(DEBUG_ERR, ("attach: %s GET_TUNABLE failed, ret=%d\n",
- state->db->db_name, ret));
- tevent_req_error(req, ret);
- return;
- }
-
- ret = ctdb_reply_control_get_tunable(reply, &mutex_enabled);
- if (ret != 0) {
- /* Treat error as mutex support not available */
- mutex_enabled = 0;
- }
-
- if (state->db->persistent) {
- state->tdb_flags = TDB_DEFAULT;
- } else {
- state->tdb_flags = (TDB_NOSYNC | TDB_INCOMPATIBLE_HASH |
- TDB_CLEAR_IF_FIRST);
- if (mutex_enabled == 1) {
- state->tdb_flags |= TDB_MUTEX_LOCKING;
- }
- }
-
if (state->db->persistent) {
ctdb_req_control_db_attach_persistent(&request,
- state->db->db_name,
- state->tdb_flags);
+ state->db->db_name);
} else {
- ctdb_req_control_db_attach(&request, state->db->db_name,
- state->tdb_flags);
+ ctdb_req_control_db_attach(&request, state->db->db_name);
}
subreq = ctdb_client_control_send(state, state->ev, state->client,
state->destnode, state->timeout,
&request);
if (tevent_req_nomem(subreq, req)) {
- return;
+ return tevent_req_post(req, ev);
}
tevent_req_set_callback(subreq, ctdb_attach_dbid_done, req);
+
+ return req;
}
static void ctdb_attach_dbid_done(struct tevent_req *subreq)
@@ -511,6 +461,7 @@ static void ctdb_attach_flags_done(struct tevent_req *subreq)
subreq, struct tevent_req);
struct ctdb_attach_state *state = tevent_req_data(
req, struct ctdb_attach_state);
+ struct ctdb_req_control request;
bool status;
int ret;
@@ -523,8 +474,46 @@ static void ctdb_attach_flags_done(struct tevent_req *subreq)
return;
}
+ ctdb_req_control_db_open_flags(&request, state->db->db_id);
+ subreq = ctdb_client_control_send(state, state->ev, state->client,
+ state->destnode, state->timeout,
+ &request);
+ if (tevent_req_nomem(subreq, req)) {
+ return;
+ }
+ tevent_req_set_callback(subreq, ctdb_attach_open_flags_done, req);
+}
+
+static void ctdb_attach_open_flags_done(struct tevent_req *subreq)
+{
+ struct tevent_req *req = tevent_req_callback_data(
+ subreq, struct tevent_req);
+ struct ctdb_attach_state *state = tevent_req_data(
+ req, struct ctdb_attach_state);
+ struct ctdb_reply_control *reply;
+ bool status;
+ int ret, tdb_flags;
+
+ status = ctdb_client_control_recv(subreq, &ret, state, &reply);
+ TALLOC_FREE(subreq);
+ if (! status) {
+ DEBUG(DEBUG_ERR, ("attach: %s DB_OPEN_FLAGS failed, ret=%d\n",
+ state->db->db_name, ret));
+ tevent_req_error(req, ret);
+ return;
+ }
+
+ ret = ctdb_reply_control_db_open_flags(reply, &tdb_flags);
+ talloc_free(reply);
+ if (ret != 0) {
+ DEBUG(DEBUG_ERR, ("attach: %s DB_OPEN_FLAGS parse failed,"
+ " ret=%d\n", state->db->db_name, ret));
+ tevent_req_error(req, ret);
+ return;
+ }
+
state->db->ltdb = tdb_wrap_open(state->db, state->db->db_path, 0,
- state->tdb_flags, O_RDWR, 0);
+ tdb_flags, O_RDWR, 0);
if (tevent_req_nomem(state->db->ltdb, req)) {
DEBUG(DEBUG_ERR, ("attach: %s tdb_wrap_open failed\n",
state->db->db_name));
diff --git a/ctdb/client/client_sync.h b/ctdb/client/client_sync.h
index 8c94f12..7bf58e6 100644
--- a/ctdb/client/client_sync.h
+++ b/ctdb/client/client_sync.h
@@ -91,8 +91,7 @@ int ctdb_ctrl_statistics_reset(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
int ctdb_ctrl_db_attach(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
struct ctdb_client_context *client,
int destnode, struct timeval timeout,
- const char *db_name, uint32_t tdb_flags,
- uint32_t *db_id);
+ const char *db_name, uint32_t *db_id);
int ctdb_ctrl_traverse_start(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
struct ctdb_client_context *client,
@@ -216,8 +215,7 @@ int ctdb_ctrl_db_attach_persistent(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
struct ctdb_client_context *client,
int destnode, struct timeval timeout,
- const char *db_name, int tdb_flags,
- uint32_t *db_id);
+ const char *db_name, uint32_t *db_id);
int ctdb_ctrl_send_gratuitous_arp(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
@@ -485,6 +483,11 @@ int ctdb_ctrl_db_push_confirm(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
int destnode, struct timeval timeout,
uint32_t db_id, uint32_t *num_records);
+int ctdb_ctrl_db_open_flags(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
+ struct ctdb_client_context *client,
+ int destnode, struct timeval timeout,
+ uint32_t db_id, int *tdb_flags);
+
/* from client/client_message_sync.c */
int ctdb_message_recd_update_ip(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
diff --git a/ctdb/client/ctdb_client.c b/ctdb/client/ctdb_client.c
index 6ffa0f4..cc23b05 100644
--- a/ctdb/client/ctdb_client.c
+++ b/ctdb/client/ctdb_client.c
@@ -2079,21 +2079,51 @@ int ctdb_statistics_reset(struct ctdb_context *ctdb, uint32_t destnode)
}
/*
+ * Get db open flags
+ */
+int ctdb_ctrl_db_open_flags(struct ctdb_context *ctdb, uint32_t db_id,
+ int *tdb_flags)
+{
+ TDB_DATA indata, outdata;
+ int ret;
+ int32_t res;
+
+ indata.dptr = (uint8_t *)&db_id;
+ indata.dsize = sizeof(db_id);
+
+ ret = ctdb_control(ctdb, CTDB_CURRENT_NODE, 0,
+ CTDB_CONTROL_DB_OPEN_FLAGS, 0, indata,
+ ctdb, &outdata, &res, NULL, NULL);
+ if (ret != 0 || res != 0) {
+ D_ERR("ctdb control for db open flags failed\n");
+ return -1;
+ }
+
+ if (outdata.dsize != sizeof(int32_t)) {
+ D_ERR(__location__ " expected %zi bytes, received %zi bytes\n",
+ sizeof(int32_t), outdata.dsize);
+ talloc_free(outdata.dptr);
+ return -1;
+ }
+
+ *tdb_flags = *(int32_t *)outdata.dptr;
+ talloc_free(outdata.dptr);
+ return 0;
+}
+
+/*
attach to a specific database - client call
*/
struct ctdb_db_context *ctdb_attach(struct ctdb_context *ctdb,
struct timeval timeout,
const char *name,
- bool persistent,
- uint32_t tdb_flags)
+ bool persistent)
{
struct ctdb_db_context *ctdb_db;
TDB_DATA data;
int ret;
int32_t res;
-#ifdef TDB_MUTEX_LOCKING
- uint32_t mutex_enabled = 0;
-#endif
+ int tdb_flags;
ctdb_db = ctdb_db_handle(ctdb, name);
if (ctdb_db) {
@@ -2110,32 +2140,8 @@ struct ctdb_db_context *ctdb_attach(struct ctdb_context *ctdb,
data.dptr = discard_const(name);
data.dsize = strlen(name)+1;
- /* CTDB has switched to using jenkins hash for volatile databases.
- * Even if tdb_flags do not explicitly mention TDB_INCOMPATIBLE_HASH,
- * always set it.
- */
- if (!persistent) {
- tdb_flags |= TDB_INCOMPATIBLE_HASH;
- }
-
-#ifdef TDB_MUTEX_LOCKING
- if (!persistent) {
- ret = ctdb_ctrl_get_tunable(ctdb, timeval_current_ofs(3,0),
- CTDB_CURRENT_NODE,
- "TDBMutexEnabled",
- &mutex_enabled);
- if (ret != 0) {
- DEBUG(DEBUG_WARNING, ("Assuming no mutex support.\n"));
- }
-
- if (mutex_enabled == 1) {
- tdb_flags |= (TDB_MUTEX_LOCKING | TDB_CLEAR_IF_FIRST);
- }
- }
-#endif
-
/* tell ctdb daemon to attach */
- ret = ctdb_control(ctdb, CTDB_CURRENT_NODE, tdb_flags,
+ ret = ctdb_control(ctdb, CTDB_CURRENT_NODE, 0,
persistent?CTDB_CONTROL_DB_ATTACH_PERSISTENT:CTDB_CONTROL_DB_ATTACH,
0, data, ctdb_db, &data, &res, NULL, NULL);
if (ret != 0 || res != 0 || data.dsize != sizeof(uint32_t)) {
@@ -2143,7 +2149,7 @@ struct ctdb_db_context *ctdb_attach(struct ctdb_context *ctdb,
talloc_free(ctdb_db);
return NULL;
}
-
+
ctdb_db->db_id = *(uint32_t *)data.dptr;
talloc_free(data.dptr);
@@ -2154,20 +2160,12 @@ struct ctdb_db_context *ctdb_attach(struct ctdb_context *ctdb,
return NULL;
}
- if (persistent) {
- tdb_flags = TDB_DEFAULT;
- } else {
- tdb_flags = TDB_NOSYNC;
-#ifdef TDB_MUTEX_LOCKING
- if (mutex_enabled) {
- tdb_flags |= (TDB_MUTEX_LOCKING | TDB_CLEAR_IF_FIRST);
- }
-#endif
- }
- if (ctdb->valgrinding) {
- tdb_flags |= TDB_NOMMAP;
+ ret = ctdb_ctrl_db_open_flags(ctdb, ctdb_db->db_id, &tdb_flags);
+ if (ret != 0) {
+ D_ERR("Failed to get tdb_flags for database '%s'\n", name);
+ talloc_free(ctdb_db);
+ return NULL;
}
- tdb_flags |= TDB_DISALLOW_NESTING;
ctdb_db->ltdb = tdb_wrap_open(ctdb_db, ctdb_db->db_path, 0, tdb_flags,
O_RDWR, 0);
@@ -3924,7 +3922,7 @@ struct ctdb_transaction_handle *ctdb_transaction_start(struct ctdb_db_context *c
}
h->g_lock_db = ctdb_attach(h->ctdb_db->ctdb, timeval_current_ofs(3,0),
- "g_lock.tdb", false, 0);
+ "g_lock.tdb", false);
if (!h->g_lock_db) {
DEBUG(DEBUG_ERR, (__location__ " unable to attach to g_lock.tdb\n"));
talloc_free(h);
diff --git a/ctdb/common/common.h b/ctdb/common/common.h
index 48e5767..0423c5e 100644
--- a/ctdb/common/common.h
+++ b/ctdb/common/common.h
@@ -39,6 +39,8 @@ struct ctdb_queue *ctdb_queue_setup(struct ctdb_context *ctdb,
/* From common/ctdb_ltdb.c */
+int ctdb_db_tdb_flags(uint8_t db_flags, bool with_valgrind, bool with_mutex);
+
struct ctdb_db_context *ctdb_db_handle(struct ctdb_context *ctdb,
const char *name);
diff --git a/ctdb/common/ctdb_ltdb.c b/ctdb/common/ctdb_ltdb.c
index fe8b41a..34ebe6a 100644
--- a/ctdb/common/ctdb_ltdb.c
+++ b/ctdb/common/ctdb_ltdb.c
@@ -33,6 +33,37 @@
#include "common/common.h"
#include "common/logging.h"
+
+/*
+ * Calculate tdb flags based on databse type
+ */
+int ctdb_db_tdb_flags(uint8_t db_flags, bool with_valgrind, bool with_mutex)
+{
+ int tdb_flags = 0;
+
+ if (db_flags & CTDB_DB_FLAGS_PERSISTENT) {
+ tdb_flags = TDB_DEFAULT;
+ } else {
+ tdb_flags = TDB_NOSYNC |
+ TDB_CLEAR_IF_FIRST |
+ TDB_INCOMPATIBLE_HASH;
+
+#ifdef TDB_MUTEX_LOCKING
+ if (with_mutex && tdb_runtime_check_for_robust_mutexes()) {
+ tdb_flags |= TDB_MUTEX_LOCKING;
+ }
+#endif
+
+ }
+
+ tdb_flags |= TDB_DISALLOW_NESTING;
+ if (with_valgrind) {
+ tdb_flags |= TDB_NOMMAP;
+ }
+
+ return tdb_flags;
+}
+
/*
find an attached ctdb_db handle given a name
*/
diff --git a/ctdb/include/ctdb_client.h b/ctdb/include/ctdb_client.h
index aa0d6b0..d4fd771 100644
--- a/ctdb/include/ctdb_client.h
+++ b/ctdb/include/ctdb_client.h
@@ -270,11 +270,13 @@ int ctdb_statistics_reset(struct ctdb_context *ctdb, uint32_t destnode);
/*
attach to a ctdb database
*/
+int ctdb_ctrl_db_open_flags(struct ctdb_context *ctdb, uint32_t db_id,
+ int *tdb_flags);
+
struct ctdb_db_context *ctdb_attach(struct ctdb_context *ctdb,
struct timeval timeout,
const char *name,
- bool persistent,
- uint32_t tdb_flags);
+ bool persistent);
int ctdb_detach(struct ctdb_context *ctdb, uint32_t db_id);
diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h
index dd54f35..8cdb4d8 100644
--- a/ctdb/include/ctdb_private.h
+++ b/ctdb/include/ctdb_private.h
@@ -724,7 +724,7 @@ int ctdb_set_db_readonly(struct ctdb_context *ctdb,
int ctdb_process_deferred_attach(struct ctdb_context *ctdb);
int32_t ctdb_control_db_attach(struct ctdb_context *ctdb, TDB_DATA indata,
- TDB_DATA *outdata, uint64_t tdb_flags,
+ TDB_DATA *outdata,
bool persistent, uint32_t client_id,
struct ctdb_req_control_old *c,
bool *async_reply);
diff --git a/ctdb/protocol/protocol.h b/ctdb/protocol/protocol.h
index 60e20b4..7e99738 100644
--- a/ctdb/protocol/protocol.h
+++ b/ctdb/protocol/protocol.h
@@ -367,6 +367,7 @@ enum ctdb_controls {CTDB_CONTROL_PROCESS_EXISTS = 0,
CTDB_CONTROL_DB_PULL = 146,
CTDB_CONTROL_DB_PUSH_START = 147,
CTDB_CONTROL_DB_PUSH_CONFIRM = 148,
+ CTDB_CONTROL_DB_OPEN_FLAGS = 149,
};
#define CTDB_MONITORING_ENABLED 0
--
Samba Shared Repository
More information about the samba-cvs
mailing list