aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/md/dm-stripe.c21
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
210static 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
210static int stripe_map(struct dm_target *ti, struct bio *bio, 220static 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