tdb_compat: honour hashsize arg when using tdb2 with TDB_VERSION1 flag.
authorRusty Russell <rusty@rustcorp.com.au>
Wed, 21 Sep 2011 03:27:59 +0000 (12:57 +0930)
committerRusty Russell <rusty@rustcorp.com.au>
Wed, 21 Sep 2011 03:27:59 +0000 (12:57 +0930)
We use the TDB_ATTRIBUTE_TDB1_HASHSIZE to set the hash size.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
lib/tdb_compat/tdb_compat.c
lib/tdb_compat/tdb_compat.h

index f311b4bfbaff18b8aeff6c8bb1a3fca147929047..d5d8f09c64a7e09cb538c86cefd573016aeb227b 100644 (file)
@@ -85,7 +85,7 @@ static enum TDB_ERROR clear_if_first(int fd, void *unused)
 }
 
 struct tdb_context *
-tdb_open_compat_(const char *name, int hash_size_unused,
+tdb_open_compat_(const char *name, int hash_size,
                 int tdb_flags, int open_flags, mode_t mode,
                 void (*log_fn)(struct tdb_context *,
                                enum tdb_log_level,
@@ -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, max_dead, *attr = NULL;
+       union tdb_attribute cif, log, hash, max_dead, hsize, *attr = NULL;
 
        if (log_fn) {
                log.log.base.attr = TDB_ATTRIBUTE_LOG;
@@ -132,6 +132,13 @@ tdb_open_compat_(const char *name, int hash_size_unused,
                tdb_flags &= ~TDB_VOLATILE;
        }
 
+       if (hash_size && (tdb_flags & TDB_VERSION1)) {
+               hsize.base.attr = TDB_ATTRIBUTE_TDB1_HASHSIZE;
+               hsize.base.next = attr;
+               hsize.tdb1_hashsize.hsize = hash_size;
+               attr = &hsize;
+       }
+
        /* Testsuite uses this to speed things up. */
        if (getenv("TDB_NO_FSYNC")) {
                tdb_flags |= TDB_NOSYNC;
index cc120bbcb652706f9cd5ca6e633b8935e9c4eed3..0d58075c80f5a34d75f47bcb9fbc9207cbb1bdb5 100644 (file)
@@ -100,7 +100,7 @@ enum TDB_ERROR tdb_transaction_start_nonblock(struct tdb_context *tdb);
                         (log_data))
 
 struct tdb_context *
-tdb_open_compat_(const char *name, int hash_size_unused,
+tdb_open_compat_(const char *name, int hash_size,
                 int tdb_flags, int open_flags, mode_t mode,
                 void (*log_fn)(struct tdb_context *,
                                enum tdb_log_level,