This is a note to let you know that I've just added the patch titled dm thin: fix missing out-of-data-space to write mode transition if blocks are released to the 3.17-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-fix-missing-out-of-data-space-to-write-mode-transition-if-blocks-are-released.patch and it can be found in the queue-3.17 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From 2c43fd26e46734430122b8d2ad3024bb532df3ef Mon Sep 17 00:00:00 2001 From: Joe Thornber <ejt@xxxxxxxxxx> Date: Thu, 11 Dec 2014 11:12:19 +0000 Subject: dm thin: fix missing out-of-data-space to write mode transition if blocks are released From: Joe Thornber <ejt@xxxxxxxxxx> commit 2c43fd26e46734430122b8d2ad3024bb532df3ef upstream. Discard bios and thin device deletion have the potential to release data blocks. If the thin-pool is in out-of-data-space mode, and blocks were released, transition the thin-pool back to full write mode. The correct time to do this is just after the thin-pool metadata commit. It cannot be done before the commit because the space maps will not allow immediate reuse of the data blocks in case there's a rollback following power failure. Signed-off-by: Joe Thornber <ejt@xxxxxxxxxx> Signed-off-by: Mike Snitzer <snitzer@xxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- drivers/md/dm-thin.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) --- a/drivers/md/dm-thin.c +++ b/drivers/md/dm-thin.c @@ -990,6 +990,24 @@ static void schedule_external_copy(struc schedule_zero(tc, virt_block, data_dest, cell, bio); } +static void set_pool_mode(struct pool *pool, enum pool_mode new_mode); + +static void check_for_space(struct pool *pool) +{ + int r; + dm_block_t nr_free; + + if (get_pool_mode(pool) != PM_OUT_OF_DATA_SPACE) + return; + + r = dm_pool_get_free_block_count(pool->pmd, &nr_free); + if (r) + return; + + if (nr_free) + set_pool_mode(pool, PM_WRITE); +} + /* * A non-zero return indicates read_only or fail_io mode. * Many callers don't care about the return value. @@ -1004,6 +1022,8 @@ static int commit(struct pool *pool) r = dm_pool_commit_metadata(pool->pmd); if (r) metadata_operation_failed(pool, "dm_pool_commit_metadata", r); + else + check_for_space(pool); return r; } @@ -1022,8 +1042,6 @@ static void check_low_water_mark(struct } } -static void set_pool_mode(struct pool *pool, enum pool_mode new_mode); - static int alloc_data_block(struct thin_c *tc, dm_block_t *result) { int r; Patches currently in stable-queue which might be from ejt@xxxxxxxxxx are queue-3.17/dm-space-map-metadata-fix-sm_bootstrap_get_nr_blocks.patch queue-3.17/dm-thin-fix-missing-out-of-data-space-to-write-mode-transition-if-blocks-are-released.patch queue-3.17/dm-cache-fix-spurious-cell_defer-when-dealing-with-partial-block-at-end-of-device.patch queue-3.17/dm-thin-fix-inability-to-discard-blocks-when-in-out-of-data-space-mode.patch queue-3.17/dm-cache-only-use-overwrite-optimisation-for-promotion-when-in-writeback-mode.patch queue-3.17/dm-cache-dirty-flag-was-mistakenly-being-cleared-when-promoting-via-overwrite.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