From 6e16e29d532d7542c210fd725bf61df1e7a97795 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 14 Sep 2011 07:47:13 +0930 Subject: tdb2: add TDB_ATTRIBUTE_TDB1_HASHSIZE This replaces the tdb1_open "hash_size" argument. It will only be valid when you call tdb_open() with O_CREAT in open_flags, and TDB_VERSION1 in tdb_flags. Signed-off-by: Rusty Russell (Imported from CCAN commit 49475d68deecd0b31597ed6094229171d2699b11) --- lib/tdb2/tdb2.h | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'lib/tdb2/tdb2.h') diff --git a/lib/tdb2/tdb2.h b/lib/tdb2/tdb2.h index 3939c4abe9..7967b60f7b 100644 --- a/lib/tdb2/tdb2.h +++ b/lib/tdb2/tdb2.h @@ -609,7 +609,8 @@ enum tdb_attribute_type { TDB_ATTRIBUTE_SEED = 2, TDB_ATTRIBUTE_STATS = 3, TDB_ATTRIBUTE_OPENHOOK = 4, - TDB_ATTRIBUTE_FLOCK = 5 + TDB_ATTRIBUTE_FLOCK = 5, + TDB_ATTRIBUTE_TDB1_HASHSIZE = 128, }; /** @@ -633,8 +634,9 @@ enum TDB_ERROR tdb_get_attribute(struct tdb_context *tdb, * of the same type. It returns TDB_ERR_EINVAL if the attribute is * unknown or invalid. * - * Note that TDB_ATTRIBUTE_HASH, TDB_ATTRIBUTE_SEED and - * TDB_ATTRIBUTE_OPENHOOK cannot currently be set after tdb_open. + * Note that TDB_ATTRIBUTE_HASH, TDB_ATTRIBUTE_SEED, + * TDB_ATTRIBUTE_OPENHOOK and TDB_ATTRIBUTE_TDB1_HASHSIZE cannot + * currently be set after tdb_open. */ enum TDB_ERROR tdb_set_attribute(struct tdb_context *tdb, const union tdb_attribute *attr); @@ -840,6 +842,19 @@ struct tdb_attribute_flock { void *data; }; +/** + * struct tdb_attribute_tdb1_hashsize - tdb1 hashsize + * + * This attribute allows setting the TDB1 hashsize; it only makes sense with + * O_CREAT and TDB_VERSION1. + * + * Hashsize should generally be a prime, such as 10007. + */ +struct tdb_attribute_tdb1_hashsize { + struct tdb_attribute_base base; /* .attr = TDB_ATTRIBUTE_TDB1_HASHSIZE */ + unsigned int hsize; +}; + /** * union tdb_attribute - tdb attributes. * @@ -858,6 +873,7 @@ union tdb_attribute { struct tdb_attribute_stats stats; struct tdb_attribute_openhook openhook; struct tdb_attribute_flock flock; + struct tdb_attribute_tdb1_hashsize tdb1_hashsize; }; #ifdef __cplusplus -- cgit