X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Ftdb2%2Fprivate.h;h=c0377363c6ac14a705868f5c74beca86f213ff84;hp=a241210bebc0a559a087881f11d1d413c364656d;hb=a2d8a4bf0c36bf312b30fdce3ae89d5f3ae21186;hpb=6804501c350181dea8f531142b28c620b70edbd9 diff --git a/ccan/tdb2/private.h b/ccan/tdb2/private.h index a241210b..c0377363 100644 --- a/ccan/tdb2/private.h +++ b/ccan/tdb2/private.h @@ -113,6 +113,10 @@ typedef uint64_t tdb_off_t; #define TDB_OFF_MASK \ (((1ULL << (64 - TDB_OFF_UPPER_STEAL)) - 1) - TDB_OFF_HASH_GROUP_MASK) +/* We have to be able to fit a free record here. */ +#define TDB_MIN_DATA_LEN \ + (sizeof(struct tdb_free_record) - sizeof(struct tdb_used_record)) + /* We ensure buckets up to size 1 << (zone_bits - TDB_COMFORT_FACTOR_BITS). */ /* FIXME: test this matches size_to_bucket! */ #define BUCKETS_FOR_ZONE(zone_bits) ((zone_bits) + 2 - TDB_COMFORT_FACTOR_BITS) @@ -242,7 +246,6 @@ struct hash_info { struct traverse_info { struct traverse_level { tdb_off_t hashtable; - const tdb_off_t *entries; /* We ignore groups here, and treat it as a big array. */ unsigned entry; unsigned int total_buckets; @@ -283,9 +286,12 @@ struct tdb_context { /* How much space has been mapped (<= current file size) */ tdb_len_t map_size; - /* Opened read-only? */ + /* Operating read-only? (Opened O_RDONLY, or in traverse_read) */ bool read_only; + /* mmap read only? */ + int mmap_flags; + /* Error code for last tdb error. */ enum TDB_ERROR ecode; @@ -347,7 +353,8 @@ tdb_off_t find_and_lock(struct tdb_context *tdb, struct tdb_data key, int ltype, struct hash_info *h, - struct tdb_used_record *rec); + struct tdb_used_record *rec, + struct traverse_info *tinfo); int replace_in_hash(struct tdb_context *tdb, struct hash_info *h, @@ -418,9 +425,11 @@ int tdb_write_off(struct tdb_context *tdb, tdb_off_t off, tdb_off_t val); /* Clear an ondisk area. */ int zero_out(struct tdb_context *tdb, tdb_off_t off, tdb_len_t len); -/* Return a non-zero offset in this array, or num. */ -tdb_off_t tdb_find_nonzero_off(struct tdb_context *tdb, tdb_off_t off, - uint64_t num); +/* Return a non-zero offset between >= start < end in this array (or end). */ +tdb_off_t tdb_find_nonzero_off(struct tdb_context *tdb, + tdb_off_t base, + uint64_t start, + uint64_t end); /* Return a zero offset in this array, or num. */ tdb_off_t tdb_find_zero_off(struct tdb_context *tdb, tdb_off_t off,