Commit d41e077a authored by Mike Snitzer's avatar Mike Snitzer

dm: refactor dm_split_and_process_bio a bit

Remove needless branching and indentation. Leaves code to catch
malformed op_is_zone_mgmt bios (they shouldn't have a payload).
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarMikulas Patocka <mpatocka@redhat.com>
Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
parent 66bdaa43
...@@ -1394,7 +1394,13 @@ static void init_clone_info(struct clone_info *ci, struct mapped_device *md, ...@@ -1394,7 +1394,13 @@ static void init_clone_info(struct clone_info *ci, struct mapped_device *md,
{ {
ci->map = map; ci->map = map;
ci->io = alloc_io(md, bio); ci->io = alloc_io(md, bio);
ci->bio = bio;
ci->sector = bio->bi_iter.bi_sector; ci->sector = bio->bi_iter.bi_sector;
ci->sector_count = bio_sectors(bio);
/* Shouldn't happen but sector_count was being set to 0 so... */
if (WARN_ON_ONCE(op_is_zone_mgmt(bio_op(bio)) && ci->sector_count))
ci->sector_count = 0;
} }
/* /*
...@@ -1404,6 +1410,7 @@ static void dm_split_and_process_bio(struct mapped_device *md, ...@@ -1404,6 +1410,7 @@ static void dm_split_and_process_bio(struct mapped_device *md,
struct dm_table *map, struct bio *bio) struct dm_table *map, struct bio *bio)
{ {
struct clone_info ci; struct clone_info ci;
struct bio *b;
int error = 0; int error = 0;
init_clone_info(&ci, md, map, bio); init_clone_info(&ci, md, map, bio);
...@@ -1411,34 +1418,29 @@ static void dm_split_and_process_bio(struct mapped_device *md, ...@@ -1411,34 +1418,29 @@ static void dm_split_and_process_bio(struct mapped_device *md,
if (bio->bi_opf & REQ_PREFLUSH) { if (bio->bi_opf & REQ_PREFLUSH) {
error = __send_empty_flush(&ci); error = __send_empty_flush(&ci);
/* dm_io_dec_pending submits any data associated with flush */ /* dm_io_dec_pending submits any data associated with flush */
} else if (op_is_zone_mgmt(bio_op(bio))) { goto out;
ci.bio = bio; }
ci.sector_count = 0;
error = __split_and_process_bio(&ci);
} else {
ci.bio = bio;
ci.sector_count = bio_sectors(bio);
error = __split_and_process_bio(&ci); error = __split_and_process_bio(&ci);
if (ci.sector_count && !error) { if (error || !ci.sector_count)
goto out;
/* /*
* Remainder must be passed to submit_bio_noacct() * Remainder must be passed to submit_bio_noacct() so it gets handled
* so that it gets handled *after* bios already submitted * *after* bios already submitted have been completely processed.
* have been completely processed. * We take a clone of the original to store in ci.io->orig_bio to be
* We take a clone of the original to store in * used by dm_end_io_acct() and for dm_io_dec_pending() to use for
* ci.io->orig_bio to be used by dm_end_io_acct() and for * completion handling.
* dm_io_dec_pending() to use for completion handling. */
*/ b = bio_split(bio, bio_sectors(bio) - ci.sector_count,
struct bio *b = bio_split(bio, bio_sectors(bio) - ci.sector_count,
GFP_NOIO, &md->queue->bio_split); GFP_NOIO, &md->queue->bio_split);
ci.io->orig_bio = b; ci.io->orig_bio = b;
bio_chain(b, bio); bio_chain(b, bio);
trace_block_split(b, bio->bi_iter.bi_sector); trace_block_split(b, bio->bi_iter.bi_sector);
submit_bio_noacct(bio); submit_bio_noacct(bio);
} out:
}
dm_start_io_acct(ci.io); dm_start_io_acct(ci.io);
/* drop the extra reference count */ /* drop the extra reference count */
dm_io_dec_pending(ci.io, errno_to_blk_status(error)); dm_io_dec_pending(ci.io, errno_to_blk_status(error));
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment