summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2008-03-26 10:08:10 +0100
committerStefan Metzmacher <metze@samba.org>2008-04-12 09:14:09 +0200
commit138b58bcec67e4a45cfa28213fc667504755a894 (patch)
tree64144779344b1388b9775aeb9eb7e1bfa84fec33
parentdfb181ab732e0a43accb3b1b328617701fc3e566 (diff)
downloadsamba-138b58bcec67e4a45cfa28213fc667504755a894.tar.gz
samba-138b58bcec67e4a45cfa28213fc667504755a894.tar.bz2
samba-138b58bcec67e4a45cfa28213fc667504755a894.zip
dbwrap: use db_open_tdb2() in for db_open_trans() if "dbwrap:use_tdb2=yes"
For clustered setups you need to disable the ctdb backend for each tdb which should use the tdb2 backend (e.g. ctdb:registry.tdb=no). To disable tdb2 per tdb use something like "tdb2:passdb.tdb=no" metze (This used to be commit 5cea2bf3673c982bafeef4a8bbd3bd2ab73cc0c5)
-rw-r--r--source3/lib/dbwrap.c59
1 files changed, 57 insertions, 2 deletions
diff --git a/source3/lib/dbwrap.c b/source3/lib/dbwrap.c
index fd924639a9..d688b83d73 100644
--- a/source3/lib/dbwrap.c
+++ b/source3/lib/dbwrap.c
@@ -104,8 +104,63 @@ struct db_context *db_open_trans(TALLOC_CTX *mem_ctx,
int hash_size, int tdb_flags,
int open_flags, mode_t mode)
{
- /* TODO: implement this differently */
- return db_open(mem_ctx, name, hash_size, tdb_flags, open_flags, mode);
+ bool use_tdb2 = lp_parm_bool(-1, "dbwrap", "use_tdb2", false);
+#ifdef CLUSTER_SUPPORT
+ const char *sockname = lp_ctdbd_socket();
+#endif
+
+ if (tdb_flags & TDB_CLEAR_IF_FIRST) {
+ DEBUG(0,("db_open_trans: called with TDB_CLEAR_IF_FIRST: %s\n",
+ name));
+ smb_panic("db_open_trans: called with TDB_CLEAR_IF_FIRST");
+ }
+
+#ifdef CLUSTER_SUPPORT
+ if(!sockname || !*sockname) {
+ sockname = CTDB_PATH;
+ }
+
+ if (lp_clustering() && socket_exist(sockname)) {
+ const char *partname;
+ /* ctdb only wants the file part of the name */
+ partname = strrchr(name, '/');
+ if (partname) {
+ partname++;
+ } else {
+ partname = name;
+ }
+ /* allow ctdb for individual databases to be disabled */
+ if (lp_parm_bool(-1, "ctdb", partname, true)) {
+ result = db_open_ctdb(mem_ctx, partname, hash_size,
+ tdb_flags, open_flags, mode);
+ if (result == NULL) {
+ DEBUG(0,("failed to attach to ctdb %s\n",
+ partname));
+ smb_panic("failed to attach to a ctdb "
+ "database");
+ }
+ }
+ }
+#endif
+
+ if (use_tdb2) {
+ const char *partname;
+ /* tdb2 only wants the file part of the name */
+ partname = strrchr(name, '/');
+ if (partname) {
+ partname++;
+ } else {
+ partname = name;
+ }
+ /* allow ctdb for individual databases to be disabled */
+ if (lp_parm_bool(-1, "tdb2", partname, true)) {
+ return db_open_tdb2(mem_ctx, partname, hash_size,
+ tdb_flags, open_flags, mode);
+ }
+ }
+
+ return db_open_tdb(mem_ctx, name, hash_size,
+ tdb_flags, open_flags, mode);
}
NTSTATUS dbwrap_delete_bystring(struct db_context *db, const char *key)