This is a note to let you know that I've just added the patch titled dm thin: switch to read-only mode if metadata space is exhausted to the 3.12-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: dm-thin-switch-to-read-only-mode-if-metadata-space-is-exhausted.patch and it can be found in the queue-3.12 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From 4a02b34e0cf1d0d0dd3737702841da4bf615a50a Mon Sep 17 00:00:00 2001 From: Mike Snitzer <snitzer@xxxxxxxxxx> Date: Tue, 3 Dec 2013 12:20:57 -0500 Subject: dm thin: switch to read-only mode if metadata space is exhausted From: Mike Snitzer <snitzer@xxxxxxxxxx> commit 4a02b34e0cf1d0d0dd3737702841da4bf615a50a upstream. Switch the thin pool to read-only mode in alloc_data_block() if dm_pool_alloc_data_block() fails because the pool's metadata space is exhausted. Differentiate between data and metadata space in messages about no free space available. This issue was noticed with the device-mapper-test-suite using: dmtest run --suite thin-provisioning -n /exhausting_metadata_space_causes_fail_mode/ The quantity of errors logged in this case must be reduced. before patch: device-mapper: thin: 253:4: reached low water mark for metadata device: sending event. device-mapper: space map metadata: unable to allocate new metadata block device-mapper: space map common: dm_tm_shadow_block() failed device-mapper: space map metadata: unable to allocate new metadata block device-mapper: space map common: dm_tm_shadow_block() failed device-mapper: space map metadata: unable to allocate new metadata block device-mapper: space map common: dm_tm_shadow_block() failed device-mapper: space map metadata: unable to allocate new metadata block device-mapper: space map common: dm_tm_shadow_block() failed device-mapper: space map metadata: unable to allocate new metadata block device-mapper: space map common: dm_tm_shadow_block() failed <snip ... these repeat for a _very_ long while ... > device-mapper: space map metadata: unable to allocate new metadata block device-mapper: thin: 253:4: commit failed: error = -28 device-mapper: thin: 253:4: switching pool to read-only mode after patch: device-mapper: thin: 253:4: reached low water mark for metadata device: sending event. device-mapper: space map metadata: unable to allocate new metadata block device-mapper: thin: 253:4: no free metadata space available. device-mapper: thin: 253:4: switching pool to read-only mode Signed-off-by: Mike Snitzer <snitzer@xxxxxxxxxx> Acked-by: Joe Thornber <ejt@xxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- drivers/md/dm-thin.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) --- a/drivers/md/dm-thin.c +++ b/drivers/md/dm-thin.c @@ -959,7 +959,7 @@ static int alloc_data_block(struct thin_ * table reload). */ if (!free_blocks) { - DMWARN("%s: no free space available.", + DMWARN("%s: no free data space available.", dm_device_name(pool->pool_md)); spin_lock_irqsave(&pool->lock, flags); pool->no_free_space = 1; @@ -969,8 +969,16 @@ static int alloc_data_block(struct thin_ } r = dm_pool_alloc_data_block(pool->pmd, result); - if (r) + if (r) { + if (r == -ENOSPC && + !dm_pool_get_free_metadata_block_count(pool->pmd, &free_blocks) && + !free_blocks) { + DMWARN("%s: no free metadata space available.", + dm_device_name(pool->pool_md)); + set_pool_mode(pool, PM_READ_ONLY); + } return r; + } return 0; } Patches currently in stable-queue which might be from snitzer@xxxxxxxxxx are queue-3.12/dm-array-fix-a-reference-counting-bug-in-shadow_ablock.patch queue-3.12/dm-thin-always-fallback-the-pool-mode-if-commit-fails.patch queue-3.12/dm-table-fail-dm_table_create-on-dm_round_up-overflow.patch queue-3.12/dm-stats-initialize-read-only-module-parameter.patch queue-3.12/dm-thin-allow-pool-in-read-only-mode-to-transition-to-read-write-mode.patch queue-3.12/dm-space-map-metadata-return-on-failure-in-sm_metadata_new_block.patch queue-3.12/dm-bufio-initialize-read-only-module-parameters.patch queue-3.12/dm-snapshot-avoid-snapshot-space-leak-on-crash.patch queue-3.12/dm-thin-re-establish-read-only-state-when-switching-to-fail-mode.patch queue-3.12/dm-delay-fix-a-possible-deadlock-due-to-shared-workqueue.patch queue-3.12/dm-thin-switch-to-read-only-mode-if-a-mapping-insert-fails.patch queue-3.12/dm-thin-switch-to-read-only-mode-if-metadata-space-is-exhausted.patch queue-3.12/dm-space-map-disallow-decrementing-a-reference-count-below-zero.patch -- To unsubscribe from this list: send the line "unsubscribe stable" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html