Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   Device-mapper Development (http://www.linux-archive.org/device-mapper-development/)
-   -   dm-thin: don't send discards to shared blocks (http://www.linux-archive.org/device-mapper-development/684337-dm-thin-dont-send-discards-shared-blocks.html)

Mikulas Patocka 07-16-2012 10:39 PM

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

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).

Mikulas

---

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
ti->discard_zeroes_data_unsupported.

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);
}
break;

@@ -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;
}

dm_put(pool_md);

--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel

Joe Thornber 07-18-2012 12:15 PM

dm-thin: don't send discards to shared blocks
 
Ack, but ...

On Mon, Jul 16, 2012 at 06:39:33PM -0400, Mikulas Patocka wrote:
> --- 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)

... I'd rather a logical && there.

- Joe

--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel


All times are GMT. The time now is 10:53 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.