4 Trivial Database 2: private types and prototypes
5 Copyright (C) Rusty Russell 2010
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 3 of the License, or (at your option) any later version.
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, see <http://www.gnu.org/licenses/>.
21 #include <ccan/tdb2/tdb2.h>
32 #include <ccan/likely/likely.h>
33 #include <ccan/endian/endian.h>
39 /* #define TDB_TRACE 1 */
42 #define __STRING(x) #x
45 #ifndef __STRINGSTRING
46 #define __STRINGSTRING(x) __STRING(x)
50 #define __location__ __FILE__ ":" __STRINGSTRING(__LINE__)
53 typedef uint64_t tdb_len_t;
54 typedef uint64_t tdb_off_t;
56 #define TDB_MAGIC_FOOD "TDB file\n"
57 #define TDB_VERSION ((uint64_t)(0x26011967 + 7))
58 #define TDB1_VERSION (0x26011967 + 6)
59 #define TDB_USED_MAGIC ((uint64_t)0x1999)
60 #define TDB_HTABLE_MAGIC ((uint64_t)0x1888)
61 #define TDB_CHAIN_MAGIC ((uint64_t)0x1777)
62 #define TDB_FTABLE_MAGIC ((uint64_t)0x1666)
63 #define TDB_FREE_MAGIC ((uint64_t)0xFE)
64 #define TDB_HASH_MAGIC (0xA1ABE11A01092008ULL)
65 #define TDB_RECOVERY_MAGIC (0xf53bc0e7ad124589ULL)
66 #define TDB_RECOVERY_INVALID_MAGIC (0x0ULL)
68 #define TDB_OFF_IS_ERR(off) unlikely(off >= (tdb_off_t)(long)TDB_ERR_LAST)
69 #define TDB_OFF_TO_ERR(off) ((enum TDB_ERROR)(long)(off))
70 #define TDB_ERR_TO_OFF(ecode) ((tdb_off_t)(long)(ecode))
72 /* Packing errors into pointers and v.v. */
73 #define TDB_PTR_IS_ERR(ptr) \
74 unlikely((unsigned long)(ptr) >= (unsigned long)TDB_ERR_LAST)
75 #define TDB_PTR_ERR(p) ((enum TDB_ERROR)(long)(p))
76 #define TDB_ERR_PTR(err) ((void *)(long)(err))
78 /* Common case of returning true, false or -ve error. */
79 typedef int tdb_bool_err;
81 /* Prevent others from opening the file. */
82 #define TDB_OPEN_LOCK 0
84 #define TDB_EXPANSION_LOCK 2
85 /* Doing a transaction. */
86 #define TDB_TRANSACTION_LOCK 8
87 /* Hash chain locks. */
88 #define TDB_HASH_LOCK_START 64
90 /* Range for hash locks. */
91 #define TDB_HASH_LOCK_RANGE_BITS 30
92 #define TDB_HASH_LOCK_RANGE (1 << TDB_HASH_LOCK_RANGE_BITS)
94 /* We have 1024 entries in the top level. */
95 #define TDB_TOPLEVEL_HASH_BITS 10
96 /* And 64 entries in each sub-level: thus 64 bits exactly after 9 levels. */
97 #define TDB_SUBLEVEL_HASH_BITS 6
98 /* And 8 entries in each group, ie 8 groups per sublevel. */
99 #define TDB_HASH_GROUP_BITS 3
100 /* This is currently 10: beyond this we chain. */
101 #define TDB_MAX_LEVELS (1+(64-TDB_TOPLEVEL_HASH_BITS) / TDB_SUBLEVEL_HASH_BITS)
103 /* Extend file by least 100 times larger than needed. */
104 #define TDB_EXTENSION_FACTOR 100
106 /* We steal bits from the offsets to store hash info. */
107 #define TDB_OFF_HASH_GROUP_MASK ((1ULL << TDB_HASH_GROUP_BITS) - 1)
108 /* We steal this many upper bits, giving a maximum offset of 64 exabytes. */
109 #define TDB_OFF_UPPER_STEAL 8
110 #define TDB_OFF_UPPER_STEAL_EXTRA 7
111 /* The bit number where we store extra hash bits. */
112 #define TDB_OFF_HASH_EXTRA_BIT 57
113 #define TDB_OFF_UPPER_STEAL_SUBHASH_BIT 56
115 /* Additional features we understand. Currently: none. */
116 #define TDB_FEATURE_MASK ((uint64_t)0)
118 /* The bit number where we store the extra hash bits. */
119 /* Convenience mask to get actual offset. */
120 #define TDB_OFF_MASK \
121 (((1ULL << (64 - TDB_OFF_UPPER_STEAL)) - 1) - TDB_OFF_HASH_GROUP_MASK)
123 /* How many buckets in a free list: see size_to_bucket(). */
124 #define TDB_FREE_BUCKETS (64 - TDB_OFF_UPPER_STEAL)
126 /* We have to be able to fit a free record here. */
127 #define TDB_MIN_DATA_LEN \
128 (sizeof(struct tdb_free_record) - sizeof(struct tdb_used_record))
130 /* Indicates this entry is not on an flist (can happen during coalescing) */
131 #define TDB_FTABLE_NONE ((1ULL << TDB_OFF_UPPER_STEAL) - 1)
133 struct tdb_used_record {
134 /* For on-disk compatibility, we avoid bitfields:
140 uint64_t magic_and_meta;
141 /* The bottom key_len_bits*2 are key length, rest is data length. */
142 uint64_t key_and_data_len;
145 static inline unsigned rec_key_bits(const struct tdb_used_record *r)
147 return ((r->magic_and_meta >> 43) & ((1 << 5)-1)) * 2;
150 static inline uint64_t rec_key_length(const struct tdb_used_record *r)
152 return r->key_and_data_len & ((1ULL << rec_key_bits(r)) - 1);
155 static inline uint64_t rec_data_length(const struct tdb_used_record *r)
157 return r->key_and_data_len >> rec_key_bits(r);
160 static inline uint64_t rec_extra_padding(const struct tdb_used_record *r)
162 return (r->magic_and_meta >> 11) & 0xFFFFFFFF;
165 static inline uint32_t rec_hash(const struct tdb_used_record *r)
167 return r->magic_and_meta & ((1 << 11) - 1);
170 static inline uint16_t rec_magic(const struct tdb_used_record *r)
172 return (r->magic_and_meta >> 48);
175 struct tdb_free_record {
176 uint64_t magic_and_prev; /* TDB_OFF_UPPER_STEAL bits magic, then prev */
177 uint64_t ftable_and_len; /* Len not counting these two fields. */
178 /* This is why the minimum record size is 8 bytes. */
182 static inline uint64_t frec_prev(const struct tdb_free_record *f)
184 return f->magic_and_prev & ((1ULL << (64 - TDB_OFF_UPPER_STEAL)) - 1);
187 static inline uint64_t frec_magic(const struct tdb_free_record *f)
189 return f->magic_and_prev >> (64 - TDB_OFF_UPPER_STEAL);
192 static inline uint64_t frec_len(const struct tdb_free_record *f)
194 return f->ftable_and_len & ((1ULL << (64 - TDB_OFF_UPPER_STEAL))-1);
197 static inline unsigned frec_ftable(const struct tdb_free_record *f)
199 return f->ftable_and_len >> (64 - TDB_OFF_UPPER_STEAL);
202 struct tdb_recovery_record {
204 /* Length of record (add this header to get total length). */
208 /* Old length of file before transaction. */
212 /* If we bottom out of the subhashes, we chain. */
214 tdb_off_t rec[1 << TDB_HASH_GROUP_BITS];
218 /* this is stored at the front of every database */
220 char magic_food[64]; /* for /etc/magic */
221 /* FIXME: Make me 32 bit? */
222 uint64_t version; /* version of the code */
223 uint64_t hash_test; /* result of hashing HASH_MAGIC. */
224 uint64_t hash_seed; /* "random" seed written at creation time. */
225 tdb_off_t free_table; /* (First) free table. */
226 tdb_off_t recovery; /* Transaction recovery area. */
228 uint64_t features_used; /* Features all writers understand */
229 uint64_t features_offered; /* Features offered */
231 uint64_t seqnum; /* Sequence number for TDB_SEQNUM */
233 tdb_off_t reserved[23];
235 /* Top level hash table. */
236 tdb_off_t hashtable[1ULL << TDB_TOPLEVEL_HASH_BITS];
239 struct tdb_freetable {
240 struct tdb_used_record hdr;
242 tdb_off_t buckets[TDB_FREE_BUCKETS];
245 /* Information about a particular (locked) hash entry. */
247 /* Full hash value of entry. */
249 /* Start and length of lock acquired. */
250 tdb_off_t hlock_start;
251 tdb_len_t hlock_range;
252 /* Start of hash group. */
253 tdb_off_t group_start;
254 /* Bucket we belong in. */
255 unsigned int home_bucket;
256 /* Bucket we (or an empty space) were found in. */
257 unsigned int found_bucket;
258 /* How many bits of the hash are already used. */
259 unsigned int hash_used;
260 /* Current working group. */
261 tdb_off_t group[1 << TDB_HASH_GROUP_BITS];
264 struct traverse_info {
265 struct traverse_level {
267 /* We ignore groups here, and treat it as a big array. */
269 unsigned int total_buckets;
270 } levels[TDB_MAX_LEVELS + 1];
271 unsigned int num_levels;
272 unsigned int toplevel_group;
273 /* This makes delete-everything-inside-traverse work as expected. */
277 typedef uint32_t tdb1_len_t;
278 typedef uint32_t tdb1_off_t;
280 enum tdb_lock_flags {
281 /* WAIT == F_SETLKW, NOWAIT == F_SETLK */
284 /* If set, don't log an error on failure. */
286 /* If set, don't check for recovery (used by recovery code). */
287 TDB_LOCK_NOCHECK = 4,
291 struct tdb_context *owner;
297 /* This is only needed for tdb_access_commit, but used everywhere to
299 struct tdb_access_hdr {
300 struct tdb_access_hdr *next;
307 /* How many are sharing us? */
310 /* Mmap (if any), or malloc (for TDB_INTERNAL). */
313 /* How much space has been mapped (<= current file size) */
316 /* The file descriptor (-1 for TDB_INTERNAL). */
319 /* Lock information */
321 struct tdb_lock allrecord_lock;
323 struct tdb_lock *lockrecs;
325 /* Identity of this file. */
331 enum TDB_ERROR (*tread)(struct tdb_context *, tdb_off_t, void *,
333 enum TDB_ERROR (*twrite)(struct tdb_context *, tdb_off_t, const void *,
335 enum TDB_ERROR (*oob)(struct tdb_context *, tdb_off_t, bool);
336 enum TDB_ERROR (*expand_file)(struct tdb_context *, tdb_len_t);
337 void *(*direct)(struct tdb_context *, tdb_off_t, size_t, bool);
344 uint64_t tdb_jenkins_hash(const void *key, size_t length, uint64_t seed,
347 enum TDB_ERROR first_in_hash(struct tdb_context *tdb,
348 struct traverse_info *tinfo,
349 TDB_DATA *kbuf, size_t *dlen);
351 enum TDB_ERROR next_in_hash(struct tdb_context *tdb,
352 struct traverse_info *tinfo,
353 TDB_DATA *kbuf, size_t *dlen);
355 /* Hash random memory. */
356 uint64_t tdb_hash(struct tdb_context *tdb, const void *ptr, size_t len);
359 uint64_t hash_record(struct tdb_context *tdb, tdb_off_t off);
361 /* Find and lock a hash entry (or where it would be). */
362 tdb_off_t find_and_lock(struct tdb_context *tdb,
366 struct tdb_used_record *rec,
367 struct traverse_info *tinfo);
369 enum TDB_ERROR replace_in_hash(struct tdb_context *tdb,
373 enum TDB_ERROR add_to_hash(struct tdb_context *tdb, struct hash_info *h,
376 enum TDB_ERROR delete_from_hash(struct tdb_context *tdb, struct hash_info *h);
379 bool is_subhash(tdb_off_t val);
382 enum TDB_ERROR tdb_ftable_init(struct tdb_context *tdb);
384 /* check.c needs these to iterate through free lists. */
385 tdb_off_t first_ftable(struct tdb_context *tdb);
386 tdb_off_t next_ftable(struct tdb_context *tdb, tdb_off_t ftable);
388 /* This returns space or -ve error number. */
389 tdb_off_t alloc(struct tdb_context *tdb, size_t keylen, size_t datalen,
390 uint64_t hash, unsigned magic, bool growing);
392 /* Put this record in a free list. */
393 enum TDB_ERROR add_free_record(struct tdb_context *tdb,
394 tdb_off_t off, tdb_len_t len_with_header,
395 enum tdb_lock_flags waitflag,
398 /* Set up header for a used/ftable/htable/chain record. */
399 enum TDB_ERROR set_header(struct tdb_context *tdb,
400 struct tdb_used_record *rec,
401 unsigned magic, uint64_t keylen, uint64_t datalen,
402 uint64_t actuallen, unsigned hashlow);
404 /* Used by tdb_check to verify. */
405 unsigned int size_to_bucket(tdb_len_t data_len);
406 tdb_off_t bucket_off(tdb_off_t ftable_off, unsigned bucket);
408 /* Used by tdb_summary */
409 tdb_off_t dead_space(struct tdb_context *tdb, tdb_off_t off);
412 /* Initialize tdb->methods. */
413 void tdb_io_init(struct tdb_context *tdb);
415 /* Convert endian of the buffer if required. */
416 void *tdb_convert(const struct tdb_context *tdb, void *buf, tdb_len_t size);
418 /* Unmap and try to map the tdb. */
419 void tdb_munmap(struct tdb_file *file);
420 void tdb_mmap(struct tdb_context *tdb);
422 /* Either alloc a copy, or give direct access. Release frees or noop. */
423 const void *tdb_access_read(struct tdb_context *tdb,
424 tdb_off_t off, tdb_len_t len, bool convert);
425 void *tdb_access_write(struct tdb_context *tdb,
426 tdb_off_t off, tdb_len_t len, bool convert);
428 /* Release result of tdb_access_read/write. */
429 void tdb_access_release(struct tdb_context *tdb, const void *p);
430 /* Commit result of tdb_acces_write. */
431 enum TDB_ERROR tdb_access_commit(struct tdb_context *tdb, void *p);
433 /* Convenience routine to get an offset. */
434 tdb_off_t tdb_read_off(struct tdb_context *tdb, tdb_off_t off);
436 /* Write an offset at an offset. */
437 enum TDB_ERROR tdb_write_off(struct tdb_context *tdb, tdb_off_t off,
440 /* Clear an ondisk area. */
441 enum TDB_ERROR zero_out(struct tdb_context *tdb, tdb_off_t off, tdb_len_t len);
443 /* Return a non-zero offset between >= start < end in this array (or end). */
444 tdb_off_t tdb_find_nonzero_off(struct tdb_context *tdb,
449 /* Return a zero offset in this array, or num. */
450 tdb_off_t tdb_find_zero_off(struct tdb_context *tdb, tdb_off_t off,
453 /* Allocate and make a copy of some offset. */
454 void *tdb_alloc_read(struct tdb_context *tdb, tdb_off_t offset, tdb_len_t len);
456 /* Writes a converted copy of a record. */
457 enum TDB_ERROR tdb_write_convert(struct tdb_context *tdb, tdb_off_t off,
458 const void *rec, size_t len);
460 /* Reads record and converts it */
461 enum TDB_ERROR tdb_read_convert(struct tdb_context *tdb, tdb_off_t off,
462 void *rec, size_t len);
464 /* Bump the seqnum (caller checks for tdb->flags & TDB_SEQNUM) */
465 void tdb_inc_seqnum(struct tdb_context *tdb);
468 /* Print message because another tdb owns a lock we want. */
469 enum TDB_ERROR owner_conflict(struct tdb_context *tdb, const char *call);
471 /* If we fork, we no longer really own locks. */
472 bool check_lock_pid(struct tdb_context *tdb, const char *call, bool log);
474 /* Lock/unlock a range of hashes. */
475 enum TDB_ERROR tdb_lock_hashes(struct tdb_context *tdb,
476 tdb_off_t hash_lock, tdb_len_t hash_range,
477 int ltype, enum tdb_lock_flags waitflag);
478 enum TDB_ERROR tdb_unlock_hashes(struct tdb_context *tdb,
480 tdb_len_t hash_range, int ltype);
482 /* For closing the file. */
483 void tdb_lock_cleanup(struct tdb_context *tdb);
485 /* Lock/unlock a particular free bucket. */
486 enum TDB_ERROR tdb_lock_free_bucket(struct tdb_context *tdb, tdb_off_t b_off,
487 enum tdb_lock_flags waitflag);
488 void tdb_unlock_free_bucket(struct tdb_context *tdb, tdb_off_t b_off);
490 /* Serialize transaction start. */
491 enum TDB_ERROR tdb_transaction_lock(struct tdb_context *tdb, int ltype);
492 void tdb_transaction_unlock(struct tdb_context *tdb, int ltype);
494 /* Do we have any hash locks (ie. via tdb_chainlock) ? */
495 bool tdb_has_hash_locks(struct tdb_context *tdb);
497 /* Lock entire database. */
498 enum TDB_ERROR tdb_allrecord_lock(struct tdb_context *tdb, int ltype,
499 enum tdb_lock_flags flags, bool upgradable);
500 void tdb_allrecord_unlock(struct tdb_context *tdb, int ltype);
501 enum TDB_ERROR tdb_allrecord_upgrade(struct tdb_context *tdb, off_t start);
503 /* Serialize db open. */
504 enum TDB_ERROR tdb_lock_open(struct tdb_context *tdb,
505 int ltype, enum tdb_lock_flags flags);
506 void tdb_unlock_open(struct tdb_context *tdb, int ltype);
507 bool tdb_has_open_lock(struct tdb_context *tdb);
509 /* Serialize db expand. */
510 enum TDB_ERROR tdb_lock_expand(struct tdb_context *tdb, int ltype);
511 void tdb_unlock_expand(struct tdb_context *tdb, int ltype);
512 bool tdb_has_expansion_lock(struct tdb_context *tdb);
514 /* If it needs recovery, grab all the locks and do it. */
515 enum TDB_ERROR tdb_lock_and_recover(struct tdb_context *tdb);
517 /* Byte-range lock wrappers for TDB1 to access. */
518 enum TDB_ERROR tdb_brlock(struct tdb_context *tdb,
519 int rw_type, tdb_off_t offset, tdb_off_t len,
520 enum tdb_lock_flags flags);
522 enum TDB_ERROR tdb_brunlock(struct tdb_context *tdb,
523 int rw_type, tdb_off_t offset, size_t len);
525 enum TDB_ERROR tdb_nest_lock(struct tdb_context *tdb,
526 tdb_off_t offset, int ltype,
527 enum tdb_lock_flags flags);
529 enum TDB_ERROR tdb_nest_unlock(struct tdb_context *tdb,
530 tdb_off_t off, int ltype);
532 enum TDB_ERROR tdb_lock_gradual(struct tdb_context *tdb,
533 int ltype, enum tdb_lock_flags flags,
534 tdb_off_t off, tdb_off_t len);
536 /* Default lock and unlock functions. */
537 int tdb_fcntl_lock(int fd, int rw, off_t off, off_t len, bool waitflag, void *);
538 int tdb_fcntl_unlock(int fd, int rw, off_t off, off_t len, void *);
541 enum TDB_ERROR tdb_transaction_recover(struct tdb_context *tdb);
542 tdb_bool_err tdb_needs_recovery(struct tdb_context *tdb);
544 /* this is stored at the front of every database */
546 char magic_food[32]; /* for /etc/magic */
547 uint32_t version; /* version of the code */
548 uint32_t hash_size; /* number of hash entries */
549 tdb1_off_t rwlocks; /* obsolete - kept to detect old formats */
550 tdb1_off_t recovery_start; /* offset of transaction recovery region */
551 tdb1_off_t sequence_number; /* used when TDB1_SEQNUM is set */
552 uint32_t magic1_hash; /* hash of TDB_MAGIC_FOOD. */
553 uint32_t magic2_hash; /* hash of TDB1_MAGIC. */
554 tdb1_off_t reserved[27];
557 struct tdb1_traverse_lock {
558 struct tdb1_traverse_lock *next;
565 /* Single list of all TDBs, to detect multiple opens. */
566 struct tdb_context *next;
568 /* Filename of the database. */
571 /* Logging function */
572 void (*log_fn)(struct tdb_context *tdb,
573 enum tdb_log_level level,
574 enum TDB_ERROR ecode,
579 /* Open flags passed to tdb_open. */
582 /* low level (fnctl) lock functions. */
583 int (*lock_fn)(int fd, int rw, off_t off, off_t len, bool w, void *);
584 int (*unlock_fn)(int fd, int rw, off_t off, off_t len, void *);
587 /* the tdb flags passed to tdb_open. */
590 /* Our statistics. */
591 struct tdb_attribute_stats stats;
593 /* The actual file information */
594 struct tdb_file *file;
597 uint64_t (*hash_fn)(const void *key, size_t len, uint64_t seed, void *);
601 /* Our open hook, if any. */
602 enum TDB_ERROR (*openhook)(int fd, void *data);
605 /* Last error we returned. */
606 enum TDB_ERROR last_error;
610 /* Are we accessing directly? (debugging check). */
613 /* Set if we are in a transaction. */
614 struct tdb_transaction *transaction;
616 /* What free table are we using? */
617 tdb_off_t ftable_off;
620 /* IO methods: changes for transactions. */
621 const struct tdb_methods *io;
623 /* Direct access information */
624 struct tdb_access_hdr *access;
628 int traverse_read; /* read-only traversal */
629 int traverse_write; /* read-write traversal */
631 struct tdb1_header header; /* a cached copy of the header */
632 struct tdb1_traverse_lock travlocks; /* current traversal locks */
633 const struct tdb1_methods *io;
634 struct tdb1_transaction *transaction;
636 int max_dead_records;
640 #define TDB1_BYTEREV(x) (((((x)&0xff)<<24)|((x)&0xFF00)<<8)|(((x)>>8)&0xFF00)|((x)>>24))
643 int tdb1_check(struct tdb_context *tdb,
644 enum TDB_ERROR (*check)(TDB_DATA key, TDB_DATA data, void *),
649 enum TDB_ERROR tdb1_new_database(struct tdb_context *tdb,
650 struct tdb_attribute_tdb1_hashsize *hashsize,
651 struct tdb_attribute_tdb1_max_dead *max_dead);
652 enum TDB_ERROR tdb1_open(struct tdb_context *tdb,
653 struct tdb_attribute_tdb1_max_dead *max_dead);
656 enum TDB_ERROR tdb1_probe_length(struct tdb_context *tdb);
659 int tdb1_allrecord_lock(struct tdb_context *tdb, int ltype,
660 enum tdb_lock_flags flags, bool upgradable);
661 int tdb1_allrecord_unlock(struct tdb_context *tdb, int ltype);
663 int tdb1_chainlock(struct tdb_context *tdb, TDB_DATA key);
664 int tdb1_chainunlock(struct tdb_context *tdb, TDB_DATA key);
665 int tdb1_chainlock_read(struct tdb_context *tdb, TDB_DATA key);
666 int tdb1_chainunlock_read(struct tdb_context *tdb, TDB_DATA key);
668 /* tdb1_transaction.c: */
669 int tdb1_transaction_recover(struct tdb_context *tdb);
670 int tdb1_transaction_cancel(struct tdb_context *tdb);
672 /* tdb1_traverse.c: */
673 int tdb1_traverse(struct tdb_context *tdb,
674 int (*)(struct tdb_context *, TDB_DATA, TDB_DATA, void *),
677 /* tdb1_summary.c: */
678 char *tdb1_summary(struct tdb_context *tdb);
681 int tdb1_store(struct tdb_context *tdb, TDB_DATA key, TDB_DATA dbuf, int flag);
682 enum TDB_ERROR tdb1_fetch(struct tdb_context *tdb, TDB_DATA key,
684 int tdb1_append(struct tdb_context *tdb, TDB_DATA key, TDB_DATA new_dbuf);
685 int tdb1_delete(struct tdb_context *tdb, TDB_DATA key);
686 int tdb1_exists(struct tdb_context *tdb, TDB_DATA key);
687 enum TDB_ERROR tdb1_parse_record(struct tdb_context *tdb, TDB_DATA key,
688 enum TDB_ERROR (*parser)(TDB_DATA key,
692 void tdb1_increment_seqnum_nonblock(struct tdb_context *tdb);
693 int tdb1_get_seqnum(struct tdb_context *tdb);
694 int tdb1_wipe_all(struct tdb_context *tdb);
696 /* tdb1_transaction.c: */
697 int tdb1_transaction_start(struct tdb_context *tdb);
698 int tdb1_transaction_prepare_commit(struct tdb_context *tdb);
699 int tdb1_transaction_commit(struct tdb_context *tdb);
701 /* tdb1_traverse.c: */
702 TDB_DATA tdb1_firstkey(struct tdb_context *tdb);
703 TDB_DATA tdb1_nextkey(struct tdb_context *tdb, TDB_DATA key);
706 enum TDB_ERROR COLD tdb_logerr(struct tdb_context *tdb,
707 enum TDB_ERROR ecode,
708 enum tdb_log_level level,
709 const char *fmt, ...);
712 void tdb_trace(struct tdb_context *tdb, const char *op);
713 void tdb_trace_seqnum(struct tdb_context *tdb, uint32_t seqnum, const char *op);
714 void tdb_trace_open(struct tdb_context *tdb, const char *op,
715 unsigned hash_size, unsigned tdb_flags, unsigned open_flags);
716 void tdb_trace_ret(struct tdb_context *tdb, const char *op, int ret);
717 void tdb_trace_retrec(struct tdb_context *tdb, const char *op, TDB_DATA ret);
718 void tdb_trace_1rec(struct tdb_context *tdb, const char *op,
720 void tdb_trace_1rec_ret(struct tdb_context *tdb, const char *op,
721 TDB_DATA rec, int ret);
722 void tdb_trace_1rec_retrec(struct tdb_context *tdb, const char *op,
723 TDB_DATA rec, TDB_DATA ret);
724 void tdb_trace_2rec_flag_ret(struct tdb_context *tdb, const char *op,
725 TDB_DATA rec1, TDB_DATA rec2, unsigned flag,
727 void tdb_trace_2rec_retrec(struct tdb_context *tdb, const char *op,
728 TDB_DATA rec1, TDB_DATA rec2, TDB_DATA ret);
730 #define tdb_trace(tdb, op)
731 #define tdb_trace_seqnum(tdb, seqnum, op)
732 #define tdb_trace_open(tdb, op, hash_size, tdb_flags, open_flags)
733 #define tdb_trace_ret(tdb, op, ret)
734 #define tdb_trace_retrec(tdb, op, ret)
735 #define tdb_trace_1rec(tdb, op, rec)
736 #define tdb_trace_1rec_ret(tdb, op, rec, ret)
737 #define tdb_trace_1rec_retrec(tdb, op, rec, ret)
738 #define tdb_trace_2rec_flag_ret(tdb, op, rec1, rec2, flag, ret)
739 #define tdb_trace_2rec_retrec(tdb, op, rec1, rec2, ret)
740 #endif /* !TDB_TRACE */