summaryrefslogtreecommitdiffstats
path: root/source3/lib/dbwrap
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2014-01-28 21:24:22 +0100
committerStefan Metzmacher <metze@samba.org>2014-02-07 16:06:06 +0100
commita97b588b63f437d25c4344c76014326dbf0cbdb0 (patch)
treee7ea0728caac265e15a8c0401d9feaca96093654 /source3/lib/dbwrap
parent56bd4040889dfe492ff820497b7a6d76624a6048 (diff)
downloadsamba-a97b588b63f437d25c4344c76014326dbf0cbdb0.tar.gz
samba-a97b588b63f437d25c4344c76014326dbf0cbdb0.tar.xz
samba-a97b588b63f437d25c4344c76014326dbf0cbdb0.zip
dbwrap_ctdb: implement DBWRAP_FLAG_OPTIMIZE_READONLY_ACCESS
For non-persistent databases we try to use CTDB_CONTROL_SET_DB_READONLY in order to make use of readonly records. Pair-Programmed-With: Michael Adam <obnox@samba.org> Signed-off-by: Stefan Metzmacher <metze@samba.org> Signed-off-by: Michael Adam <obnox@samba.org>
Diffstat (limited to 'source3/lib/dbwrap')
-rw-r--r--source3/lib/dbwrap/dbwrap_ctdb.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/source3/lib/dbwrap/dbwrap_ctdb.c b/source3/lib/dbwrap/dbwrap_ctdb.c
index 2770129a17..87e644dbe5 100644
--- a/source3/lib/dbwrap/dbwrap_ctdb.c
+++ b/source3/lib/dbwrap/dbwrap_ctdb.c
@@ -1649,6 +1649,27 @@ struct db_context *db_open_ctdb(TALLOC_CTX *mem_ctx,
return NULL;
}
+#ifdef HAVE_CTDB_WANT_READONLY_DECL
+ if (!result->persistent &&
+ (dbwrap_flags & DBWRAP_FLAG_OPTIMIZE_READONLY_ACCESS))
+ {
+ TDB_DATA indata;
+
+ indata = make_tdb_data((uint8_t *)&db_ctdb->db_id,
+ sizeof(db_ctdb->db_id));
+
+ status = ctdbd_control_local(
+ conn, CTDB_CONTROL_SET_DB_READONLY, 0, 0, indata,
+ NULL, NULL, &cstatus);
+ if (!NT_STATUS_IS_OK(status) || (cstatus != 0)) {
+ DEBUG(1, ("CTDB_CONTROL_SET_DB_READONLY failed: "
+ "%s, %d\n", nt_errstr(status), cstatus));
+ TALLOC_FREE(result);
+ return NULL;
+ }
+ }
+#endif
+
lp_ctx = loadparm_init_s3(db_path, loadparm_s3_helpers());
db_ctdb->wtdb = tdb_wrap_open(db_ctdb, db_path, hash_size, tdb_flags,