diff options
author | Mikulas Patocka <mpatocka@redhat.com> | 2010-08-11 23:14:14 -0400 |
---|---|---|
committer | Alasdair G Kergon <agk@redhat.com> | 2010-08-11 23:14:14 -0400 |
commit | 65988525abde0b0a5833c4e20f32967184a5dcf0 (patch) | |
tree | 27e8908099d9dbd1473e6b69775fcba23827d2a1 | |
parent | 38e1b257fd7b4f3eee667d29a5e44ec15e253c1c (diff) |
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>
-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 779f47a0fe71..e2ad1ae5268d 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) | |||
207 | kfree(sc); | 207 | kfree(sc); |
208 | } | 208 | } |
209 | 209 | ||
210 | static void stripe_map_sector(struct stripe_c *sc, sector_t sector, | ||
211 | uint32_t *stripe, sector_t *result) | ||
212 | { | ||
213 | sector_t offset = dm_target_offset(sc->ti, sector); | ||
214 | sector_t chunk = offset >> sc->chunk_shift; | ||
215 | |||
216 | *stripe = sector_div(chunk, sc->stripes); | ||
217 | *result = (chunk << sc->chunk_shift) | (offset & sc->chunk_mask); | ||
218 | } | ||
219 | |||
210 | static int stripe_map(struct dm_target *ti, struct bio *bio, | 220 | static int stripe_map(struct dm_target *ti, struct bio *bio, |
211 | union map_info *map_context) | 221 | union map_info *map_context) |
212 | { | 222 | { |
213 | struct stripe_c *sc = (struct stripe_c *) ti->private; | 223 | struct stripe_c *sc = ti->private; |
214 | sector_t offset, chunk; | ||
215 | uint32_t stripe; | 224 | uint32_t stripe; |
216 | unsigned target_request_nr; | 225 | unsigned target_request_nr; |
217 | 226 | ||
@@ -222,13 +231,11 @@ static int stripe_map(struct dm_target *ti, struct bio *bio, | |||
222 | return DM_MAPIO_REMAPPED; | 231 | return DM_MAPIO_REMAPPED; |
223 | } | 232 | } |
224 | 233 | ||
225 | offset = dm_target_offset(ti, bio->bi_sector); | 234 | stripe_map_sector(sc, bio->bi_sector, &stripe, &bio->bi_sector); |
226 | chunk = offset >> sc->chunk_shift; | ||
227 | stripe = sector_div(chunk, sc->stripes); | ||
228 | 235 | ||
236 | bio->bi_sector += sc->stripe[stripe].physical_start; | ||
229 | bio->bi_bdev = sc->stripe[stripe].dev->bdev; | 237 | bio->bi_bdev = sc->stripe[stripe].dev->bdev; |
230 | bio->bi_sector = sc->stripe[stripe].physical_start + | 238 | |
231 | (chunk << sc->chunk_shift) + (offset & sc->chunk_mask); | ||
232 | return DM_MAPIO_REMAPPED; | 239 | return DM_MAPIO_REMAPPED; |
233 | } | 240 | } |
234 | 241 | ||