Skip to content

Commit d3de6d1

Browse files
Ming LeiMike Snitzer
authored andcommitted
dm: switch to bdev based IO accounting interfaces
DM splits flush with data into empty flush followed by bio with data payload, switch dm_io_acct() to use bdev_{start,end}_io_acct() to do this accoiunting more naturally (rather than temporarily changing the bio's bi_size). This will allow DM to more easily account bios that are split (in following commit). Signed-off-by: Ming Lei <[email protected]> Signed-off-by: Mike Snitzer <[email protected]>
1 parent e6926ad commit d3de6d1

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

drivers/md/dm.c

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -508,30 +508,28 @@ static void dm_io_acct(struct dm_io *io, bool end)
508508
unsigned long start_time = io->start_time;
509509
struct mapped_device *md = io->md;
510510
struct bio *bio = io->orig_bio;
511-
bool is_flush_with_data;
512-
unsigned int bi_size;
511+
unsigned int sectors;
513512

514-
/* If REQ_PREFLUSH set save any payload but do not account it */
515-
is_flush_with_data = bio_is_flush_with_data(bio);
516-
if (is_flush_with_data) {
517-
bi_size = bio->bi_iter.bi_size;
518-
bio->bi_iter.bi_size = 0;
519-
}
513+
/*
514+
* If REQ_PREFLUSH set, don't account payload, it will be
515+
* submitted (and accounted) after this flush completes.
516+
*/
517+
if (bio_is_flush_with_data(bio))
518+
sectors = 0;
519+
else
520+
sectors = bio_sectors(bio);
520521

521522
if (!end)
522-
bio_start_io_acct_time(bio, start_time);
523+
bdev_start_io_acct(bio->bi_bdev, sectors, bio_op(bio),
524+
start_time);
523525
else
524-
bio_end_io_acct(bio, start_time);
526+
bdev_end_io_acct(bio->bi_bdev, bio_op(bio), start_time);
525527

526528
if (static_branch_unlikely(&stats_enabled) &&
527529
unlikely(dm_stats_used(&md->stats)))
528530
dm_stats_account_io(&md->stats, bio_data_dir(bio),
529-
bio->bi_iter.bi_sector, bio_sectors(bio),
531+
bio->bi_iter.bi_sector, sectors,
530532
end, start_time, stats_aux);
531-
532-
/* Restore bio's payload so it does get accounted upon requeue */
533-
if (is_flush_with_data)
534-
bio->bi_iter.bi_size = bi_size;
535533
}
536534

537535
static void __dm_start_io_acct(struct dm_io *io)

0 commit comments

Comments
 (0)