X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Ftdb2%2Ftdb1_private.h;h=bff967b25b883ea38fe5992489f8dffd9294ae59;hb=4dc29a338fadeac805b369b4b0851c02f1b152c7;hp=20838bfe7b1f32b20cf0bcf5222aa2db798f67fc;hpb=8a47d50d72ea62e378dc92b150c92c1317c73fa3;p=ccan diff --git a/ccan/tdb2/tdb1_private.h b/ccan/tdb2/tdb1_private.h index 20838bfe..bff967b2 100644 --- a/ccan/tdb2/tdb1_private.h +++ b/ccan/tdb2/tdb1_private.h @@ -35,6 +35,35 @@ #define tdb_error(tdb) \ tdb_error((struct tdb_context *)(tdb)) +#define tdb_brlock(tdb1, rw_type, offset, len, flags) \ + tdb_brlock((struct tdb_context *)(tdb1), \ + (rw_type), (offset), (len), (flags)) + +#define tdb_brunlock(tdb1, rw_type, offset, len) \ + tdb_brunlock((struct tdb_context *)(tdb1), (rw_type), (offset), (len)) + +#define tdb_nest_lock(tdb1, offset, ltype, flags) \ + tdb_nest_lock((struct tdb_context *)(tdb1), (offset), (ltype), (flags)) + +#define tdb_nest_unlock(tdb1, offset, ltype) \ + tdb_nest_unlock((struct tdb_context *)(tdb1), (offset), (ltype)) + +#define tdb_allrecord_lock(tdb1, offset, flags, upgradable) \ + tdb_allrecord_lock((struct tdb_context *)(tdb1), \ + (offset), (flags), (upgradable)) + +#define tdb_allrecord_unlock(tdb1, ltype) \ + tdb_allrecord_unlock((struct tdb_context *)(tdb1), (ltype)) + +#define tdb_allrecord_upgrade(tdb1, start) \ + tdb_allrecord_upgrade((struct tdb_context *)(tdb1), (start)) + +#define tdb_hash(tdb1, ptr, len) \ + tdb_hash((struct tdb_context *)(tdb1), (ptr), (len)) + +#define tdb_lock_gradual(tdb1, ltype, flags, off, len) \ + tdb_lock_gradual((struct tdb_context *)(tdb1), \ + (ltype), (flags), (off), (len)) /***** END FIXME ***/ #include @@ -97,7 +126,7 @@ typedef uint32_t tdb1_off_t; #define TDB1_BUCKET(hash) ((hash) % tdb->header.hash_size) -#define TDB1_DOCONV() (tdb->flags & TDB1_CONVERT) +#define TDB1_DOCONV() (tdb->flags & TDB_CONVERT) #define TDB1_CONV(x) (TDB1_DOCONV() ? tdb1_convert(&x, sizeof(x)) : &x) /* the body of the database is made of one tdb1_record for the free space @@ -135,12 +164,6 @@ struct tdb1_header { tdb1_off_t reserved[27]; }; -struct tdb1_lock_type { - uint32_t off; - uint32_t count; - uint32_t ltype; -}; - struct tdb1_traverse_lock { struct tdb1_traverse_lock *next; uint32_t off; @@ -174,22 +197,30 @@ struct tdb1_context { /* Last error we returned. */ enum TDB_ERROR last_error; /* error code for last tdb error */ - void *map_ptr; /* where it is currently mapped */ - int fd; /* open file descriptor for the database */ - tdb1_len_t map_size; /* how much space has been mapped */ - int read_only; /* opened read-only */ + /* The actual file information */ + struct tdb_file *file; + + int open_flags; /* flags used in the open - needed by reopen */ + + /* low level (fnctl) lock functions. */ + int (*lock_fn)(int fd, int rw, off_t off, off_t len, bool w, void *); + int (*unlock_fn)(int fd, int rw, off_t off, off_t len, void *); + void *lock_data; + + uint32_t flags; /* the flags passed to tdb1_open */ + + /* Our statistics. */ + struct tdb_attribute_stats stats; + + /* Hash function. */ + uint64_t (*hash_fn)(const void *key, size_t len, uint64_t seed, void *); + void *hash_data; + uint64_t hash_seed; + int traverse_read; /* read-only traversal */ int traverse_write; /* read-write traversal */ - struct tdb1_lock_type allrecord_lock; /* .offset == upgradable */ - int num_lockrecs; - struct tdb1_lock_type *lockrecs; /* only real locks, all with count>0 */ struct tdb1_header header; /* a cached copy of the header */ - uint32_t flags; /* the flags passed to tdb1_open */ struct tdb1_traverse_lock travlocks; /* current traversal locks */ - dev_t device; /* uniquely identifies this tdb */ - ino_t inode; /* uniquely identifies this tdb */ - unsigned int (*hash_fn)(TDB_DATA *key); - int open_flags; /* flags used in the open - needed by reopen */ const struct tdb1_methods *methods; struct tdb1_transaction *transaction; int page_size; @@ -255,6 +286,6 @@ bool tdb1_write_all(int fd, const void *buf, size_t count); int tdb1_transaction_recover(struct tdb1_context *tdb); void tdb1_header_hash(struct tdb1_context *tdb, uint32_t *magic1_hash, uint32_t *magic2_hash); -unsigned int tdb1_old_hash(TDB_DATA *key); +uint64_t tdb1_old_hash(const void *key, size_t len, uint64_t seed, void *); size_t tdb1_dead_space(struct tdb1_context *tdb, tdb1_off_t off); #endif /* CCAN_TDB2_TDB1_PRIVATE_H */