Message ID | 20220210223832.99412-8-snitzer@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | dm: improve bio-based IO accounting | expand |
> static void alloc_multiple_bios(struct bio_list *blist, struct clone_info *ci, > struct dm_target *ti, unsigned num_bios, > unsigned *len) > @@ -1224,14 +1218,14 @@ static void __send_duplicate_bios(struct clone_info *ci, struct dm_target *ti, > case 1: > clone = alloc_tio(ci, ti, 0, len, GFP_NOIO); > if (len) > - bio_setup_sector(clone, ci->sector, *len); > + clone->bi_iter.bi_size = to_bytes(*len); > __map_bio(clone); > break; > default: > alloc_multiple_bios(&blist, ci, ti, num_bios, len); > while ((clone = bio_list_pop(&blist))) { > if (len) > - bio_setup_sector(clone, ci->sector, *len); > + clone->bi_iter.bi_size = to_bytes(*len); > __map_bio(clone); > } > break; > @@ -1350,7 +1344,6 @@ static int __split_and_process_bio(struct clone_info *ci) > len = min_t(sector_t, max_io_len(ti, ci->sector), ci->sector_count); > > clone = alloc_tio(ci, ti, 0, &len, GFP_NOIO); > - bio_advance(clone, to_bytes(ci->sector - clone->bi_iter.bi_sector)); > clone->bi_iter.bi_size = to_bytes(len); Maybe move the clone->bi_iter.bi_size assignment into alloc_tio as well? Otherwise looks good: Reviewed-by: Christoph Hellwig <hch@lst.de>
diff --git a/drivers/md/dm.c b/drivers/md/dm.c index f091bbf8a8dc..5950d518e544 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -1176,12 +1176,6 @@ static void __map_bio(struct bio *clone) } } -static void bio_setup_sector(struct bio *bio, sector_t sector, unsigned len) -{ - bio->bi_iter.bi_sector = sector; - bio->bi_iter.bi_size = to_bytes(len); -} - static void alloc_multiple_bios(struct bio_list *blist, struct clone_info *ci, struct dm_target *ti, unsigned num_bios, unsigned *len) @@ -1224,14 +1218,14 @@ static void __send_duplicate_bios(struct clone_info *ci, struct dm_target *ti, case 1: clone = alloc_tio(ci, ti, 0, len, GFP_NOIO); if (len) - bio_setup_sector(clone, ci->sector, *len); + clone->bi_iter.bi_size = to_bytes(*len); __map_bio(clone); break; default: alloc_multiple_bios(&blist, ci, ti, num_bios, len); while ((clone = bio_list_pop(&blist))) { if (len) - bio_setup_sector(clone, ci->sector, *len); + clone->bi_iter.bi_size = to_bytes(*len); __map_bio(clone); } break; @@ -1350,7 +1344,6 @@ static int __split_and_process_bio(struct clone_info *ci) len = min_t(sector_t, max_io_len(ti, ci->sector), ci->sector_count); clone = alloc_tio(ci, ti, 0, &len, GFP_NOIO); - bio_advance(clone, to_bytes(ci->sector - clone->bi_iter.bi_sector)); clone->bi_iter.bi_size = to_bytes(len); if (bio_integrity(clone)) bio_integrity_trim(clone);
Commit 8615cb65bd63 ("dm: remove useless loop in __split_and_process_bio") showcased that we no longer loop. Remove the bio_advance() in __split_and_process_bio() that was only needed when looping was possible. Similarly there is no need to advance the bio, using ci->sector cursor, in __send_duplicate_bios(). Signed-off-by: Mike Snitzer <snitzer@redhat.com> --- drivers/md/dm.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-)