X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Ftdb2%2Fprivate.h;h=e29bda96cb60d3709619d12364ac196f5cc7a4d3;hp=b77d70c3ce6b0afa47eec11e2838a4cbbf4284ca;hb=2523e67f154c3f8614a2ddca2cd0170d321a27d4;hpb=539f1af037858b905c50c560f2a608555d8457ff diff --git a/ccan/tdb2/private.h b/ccan/tdb2/private.h index b77d70c3..e29bda96 100644 --- a/ccan/tdb2/private.h +++ b/ccan/tdb2/private.h @@ -91,6 +91,8 @@ typedef uint64_t tdb_off_t; #define TDB_SUBLEVEL_HASH_BITS 6 /* And 8 entries in each group, ie 8 groups per sublevel. */ #define TDB_HASH_GROUP_BITS 3 +/* This is currently 10: beyond this we chain. */ +#define TDB_MAX_LEVELS (1+(64-TDB_TOPLEVEL_HASH_BITS) / TDB_SUBLEVEL_HASH_BITS) /* Extend file by least 100 times larger than needed. */ #define TDB_EXTENSION_FACTOR 100 @@ -212,6 +214,12 @@ struct tdb_recovery_record { uint64_t eof; }; +/* If we bottom out of the subhashes, we chain. */ +struct tdb_chain { + tdb_off_t rec[1 << TDB_HASH_GROUP_BITS]; + tdb_off_t next; +}; + /* this is stored at the front of every database */ struct tdb_header { char magic_food[64]; /* for /etc/magic */ @@ -259,7 +267,7 @@ struct traverse_info { /* We ignore groups here, and treat it as a big array. */ unsigned entry; unsigned int total_buckets; - } levels[64 / TDB_SUBLEVEL_HASH_BITS]; + } levels[TDB_MAX_LEVELS + 1]; unsigned int num_levels; unsigned int toplevel_group; /* This makes delete-everything-inside-traverse work as expected. */