From 10e6a3282098b3d4d94e72fa27f47825ef4e7f15 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 21 Sep 2011 12:56:59 +0930 Subject: tdb_compat: handle TDB_VOLATILE flag. This is only meaningful when using the TDB_VERSION1 flag: we set the attribute to control the maximum number of dead records (to 5, which is what TDB_VOLATILE did for tdb1). Signed-off-by: Rusty Russell --- lib/tdb_compat/tdb_compat.c | 12 +++++++++++- lib/tdb_compat/tdb_compat.h | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'lib/tdb_compat') diff --git a/lib/tdb_compat/tdb_compat.c b/lib/tdb_compat/tdb_compat.c index 9ed6604c4d..f311b4bfba 100644 --- a/lib/tdb_compat/tdb_compat.c +++ b/lib/tdb_compat/tdb_compat.c @@ -94,7 +94,7 @@ tdb_open_compat_(const char *name, int hash_size_unused, void *data), void *log_data) { - union tdb_attribute cif, log, hash, *attr = NULL; + union tdb_attribute cif, log, hash, max_dead, *attr = NULL; if (log_fn) { log.log.base.attr = TDB_ATTRIBUTE_LOG; @@ -122,6 +122,16 @@ tdb_open_compat_(const char *name, int hash_size_unused, tdb_flags &= ~TDB_INCOMPATIBLE_HASH; } + if (tdb_flags & TDB_VOLATILE) { + if (tdb_flags & TDB_VERSION1) { + max_dead.base.attr = TDB_ATTRIBUTE_TDB1_MAX_DEAD; + max_dead.base.next = attr; + max_dead.tdb1_max_dead.max_dead = 5; + attr = &max_dead; + } + tdb_flags &= ~TDB_VOLATILE; + } + /* Testsuite uses this to speed things up. */ if (getenv("TDB_NO_FSYNC")) { tdb_flags |= TDB_NOSYNC; diff --git a/lib/tdb_compat/tdb_compat.h b/lib/tdb_compat/tdb_compat.h index 4a01c15fdb..cc120bbcb6 100644 --- a/lib/tdb_compat/tdb_compat.h +++ b/lib/tdb_compat/tdb_compat.h @@ -83,7 +83,7 @@ int tdb_reopen_all(int parent_longlived); /* These no longer exist in tdb2. */ #define TDB_CLEAR_IF_FIRST 1048576 #define TDB_INCOMPATIBLE_HASH 2097152 -#define TDB_VOLATILE 0 +#define TDB_VOLATILE 4194304 /* tdb2 does nonblocking functions via attibutes. */ enum TDB_ERROR tdb_transaction_start_nonblock(struct tdb_context *tdb); -- cgit