FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Redhat > Device-mapper Development

 
 
LinkBack Thread Tools
 
Old 04-28-2011, 12:19 AM
Mike Snitzer
 
Default dm snapshot: ignore discards issued to the snapshot-origin target

Discards pose a problem for the snapshot-origin target because they are
treated as writes. Treating a discard as a write would trigger a
copyout to the snapshot. Such copyout can prove too costly in the face
of otherwise benign scenarios (e.g. create a snapshot and then mkfs.ext4
the origin -- mkfs.ext4 discards the entire volume by default, which
would copyout the entire origin volume to the snapshot).

Signed-off-by: Mike Snitzer <snitzer@redhat.com>
---
drivers/md/dm-snap.c | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c
index a2d3309..639af12 100644
--- a/drivers/md/dm-snap.c
+++ b/drivers/md/dm-snap.c
@@ -2076,6 +2076,7 @@ static int origin_ctr(struct dm_target *ti, unsigned int argc, char **argv)

ti->private = dev;
ti->num_flush_requests = 1;
+ ti->num_discard_requests = 1;

return 0;
}
@@ -2095,6 +2096,12 @@ static int origin_map(struct dm_target *ti, struct bio *bio,
if (bio->bi_rw & REQ_FLUSH)
return DM_MAPIO_REMAPPED;

+ if (bio->bi_rw & REQ_DISCARD) {
+ /* ignore discard requests */
+ bio_endio(bio, 0);
+ return DM_MAPIO_SUBMITTED;
+ }
+
/* Only tell snapshots if this is a write */
return (bio_rw(bio) == WRITE) ? do_origin(dev, bio) : DM_MAPIO_REMAPPED;
}
@@ -2153,7 +2160,7 @@ static int origin_iterate_devices(struct dm_target *ti,

static struct target_type origin_target = {
.name = "snapshot-origin",
- .version = {1, 7, 1},
+ .version = {1, 8, 0},
.module = THIS_MODULE,
.ctr = origin_ctr,
.dtr = origin_dtr,
--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel
 
Old 04-28-2011, 07:53 AM
Christoph Hellwig
 
Default dm snapshot: ignore discards issued to the snapshot-origin target

On Wed, Apr 27, 2011 at 08:19:13PM -0400, Mike Snitzer wrote:
> Discards pose a problem for the snapshot-origin target because they are
> treated as writes. Treating a discard as a write would trigger a
> copyout to the snapshot. Such copyout can prove too costly in the face
> of otherwise benign scenarios (e.g. create a snapshot and then mkfs.ext4
> the origin -- mkfs.ext4 discards the entire volume by default, which
> would copyout the entire origin volume to the snapshot).

You also need to make sure that we don't claim discard_zeroes_data for
the origin volume in this case. Especially as ext4 started to rely
on this actually working (very bad idea IMHO, but that's another story)

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

Thread Tools




All times are GMT. The time now is 07:49 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org