From: Mike Snitzer <[email-masked]>

Use dm_target_offset() and support discards.

Signed-off-by: Mike Snitzer <[email-masked]>
Signed-off-by: Alasdair G Kergon <[email-masked]>

---
 drivers/md/dm-flakey.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Index: linux-3.0/drivers/md/dm-flakey.c
===================================================================
--- linux-3.0.orig/drivers/md/dm-flakey.c
+++ linux-3.0/drivers/md/dm-flakey.c
@@ -79,6 +79,7 @@ static int flakey_ctr(struct dm_target *
 	}
 
 	ti->num_flush_requests = 1;
+	ti->num_discard_requests = 1;
 	ti->private = fc;
 	return 0;
 
@@ -99,7 +100,7 @@ static sector_t flakey_map_sector(struct
 {
 	struct flakey_c *fc = ti->private;
 
-	return fc->start + (bi_sector - ti->begin);
+	return fc->start + dm_target_offset(ti, bi_sector);
 }
 
 static void flakey_map_bio(struct dm_target *ti, struct bio *bio)