From 6610df34236a3e038f1a224e57ec7a24c94147b2 Mon Sep 17 00:00:00 2001 From: Joe Thornber Date: Fri, 9 Aug 2013 14:01:38 +0100 Subject: dm block manager: Make block locking configurable At the moment block locking only serves as a sanity check for code that uses the persistent-data library. Turning it off can save a small amount of time in some circumstances. For instance deleting a thin volume with 1 million unique mappings goes from ~9 seconds -> ~6.5. [FIXME: Not sure if this should go upstream. The plan after all is to use block locking to allow concurrent lookups and insertions into btrees via a rolling lock scheme. Keeping this in my tree since it's useful to regularly assess the cost of block locking.] --- drivers/md/Kconfig | 10 ---------- drivers/md/persistent-data/Kconfig | 25 ++++++++++++++++++++++--- drivers/md/persistent-data/dm-block-manager.c | 16 +++++++++++++++- 3 files changed, 37 insertions(+), 14 deletions(-) Index: linux/drivers/md/Kconfig =================================================================== --- linux.orig/drivers/md/Kconfig +++ linux/drivers/md/Kconfig @@ -249,16 +249,6 @@ config DM_THIN_PROVISIONING ---help--- Provides thin provisioning and snapshots that share a data store. -config DM_DEBUG_BLOCK_STACK_TRACING - boolean "Keep stack trace of thin provisioning block lock holders" - depends on STACKTRACE_SUPPORT && DM_THIN_PROVISIONING - select STACKTRACE - ---help--- - Enable this for messages that may help debug problems with the - block manager locking used by thin provisioning. - - If unsure, say N. - config DM_CACHE tristate "Cache target (EXPERIMENTAL)" depends on BLK_DEV_DM Index: linux/drivers/md/persistent-data/Kconfig =================================================================== --- linux.orig/drivers/md/persistent-data/Kconfig +++ linux/drivers/md/persistent-data/Kconfig @@ -1,8 +1,27 @@ config DM_PERSISTENT_DATA - tristate + tristate "Persistent data library" depends on BLK_DEV_DM select LIBCRC32C select DM_BUFIO ---help--- - Library providing immutable on-disk data structure support for - device-mapper targets such as the thin provisioning target. + Library providing immutable on-disk data structure support + for device-mapper targets such as the thin provisioning and + caching targets. + +config DM_DEBUG_BLOCK_LOCKING + boolean "Use locking to restrict concurrent access to blocks" + depends on DM_PERSISTENT_DATA + ---help--- + Enable this to help debug code that uses DM_PERSISTENT_DATA. + + If unsure, say N. + +config DM_DEBUG_BLOCK_STACK_TRACING + boolean "Keep stack trace of thin provisioning block lock holders" + depends on DM_DEBUG_BLOCK_LOCKING && STACKTRACE_SUPPORT + select STACKTRACE + ---help--- + Enable this for messages that may help debug problems with the + block manager locking used by thin provisioning. + + If unsure, say N. Index: linux/drivers/md/persistent-data/dm-block-manager.c =================================================================== --- linux.orig/drivers/md/persistent-data/dm-block-manager.c +++ linux/drivers/md/persistent-data/dm-block-manager.c @@ -18,6 +18,8 @@ /*----------------------------------------------------------------*/ +#ifdef CONFIG_DM_DEBUG_BLOCK_LOCKING + /* * This is a read/write semaphore with a couple of differences. * @@ -310,6 +312,15 @@ static void report_recursive_bug(dm_bloc DMERR("recursive acquisition of block %llu requested.", (unsigned long long) b); } +#else +#define bl_init(x) +#define bl_down_read(x) 0 +#define bl_down_read_nonblock(x) 0 +#define bl_up_read(x) +#define bl_down_write(x) 0 +#define bl_up_write(x) +#define report_recursive_bug(x, y) +#endif /*----------------------------------------------------------------*/ @@ -339,8 +350,11 @@ EXPORT_SYMBOL_GPL(dm_block_data); struct buffer_aux { struct dm_block_validator *validator; - struct block_lock lock; int write_locked; + +#ifdef CONFIG_DM_DEBUG_BLOCK_LOCKING + struct block_lock lock; +#endif }; static void dm_block_manager_alloc_callback(struct dm_buffer *buf)