diff options
Diffstat (limited to 'drivers/md/dm-mpath.c')
-rw-r--r-- | drivers/md/dm-mpath.c | 43 |
1 files changed, 31 insertions, 12 deletions
diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c index f5921661bd99..2d10ff780d84 100644 --- a/drivers/md/dm-mpath.c +++ b/drivers/md/dm-mpath.c | |||
@@ -109,11 +109,6 @@ struct multipath { | |||
109 | struct dm_mpath_io { | 109 | struct dm_mpath_io { |
110 | struct pgpath *pgpath; | 110 | struct pgpath *pgpath; |
111 | size_t nr_bytes; | 111 | size_t nr_bytes; |
112 | |||
113 | /* | ||
114 | * FIXME: make request-based code _not_ include this member. | ||
115 | */ | ||
116 | struct dm_bio_details bio_details; | ||
117 | }; | 112 | }; |
118 | 113 | ||
119 | typedef int (*action_fn) (struct pgpath *pgpath); | 114 | typedef int (*action_fn) (struct pgpath *pgpath); |
@@ -294,19 +289,39 @@ static void clear_request_fn_mpio(struct multipath *m, union map_info *info) | |||
294 | } | 289 | } |
295 | } | 290 | } |
296 | 291 | ||
292 | static size_t multipath_per_bio_data_size(void) | ||
293 | { | ||
294 | return sizeof(struct dm_mpath_io) + sizeof(struct dm_bio_details); | ||
295 | } | ||
296 | |||
297 | static struct dm_mpath_io *get_mpio_from_bio(struct bio *bio) | 297 | static struct dm_mpath_io *get_mpio_from_bio(struct bio *bio) |
298 | { | 298 | { |
299 | return dm_per_bio_data(bio, sizeof(struct dm_mpath_io)); | 299 | return dm_per_bio_data(bio, multipath_per_bio_data_size()); |
300 | } | 300 | } |
301 | 301 | ||
302 | static struct dm_mpath_io *set_mpio_bio(struct multipath *m, struct bio *bio) | 302 | static struct dm_bio_details *get_bio_details_from_bio(struct bio *bio) |
303 | { | 303 | { |
304 | /* dm_bio_details is immediately after the dm_mpath_io in bio's per-bio-data */ | ||
304 | struct dm_mpath_io *mpio = get_mpio_from_bio(bio); | 305 | struct dm_mpath_io *mpio = get_mpio_from_bio(bio); |
306 | void *bio_details = mpio + 1; | ||
307 | |||
308 | return bio_details; | ||
309 | } | ||
310 | |||
311 | static void multipath_init_per_bio_data(struct bio *bio, struct dm_mpath_io **mpio_p, | ||
312 | struct dm_bio_details **bio_details_p) | ||
313 | { | ||
314 | struct dm_mpath_io *mpio = get_mpio_from_bio(bio); | ||
315 | struct dm_bio_details *bio_details = get_bio_details_from_bio(bio); | ||
305 | 316 | ||
306 | memset(mpio, 0, sizeof(*mpio)); | 317 | memset(mpio, 0, sizeof(*mpio)); |
307 | dm_bio_record(&mpio->bio_details, bio); | 318 | memset(bio_details, 0, sizeof(*bio_details)); |
319 | dm_bio_record(bio_details, bio); | ||
308 | 320 | ||
309 | return mpio; | 321 | if (mpio_p) |
322 | *mpio_p = mpio; | ||
323 | if (bio_details_p) | ||
324 | *bio_details_p = bio_details; | ||
310 | } | 325 | } |
311 | 326 | ||
312 | /*----------------------------------------------- | 327 | /*----------------------------------------------- |
@@ -629,7 +644,9 @@ static int __multipath_map_bio(struct multipath *m, struct bio *bio, struct dm_m | |||
629 | static int multipath_map_bio(struct dm_target *ti, struct bio *bio) | 644 | static int multipath_map_bio(struct dm_target *ti, struct bio *bio) |
630 | { | 645 | { |
631 | struct multipath *m = ti->private; | 646 | struct multipath *m = ti->private; |
632 | struct dm_mpath_io *mpio = set_mpio_bio(m, bio); | 647 | struct dm_mpath_io *mpio = NULL; |
648 | |||
649 | multipath_init_per_bio_data(bio, &mpio, NULL); | ||
633 | 650 | ||
634 | return __multipath_map_bio(m, bio, mpio); | 651 | return __multipath_map_bio(m, bio, mpio); |
635 | } | 652 | } |
@@ -1113,7 +1130,9 @@ static int __multipath_ctr(struct dm_target *ti, unsigned int argc, | |||
1113 | ti->num_flush_bios = 1; | 1130 | ti->num_flush_bios = 1; |
1114 | ti->num_discard_bios = 1; | 1131 | ti->num_discard_bios = 1; |
1115 | ti->num_write_same_bios = 1; | 1132 | ti->num_write_same_bios = 1; |
1116 | if (use_blk_mq || bio_based) | 1133 | if (bio_based) |
1134 | ti->per_io_data_size = multipath_per_bio_data_size(); | ||
1135 | else if (use_blk_mq) | ||
1117 | ti->per_io_data_size = sizeof(struct dm_mpath_io); | 1136 | ti->per_io_data_size = sizeof(struct dm_mpath_io); |
1118 | 1137 | ||
1119 | return 0; | 1138 | return 0; |
@@ -1576,7 +1595,7 @@ static int do_end_io_bio(struct multipath *m, struct bio *clone, | |||
1576 | } | 1595 | } |
1577 | 1596 | ||
1578 | /* Queue for the daemon to resubmit */ | 1597 | /* Queue for the daemon to resubmit */ |
1579 | dm_bio_restore(&mpio->bio_details, clone); | 1598 | dm_bio_restore(get_bio_details_from_bio(clone), clone); |
1580 | 1599 | ||
1581 | spin_lock_irqsave(&m->lock, flags); | 1600 | spin_lock_irqsave(&m->lock, flags); |
1582 | bio_list_add(&m->queued_bios, clone); | 1601 | bio_list_add(&m->queued_bios, clone); |