Skip to content

Commit b879f91

Browse files
snitmaxboe
authored andcommitted
dm: properly fix redundant bio-based IO accounting
Record the start_time for a bio but defer the starting block core's IO accounting until after IO is submitted using bio_start_io_acct_time(). This approach avoids the need to mess around with any of the individual IO stats in response to a bio_split() that follows bio submission. Reported-by: Bud Brown <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Cc: [email protected] Depends-on: e45c47d ("block: add bio_start_io_acct_time() to control start_time") Signed-off-by: Mike Snitzer <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent f524d9c commit b879f91

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

drivers/md/dm.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ static void start_io_acct(struct dm_io *io)
489489
struct mapped_device *md = io->md;
490490
struct bio *bio = io->orig_bio;
491491

492-
io->start_time = bio_start_io_acct(bio);
492+
bio_start_io_acct_time(bio, io->start_time);
493493
if (unlikely(dm_stats_used(&md->stats)))
494494
dm_stats_account_io(&md->stats, bio_data_dir(bio),
495495
bio->bi_iter.bi_sector, bio_sectors(bio),
@@ -535,7 +535,7 @@ static struct dm_io *alloc_io(struct mapped_device *md, struct bio *bio)
535535
io->md = md;
536536
spin_lock_init(&io->endio_lock);
537537

538-
start_io_acct(io);
538+
io->start_time = jiffies;
539539

540540
return io;
541541
}
@@ -1482,6 +1482,7 @@ static void __split_and_process_bio(struct mapped_device *md,
14821482
submit_bio_noacct(bio);
14831483
}
14841484
}
1485+
start_io_acct(ci.io);
14851486

14861487
/* drop the extra reference count */
14871488
dm_io_dec_pending(ci.io, errno_to_blk_status(error));

0 commit comments

Comments
 (0)