diff options
author | Mike Snitzer <snitzer@redhat.com> | 2016-05-24 15:48:08 -0400 |
---|---|---|
committer | Mike Snitzer <snitzer@redhat.com> | 2016-06-10 15:15:48 -0400 |
commit | bf661be1fcf9b1da8abc81a56ff41ce5964ce896 (patch) | |
tree | 7bd9a0e995d9f5f7b9939d267544675b201d27a6 /drivers | |
parent | 76e33fe4e2c4363c2b9f627472bd43dc235c3406 (diff) |
dm mpath: remove bio-based bloat from struct dm_mpath_io
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Diffstat (limited to 'drivers')
-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 { struct dm_mpath_io { struct pgpath *pgpath; size_t nr_bytes; - - /* - * FIXME: make request-based code _not_ include this member. - */ - struct dm_bio_details bio_details; }; typedef int (*action_fn) (struct pgpath *pgpath); @@ -294,19 +289,39 @@ static void clear_request_fn_mpio(struct multipath *m, union map_info *info) } } +static size_t multipath_per_bio_data_size(void) +{ + return sizeof(struct dm_mpath_io) + sizeof(struct dm_bio_details); +} + static struct dm_mpath_io *get_mpio_from_bio(struct bio *bio) { - return dm_per_bio_data(bio, sizeof(struct dm_mpath_io)); + return dm_per_bio_data(bio, multipath_per_bio_data_size()); } -static struct dm_mpath_io *set_mpio_bio(struct multipath *m, struct bio *bio) +static struct dm_bio_details *get_bio_details_from_bio(struct bio *bio) { + /* dm_bio_details is immediately after the dm_mpath_io in bio's per-bio-data */ struct dm_mpath_io *mpio = get_mpio_from_bio(bio); + void *bio_details = mpio + 1; + + return bio_details; +} + +static void multipath_init_per_bio_data(struct bio *bio, struct dm_mpath_io **mpio_p, + struct dm_bio_details **bio_details_p) +{ + struct dm_mpath_io *mpio = get_mpio_from_bio(bio); + struct dm_bio_details *bio_details = get_bio_details_from_bio(bio); memset(mpio, 0, sizeof(*mpio)); - dm_bio_record(&mpio->bio_details, bio); + memset(bio_details, 0, sizeof(*bio_details)); + dm_bio_record(bio_details, bio); - return mpio; + if (mpio_p) + *mpio_p = mpio; + if (bio_details_p) + *bio_details_p = bio_details; } /*----------------------------------------------- @@ -629,7 +644,9 @@ static int __multipath_map_bio(struct multipath *m, struct bio *bio, struct dm_m static int multipath_map_bio(struct dm_target *ti, struct bio *bio) { struct multipath *m = ti->private; - struct dm_mpath_io *mpio = set_mpio_bio(m, bio); + struct dm_mpath_io *mpio = NULL; + + multipath_init_per_bio_data(bio, &mpio, NULL); return __multipath_map_bio(m, bio, mpio); } @@ -1113,7 +1130,9 @@ static int __multipath_ctr(struct dm_target *ti, unsigned int argc, ti->num_flush_bios = 1; ti->num_discard_bios = 1; ti->num_write_same_bios = 1; - if (use_blk_mq || bio_based) + if (bio_based) + ti->per_io_data_size = multipath_per_bio_data_size(); + else if (use_blk_mq) ti->per_io_data_size = sizeof(struct dm_mpath_io); return 0; @@ -1576,7 +1595,7 @@ static int do_end_io_bio(struct multipath *m, struct bio *clone, } /* Queue for the daemon to resubmit */ - dm_bio_restore(&mpio->bio_details, clone); + dm_bio_restore(get_bio_details_from_bio(clone), clone); spin_lock_irqsave(&m->lock, flags); bio_list_add(&m->queued_bios, clone); |