summaryrefslogtreecommitdiff
path: root/source4/cluster/ctdb
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2007-01-20 00:48:31 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:43:52 -0500
commitefc68d8bf6d5acc009285e8f34b30a3a5b252884 (patch)
treed84cca0cf2946c054f3f19ee8b50b77713952af4 /source4/cluster/ctdb
parentd1b61b09aa542d64bf43abb3ad04611f46b57376 (diff)
downloadsamba-efc68d8bf6d5acc009285e8f34b30a3a5b252884.tar.gz
samba-efc68d8bf6d5acc009285e8f34b30a3a5b252884.tar.bz2
samba-efc68d8bf6d5acc009285e8f34b30a3a5b252884.zip
r20919: add a function cluster_tdb_tmp_open() which can be used in a cluster
environment for subsystems that have not yet been converted to use ctdb to get a shared temporary tdb (This used to be commit 0ed91384497aed6817b2220c31344bfcd45fd033)
Diffstat (limited to 'source4/cluster/ctdb')
-rw-r--r--source4/cluster/ctdb/brlock_ctdb.c3
-rw-r--r--source4/cluster/ctdb/ctdb_cluster.c31
2 files changed, 32 insertions, 2 deletions
diff --git a/source4/cluster/ctdb/brlock_ctdb.c b/source4/cluster/ctdb/brlock_ctdb.c
index 00fcb0335a..0ae5c36094 100644
--- a/source4/cluster/ctdb/brlock_ctdb.c
+++ b/source4/cluster/ctdb/brlock_ctdb.c
@@ -116,6 +116,9 @@ static struct brl_handle *brl_ctdb_create_handle(TALLOC_CTX *mem_ctx, struct ntv
return NULL;
}
+ DEBUG(0,("file_key\n"));
+ dump_data(0,file_key->data, file_key->length);
+
brlh->key = *file_key;
brlh->ntvfs = ntvfs;
ZERO_STRUCT(brlh->last_lock);
diff --git a/source4/cluster/ctdb/ctdb_cluster.c b/source4/cluster/ctdb/ctdb_cluster.c
index 183d5c1831..0e7255f060 100644
--- a/source4/cluster/ctdb/ctdb_cluster.c
+++ b/source4/cluster/ctdb/ctdb_cluster.c
@@ -27,6 +27,7 @@
#include "cluster/cluster_private.h"
#include "lib/tdb/include/tdb.h"
#include "cluster/ctdb/include/ctdb.h"
+#include "db_wrap.h"
struct cluster_state {
struct ctdb_context *ctdb;
@@ -55,9 +56,35 @@ static const char *ctdb_id_string(struct cluster_ops *ops,
return talloc_asprintf(mem_ctx, "%u.%u", id.node, id.id);
}
+/*
+ this is an interim method for subsystems that have not yet been
+ converted to use the ctdb api. It opens a shared database in the
+ cluster temporary area, using TDB_CLEAR_IF_FIRST which relies on
+ correct operation of fcntl locks on the shared fileystem.
+*/
+static struct tdb_wrap *ctdb_tdb_tmp_open(struct cluster_ops *ops,
+ TALLOC_CTX *mem_ctx, const char *dbname,
+ int flags)
+{
+ const char *dir = lp_parm_string(-1, "ctdb", "shared data");
+ char *path;
+ struct tdb_wrap *w;
+ if (dir == NULL) {
+ DEBUG(0,("ERROR: You must set 'ctdb:shared data' to a cluster shared path\n"));
+ return NULL;
+ }
+ path = talloc_asprintf(mem_ctx, "%s/%s", dir, dbname);
+ w = tdb_wrap_open(mem_ctx, path, 0,
+ flags | TDB_CLEAR_IF_FIRST,
+ O_RDWR|O_CREAT, 0600);
+ talloc_free(path);
+ return w;
+}
+
static struct cluster_ops cluster_ctdb_ops = {
- .cluster_id = ctdb_id,
- .cluster_id_string = ctdb_id_string,
+ .cluster_id = ctdb_id,
+ .cluster_id_string = ctdb_id_string,
+ .cluster_tdb_tmp_open = ctdb_tdb_tmp_open,
.private = NULL
};