[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[dm-devel] [PATCH] dm-thin: don't send discards to shared blocks


This patch prevents dm-thin from sending discards to shared blocks. It is 
an upstream bug, so it should be sent upstream now (preferably before 3.5 
comes out).



dm-thin: don't send discards to shared blocks

When process_discard receives a partial discard that doesn't cover full
block, it sends this discard down to that block. Unfortunatelly, the
block can be shared and the discard would corrupt the other snapshots
sharing this block.

This patch detects block sharing and ends the discard with sucess when
sending it to the shared block.

The above change causes that if the device supports discard it can't be
guaranteed that a discard request zeroes data. Therefore, we set

Signed-off-by: Mikulas Patocka <mpatocka redhat com>
Cc: stable kernel org

 drivers/md/dm-thin.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Index: linux-3.5-rc6-fast/drivers/md/dm-thin.c
--- linux-3.5-rc6-fast.orig/drivers/md/dm-thin.c	2012-07-16 21:47:46.000000000 +0200
+++ linux-3.5-rc6-fast/drivers/md/dm-thin.c	2012-07-17 00:35:25.000000000 +0200
@@ -1259,7 +1259,10 @@ static void process_discard(struct thin_
 			cell_release_singleton(cell, bio);
 			cell_release_singleton(cell2, bio);
-			remap_and_issue(tc, bio, lookup_result.block);
+			if ((!lookup_result.shared) & pool->pf.discard_passdown)
+				remap_and_issue(tc, bio, lookup_result.block);
+			else
+				bio_endio(bio, 0);
@@ -2648,6 +2651,7 @@ static int thin_ctr(struct dm_target *ti
 	if (tc->pool->pf.discard_enabled) {
 		ti->discards_supported = 1;
 		ti->num_discard_requests = 1;
+		ti->discard_zeroes_data_unsupported = 1;

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]