-static int chainlock_loop(struct tdb_context *tdb, const TDB_DATA *key,
- int ltype, enum tdb_lock_flags waitflag,
- const char *func)
-{
- int ret;
- uint64_t h = tdb_hash(tdb, key->dptr, key->dsize);
-
-again:
- ret = tdb_lock_list(tdb,
- h & ((1ULL << tdb->header.v.hash_bits) - 1),
- ltype, waitflag);
- if (likely(ret == 0) && unlikely(update_header(tdb))) {
- tdb_unlock_list(tdb, h & ((1ULL << tdb->header.v.hash_bits)-1),
- ltype);
- goto again;
- }
-
- tdb_trace_1rec(tdb, func, *key);
- return ret;
-}
-
-/* lock/unlock one hash chain. This is meant to be used to reduce
- contention - it cannot guarantee how many records will be locked */
-int tdb_chainlock(struct tdb_context *tdb, TDB_DATA key)
-{
- return chainlock_loop(tdb, &key, F_WRLCK, TDB_LOCK_WAIT,
- "tdb_chainlock");
-}
-