From 5d9de604d92d227899e9b861c6beafb2e4fa61e0 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 17 Feb 2010 12:26:13 +1030 Subject: tdb: cleanup: tdb_nest_lock/tdb_nest_unlock Because fcntl locks don't nest, we track them in the tdb->lockrecs array and only place/release them when the count goes to 1/0. We only do this for record locks, so we simply place the list number (or -1 for the free list) in the structure. To generalize this: 1) Put the offset rather than list number in struct tdb_lock_type. 2) Rename _tdb_lock() to tdb_nest_lock, make it non-static and move the allrecord check out to the callers (except the mark case which doesn't care). 3) Rename _tdb_unlock() to tdb_nest_unlock(), make it non-static and move the allrecord out to the callers (except mark again). Signed-off-by: Rusty Russell --- lib/tdb/common/tdb_private.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lib/tdb/common/tdb_private.h') diff --git a/lib/tdb/common/tdb_private.h b/lib/tdb/common/tdb_private.h index 2e5679690f..4e4816bd4a 100644 --- a/lib/tdb/common/tdb_private.h +++ b/lib/tdb/common/tdb_private.h @@ -151,7 +151,7 @@ struct tdb_header { }; struct tdb_lock_type { - int list; + uint32_t off; uint32_t count; uint32_t ltype; }; @@ -224,6 +224,10 @@ int tdb_munmap(struct tdb_context *tdb); void tdb_mmap(struct tdb_context *tdb); int tdb_lock(struct tdb_context *tdb, int list, int ltype); int tdb_lock_nonblock(struct tdb_context *tdb, int list, int ltype); +int tdb_nest_lock(struct tdb_context *tdb, uint32_t offset, int ltype, + enum tdb_lock_flags flags); +int tdb_nest_unlock(struct tdb_context *tdb, uint32_t offset, int ltype, + bool mark_lock); int tdb_unlock(struct tdb_context *tdb, int list, int ltype); int tdb_brlock(struct tdb_context *tdb, int rw_type, tdb_off_t offset, size_t len, -- cgit