X-Git-Url: https://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Ftdb2%2Fprivate.h;h=306cb3ff467f70397fbcd91709a285c34e9e9de8;hp=90fe7376b3558665cac13a30d4a864697d3388e6;hb=703cea0c78a896c658272af06306218fc0bb23cc;hpb=f367a1dc8573db0a1f6f49fcda474eb51c192241 diff --git a/ccan/tdb2/private.h b/ccan/tdb2/private.h index 90fe7376..306cb3ff 100644 --- a/ccan/tdb2/private.h +++ b/ccan/tdb2/private.h @@ -89,7 +89,7 @@ typedef int tdb_bool_err; /* Expanding file. */ #define TDB_EXPANSION_LOCK 2 /* Hash chain locks. */ -#define TDB_HASH_LOCK_START 3 +#define TDB_HASH_LOCK_START 64 /* Range for hash locks. */ #define TDB_HASH_LOCK_RANGE_BITS 30 @@ -335,6 +335,7 @@ struct tdb_file { int fd; /* Lock information */ + pid_t locker; struct tdb_lock allrecord_lock; size_t num_lockrecs; struct tdb_lock *lockrecs; @@ -364,17 +365,22 @@ struct tdb_context { uint32_t flags; /* Logging function */ - void (*logfn)(struct tdb_context *tdb, - enum tdb_log_level level, - void *log_private, - const char *message); - void *log_private; + void (*log_fn)(struct tdb_context *tdb, + enum tdb_log_level level, + const char *message, + void *data); + void *log_data; /* Hash function. */ - uint64_t (*khash)(const void *key, size_t len, uint64_t seed, void *); - void *hash_priv; + uint64_t (*hash_fn)(const void *key, size_t len, uint64_t seed, void *); + void *hash_data; uint64_t hash_seed; + /* 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; + /* Set if we are in a transaction. */ struct tdb_transaction *transaction; @@ -411,8 +417,6 @@ struct tdb_methods { internal prototypes */ /* hash.c: */ -void tdb_hash_init(struct tdb_context *tdb); - tdb_bool_err first_in_hash(struct tdb_context *tdb, struct traverse_info *tinfo, TDB_DATA *kbuf, size_t *dlen); @@ -549,7 +553,7 @@ enum TDB_ERROR tdb_unlock_hashes(struct tdb_context *tdb, tdb_len_t hash_range, int ltype); /* For closing the file. */ -void tdb_unlock_all(struct tdb_context *tdb); +void tdb_lock_cleanup(struct tdb_context *tdb); /* Lock/unlock a particular free bucket. */ enum TDB_ERROR tdb_lock_free_bucket(struct tdb_context *tdb, tdb_off_t b_off, @@ -583,6 +587,10 @@ bool tdb_has_expansion_lock(struct tdb_context *tdb); /* If it needs recovery, grab all the locks and do it. */ enum TDB_ERROR tdb_lock_and_recover(struct tdb_context *tdb); +/* Default lock and unlock functions. */ +int tdb_fcntl_lock(int fd, int rw, off_t off, off_t len, bool waitflag, void *); +int tdb_fcntl_unlock(int fd, int rw, off_t off, off_t len, void *); + /* transaction.c: */ enum TDB_ERROR tdb_transaction_recover(struct tdb_context *tdb); tdb_bool_err tdb_needs_recovery(struct tdb_context *tdb);