diff options
author | Mikulas Patocka <mpatocka@redhat.com> | 2010-08-12 04:14:14 +0100 |
---|---|---|
committer | Alasdair G Kergon <agk@redhat.com> | 2010-08-12 04:14:14 +0100 |
commit | 65988525abde0b0a5833c4e20f32967184a5dcf0 (patch) | |
tree | 27e8908099d9dbd1473e6b69775fcba23827d2a1 /drivers/md/dm-stripe.c | |
parent | 38e1b257fd7b4f3eee667d29a5e44ec15e253c1c (diff) | |
download | linux-3.10-65988525abde0b0a5833c4e20f32967184a5dcf0.tar.gz linux-3.10-65988525abde0b0a5833c4e20f32967184a5dcf0.tar.bz2 linux-3.10-65988525abde0b0a5833c4e20f32967184a5dcf0.zip |
dm stripe: move sector translation to a function
Move sector to stripe translation into a function.
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
Diffstat (limited to 'drivers/md/dm-stripe.c')
-rw-r--r-- | drivers/md/dm-stripe.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c index 779f47a0fe7..e2ad1ae5268 100644 --- a/drivers/md/dm-stripe.c +++ b/drivers/md/dm-stripe.c @@ -207,11 +207,20 @@ static void stripe_dtr(struct dm_target *ti) 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; + struct stripe_c *sc = ti->private; uint32_t stripe; unsigned target_request_nr; @@ -222,13 +231,11 @@ static int stripe_map(struct dm_target *ti, struct bio *bio, 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; } |