[prev in list] [next in list] [prev in thread] [next in thread]
List: dm-devel
Subject: [dm-devel] [PATCH 1/2 v2] dm stripe: move sector translation to a
From: Mike Snitzer <snitzer () redhat ! com>
Date: 2010-07-28 17:09:10
Message-ID: 20100728170909.GA9036 () redhat ! com
[Download RAW message or body]
From: Mikulas Patocka <mpatocka@redhat.com>
Abstract sector -> stripe translation to a function.
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
---
drivers/md/dm-stripe.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
v2: fix conflict with newly staged dm_target_offset changes
Index: linux-2.6/drivers/md/dm-stripe.c
===================================================================
--- linux-2.6.orig/drivers/md/dm-stripe.c
+++ linux-2.6/drivers/md/dm-stripe.c
@@ -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 = dm_target_offset(sc->ti, sector);
+ 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;
unsigned target_request_nr;
@@ -222,13 +230,11 @@ static int stripe_map(struct dm_target *
return DM_MAPIO_REMAPPED;
}
- offset = dm_target_offset(ti, bio->bi_sector);
- 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;
}
--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic