X-Git-Url: https://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Ftdb2%2Fprivate.h;h=9ae5bed2e6bc6cb8c397d32d1f7f6f6ef8574930;hp=236aa3696d6b4c30efe7e974b53500b51c2f7832;hb=1ad66fedf81fdaf0f07a2b00d6787614c58a23ef;hpb=3835bb95d716cb6448913792b0d8d539877d93e9 diff --git a/ccan/tdb2/private.h b/ccan/tdb2/private.h index 236aa369..9ae5bed2 100644 --- a/ccan/tdb2/private.h +++ b/ccan/tdb2/private.h @@ -18,8 +18,7 @@ License along with this library; if not, see . */ -#define _XOPEN_SOURCE 500 -#define _FILE_OFFSET_BITS 64 +#include "config.h" #include #include #include @@ -33,7 +32,6 @@ #include #include #include -#include "config.h" #include #include #include @@ -118,6 +116,9 @@ typedef int tdb_bool_err; #define TDB_OFF_HASH_EXTRA_BIT 57 #define TDB_OFF_UPPER_STEAL_SUBHASH_BIT 56 +/* Additional features we understand. Currently: none. */ +#define TDB_FEATURE_MASK ((uint64_t)0) + /* The bit number where we store the extra hash bits. */ /* Convenience mask to get actual offset. */ #define TDB_OFF_MASK \ @@ -242,7 +243,10 @@ struct tdb_header { tdb_off_t free_table; /* (First) free table. */ tdb_off_t recovery; /* Transaction recovery area. */ - tdb_off_t reserved[26]; + uint64_t features_used; /* Features all writers understand */ + uint64_t features_offered; /* Features offered */ + + tdb_off_t reserved[24]; /* Top level hash table. */ tdb_off_t hashtable[1ULL << TDB_TOPLEVEL_HASH_BITS]; @@ -311,6 +315,23 @@ struct tdb_access_hdr { bool convert; }; +struct tdb_file { + /* Single list of all TDBs, to detect multiple opens. */ + struct tdb_file *next; + + /* The file descriptor. */ + int fd; + + /* Lock information */ + struct tdb_lock_type allrecord_lock; + size_t num_lockrecs; + struct tdb_lock_type *lockrecs; + + /* Identity of this file. */ + dev_t device; + ino_t inode; +}; + struct tdb_context { /* Filename of the database. */ const char *name; @@ -321,9 +342,6 @@ struct tdb_context { /* Are we accessing directly? (debugging check). */ int direct_access; - /* Open file descriptor (undefined for TDB_INTERNAL). */ - int fd; - /* How much space has been mapped (<= current file size) */ tdb_len_t map_size; @@ -361,20 +379,13 @@ struct tdb_context { /* IO methods: changes for transactions. */ const struct tdb_methods *methods; - /* Lock information */ - struct tdb_lock_type allrecord_lock; - size_t num_lockrecs; - struct tdb_lock_type *lockrecs; - struct tdb_attribute_stats *stats; /* Direct access information */ struct tdb_access_hdr *access; - /* Single list of all TDBs, to avoid multiple opens. */ - struct tdb_context *next; - dev_t device; - ino_t inode; + /* The actual file information */ + struct tdb_file *file; }; struct tdb_methods { @@ -453,7 +464,7 @@ unsigned int size_to_bucket(tdb_len_t data_len); tdb_off_t bucket_off(tdb_off_t ftable_off, unsigned bucket); /* Used by tdb_summary */ -size_t dead_space(struct tdb_context *tdb, tdb_off_t off); +tdb_off_t dead_space(struct tdb_context *tdb, tdb_off_t off); /* io.c: */ /* Initialize tdb->methods. */ @@ -517,8 +528,6 @@ void add_stat_(struct tdb_context *tdb, uint64_t *stat, size_t val); } while (0) /* lock.c: */ -void tdb_lock_init(struct tdb_context *tdb); - /* Lock/unlock a range of hashes. */ enum TDB_ERROR tdb_lock_hashes(struct tdb_context *tdb, tdb_off_t hash_lock, tdb_len_t hash_range, @@ -560,8 +569,8 @@ bool tdb_has_expansion_lock(struct tdb_context *tdb); enum TDB_ERROR tdb_lock_and_recover(struct tdb_context *tdb); /* transaction.c: */ -int tdb_transaction_recover(struct tdb_context *tdb); -bool tdb_needs_recovery(struct tdb_context *tdb); +enum TDB_ERROR tdb_transaction_recover(struct tdb_context *tdb); +tdb_bool_err tdb_needs_recovery(struct tdb_context *tdb); /* tdb.c: */ enum TDB_ERROR COLD tdb_logerr(struct tdb_context *tdb,