From: Greg Kroah-Hartman Date: Tue, 18 Nov 2014 19:43:48 +0000 (-0800) Subject: 3.14-stable patches X-Git-Tag: v3.10.61~33 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=27b1d4c515e8531a7beaf9c7ef4ed4243bfbdf25;p=thirdparty%2Fkernel%2Fstable-queue.git 3.14-stable patches added patches: dm-thin-grab-a-virtual-cell-before-looking-up-the-mapping.patch --- diff --git a/queue-3.14/dm-thin-grab-a-virtual-cell-before-looking-up-the-mapping.patch b/queue-3.14/dm-thin-grab-a-virtual-cell-before-looking-up-the-mapping.patch new file mode 100644 index 00000000000..d7decef2c5c --- /dev/null +++ b/queue-3.14/dm-thin-grab-a-virtual-cell-before-looking-up-the-mapping.patch @@ -0,0 +1,75 @@ +From c822ed967cba38505713d59ed40a114386ef6c01 Mon Sep 17 00:00:00 2001 +From: Joe Thornber +Date: Fri, 10 Oct 2014 09:41:09 +0100 +Subject: dm thin: grab a virtual cell before looking up the mapping + +From: Joe Thornber + +commit c822ed967cba38505713d59ed40a114386ef6c01 upstream. + +Avoids normal IO racing with discard. + +Signed-off-by: Joe Thornber +Signed-off-by: Mike Snitzer +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/md/dm-thin.c | 16 ++++++++++++---- + 1 file changed, 12 insertions(+), 4 deletions(-) + +--- a/drivers/md/dm-thin.c ++++ b/drivers/md/dm-thin.c +@@ -1704,6 +1704,14 @@ static int thin_bio_map(struct dm_target + return DM_MAPIO_SUBMITTED; + } + ++ /* ++ * We must hold the virtual cell before doing the lookup, otherwise ++ * there's a race with discard. ++ */ ++ build_virtual_key(tc->td, block, &key); ++ if (dm_bio_detain(tc->pool->prison, &key, bio, &cell1, &cell_result)) ++ return DM_MAPIO_SUBMITTED; ++ + r = dm_thin_find_block(td, block, 0, &result); + + /* +@@ -1727,13 +1735,10 @@ static int thin_bio_map(struct dm_target + * shared flag will be set in their case. + */ + thin_defer_bio(tc, bio); ++ cell_defer_no_holder_no_free(tc, &cell1); + return DM_MAPIO_SUBMITTED; + } + +- build_virtual_key(tc->td, block, &key); +- if (dm_bio_detain(tc->pool->prison, &key, bio, &cell1, &cell_result)) +- return DM_MAPIO_SUBMITTED; +- + build_data_key(tc->td, result.block, &key); + if (dm_bio_detain(tc->pool->prison, &key, bio, &cell2, &cell_result)) { + cell_defer_no_holder_no_free(tc, &cell1); +@@ -1754,6 +1759,7 @@ static int thin_bio_map(struct dm_target + * of doing so. + */ + handle_unserviceable_bio(tc->pool, bio); ++ cell_defer_no_holder_no_free(tc, &cell1); + return DM_MAPIO_SUBMITTED; + } + /* fall through */ +@@ -1764,6 +1770,7 @@ static int thin_bio_map(struct dm_target + * provide the hint to load the metadata into cache. + */ + thin_defer_bio(tc, bio); ++ cell_defer_no_holder_no_free(tc, &cell1); + return DM_MAPIO_SUBMITTED; + + default: +@@ -1773,6 +1780,7 @@ static int thin_bio_map(struct dm_target + * pool is switched to fail-io mode. + */ + bio_io_error(bio); ++ cell_defer_no_holder_no_free(tc, &cell1); + return DM_MAPIO_SUBMITTED; + } + } diff --git a/queue-3.14/series b/queue-3.14/series index 53521802c7e..ac2059d085b 100644 --- a/queue-3.14/series +++ b/queue-3.14/series @@ -41,3 +41,4 @@ drm-radeon-add-missing-crtc-unlock-when-setting-up-the-mc.patch arm-8198-1-make-kuser-helpers-depend-on-mmu.patch arm-8191-1-decompressor-ensure-i-side-picks-up-relocated-code.patch pinctrl-dra-dt-bindings-fix-output-pull-up-down.patch +dm-thin-grab-a-virtual-cell-before-looking-up-the-mapping.patch