dm-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] dm-stripe: move sector translation to a function
@ 2010-07-27 21:38 Mikulas Patocka
  2010-07-27 21:42 ` [PATCH 2/2] dm-stripe: discard support Mikulas Patocka
  2010-07-28 17:09 ` [PATCH 1/2 v2] dm stripe: move sector translation to a function Mike Snitzer
  0 siblings, 2 replies; 11+ messages in thread
From: Mikulas Patocka @ 2010-07-27 21:38 UTC (permalink / raw)
  To: dm-devel; +Cc: Mike Snitzer, Alasdair G Kergon

Abstract sector translation in dm-stripe

Abstract sector -> stripe, sector translation to a function.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>

---
 drivers/md/dm-stripe.c |   18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

Index: linux-2.6.35-rc6-fast/drivers/md/dm-stripe.c
===================================================================
--- linux-2.6.35-rc6-fast.orig/drivers/md/dm-stripe.c	2010-07-27 22:43:40.000000000 +0200
+++ linux-2.6.35-rc6-fast/drivers/md/dm-stripe.c	2010-07-27 23:08:28.000000000 +0200
@@ -207,11 +207,19 @@ static void stripe_dtr(struct dm_target 
 	kfree(sc);
 }
 
+static void stripe_map_sector(struct stripe_c *sc, sector_t sector,
+			      uint32_t *stripe, sector_t *result)
+{
+	sector_t offset = sector - sc->ti->begin;
+	sector_t chunk = offset >> sc->chunk_shift;
+	*stripe = sector_div(chunk, sc->stripes);
+	*result = (chunk << sc->chunk_shift) | (offset & sc->chunk_mask);
+}
+
 static int stripe_map(struct dm_target *ti, struct bio *bio,
 		      union map_info *map_context)
 {
 	struct stripe_c *sc = (struct stripe_c *) ti->private;
-	sector_t offset, chunk;
 	uint32_t stripe;
 
 	if (unlikely(bio_empty_barrier(bio))) {
@@ -220,13 +228,11 @@ static int stripe_map(struct dm_target *
 		return DM_MAPIO_REMAPPED;
 	}
 
-	offset = bio->bi_sector - ti->begin;
-	chunk = offset >> sc->chunk_shift;
-	stripe = sector_div(chunk, sc->stripes);
+	stripe_map_sector(sc, bio->bi_sector, &stripe, &bio->bi_sector);
 
+	bio->bi_sector += sc->stripe[stripe].physical_start;
 	bio->bi_bdev = sc->stripe[stripe].dev->bdev;
-	bio->bi_sector = sc->stripe[stripe].physical_start +
-	    (chunk << sc->chunk_shift) + (offset & sc->chunk_mask);
+
 	return DM_MAPIO_REMAPPED;
 }
 

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2010-07-28 17:09 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-27 21:38 [PATCH 1/2] dm-stripe: move sector translation to a function Mikulas Patocka
2010-07-27 21:42 ` [PATCH 2/2] dm-stripe: discard support Mikulas Patocka
2010-07-27 22:12   ` [PATCH 1.5/2] dm-stripe: optimize sector division Mikulas Patocka
2010-07-27 23:10     ` Mike Snitzer
2010-07-28 13:53     ` Mike Snitzer
2010-07-28 14:43       ` Mikulas Patocka
2010-07-28 15:21         ` [PATCH 1.5/2 v2] dm stripe: " Mike Snitzer
2010-07-27 22:39   ` [PATCH 2/2] dm-stripe: discard support Mike Snitzer
2010-07-28  0:03   ` [PATCH 2/2 v2] dm stripe: enable " Mike Snitzer
2010-07-28  0:06     ` Mike Snitzer
2010-07-28 17:09 ` [PATCH 1/2 v2] dm stripe: move sector translation to a function Mike Snitzer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).