tdb_compat: handle TDB_VOLATILE flag.
authorRusty Russell <rusty@rustcorp.com.au>
Wed, 21 Sep 2011 03:26:59 +0000 (12:56 +0930)
committerRusty Russell <rusty@rustcorp.com.au>
Wed, 21 Sep 2011 03:26:59 +0000 (12:56 +0930)
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 <rusty@rustcorp.com.au>
lib/tdb_compat/tdb_compat.c
lib/tdb_compat/tdb_compat.h

index 9ed6604c4dcb30149f49384db1da007ead1fcc24..f311b4bfbaff18b8aeff6c8bb1a3fca147929047 100644 (file)
@@ -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;
index 4a01c15fdbd3c7213cfa7b6c9d4b9d48db38da41..cc120bbcb652706f9cd5ca6e633b8935e9c4eed3 100644 (file)
@@ -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);