diff options
author | Li Nan <linan122@huawei.com> | 2023-06-13 04:33:32 +0300 |
---|---|---|
committer | Mike Snitzer <snitzer@kernel.org> | 2023-06-17 01:24:13 +0300 |
commit | 526d10061bc29b314cc41f3b8322606df9172f14 (patch) | |
tree | 7a2478c5e856ea145f8f86113aaed4bc8293c385 | |
parent | e118029cb7605a89bf334a83023fc0c102420954 (diff) | |
download | linux-526d10061bc29b314cc41f3b8322606df9172f14.tar.xz |
dm: support turning off block-core's io stats accounting
Commit bc58ba9468d9 ("block: add sysfs file for controlling io stats
accounting") allowed users to turn off disk stat accounting completely
by checking if queue flag QUEUE_FLAG_IO_STAT is set. In dm, this flag
is neither set nor checked: so block-core's io stats are continuously
counted and cannot be turned off.
Add support for turning off block-core's io stats accounting for dm.
Set QUEUE_FLAG_IO_STAT for dm's request_queue. If QUEUE_FLAG_IO_STAT
is set when an io starts, record the need for block core's io stats by
setting the DM_IO_BLK_STAT dm_io flag to avoid io stats being disabled
in the middle of the io.
DM statistics (dm-stats) is independent of block-core's io stats and
remains unchanged.
Signed-off-by: Li Nan <linan122@huawei.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
-rw-r--r-- | drivers/md/dm-core.h | 3 | ||||
-rw-r--r-- | drivers/md/dm.c | 16 |
2 files changed, 13 insertions, 6 deletions
diff --git a/drivers/md/dm-core.h b/drivers/md/dm-core.h index ce913ad91a52..0d93661f88d3 100644 --- a/drivers/md/dm-core.h +++ b/drivers/md/dm-core.h @@ -306,7 +306,8 @@ struct dm_io { */ enum { DM_IO_ACCOUNTED, - DM_IO_WAS_SPLIT + DM_IO_WAS_SPLIT, + DM_IO_BLK_STAT }; static inline bool dm_io_flagged(struct dm_io *io, unsigned int bit) diff --git a/drivers/md/dm.c b/drivers/md/dm.c index ca2dc079c3f4..c8b3d686dc18 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -511,11 +511,14 @@ static void dm_io_acct(struct dm_io *io, bool end) else sectors = io->sectors; - if (!end) - bdev_start_io_acct(bio->bi_bdev, bio_op(bio), start_time); - else - bdev_end_io_acct(bio->bi_bdev, bio_op(bio), sectors, - start_time); + if (dm_io_flagged(io, DM_IO_BLK_STAT)) { + if (!end) + bdev_start_io_acct(bio->bi_bdev, bio_op(bio), + start_time); + else + bdev_end_io_acct(bio->bi_bdev, bio_op(bio), + sectors, start_time); + } if (static_branch_unlikely(&stats_enabled) && unlikely(dm_stats_used(&md->stats))) { @@ -592,6 +595,8 @@ static struct dm_io *alloc_io(struct mapped_device *md, struct bio *bio) spin_lock_init(&io->lock); io->start_time = jiffies; io->flags = 0; + if (blk_queue_io_stat(md->queue)) + dm_io_set_flag(io, DM_IO_BLK_STAT); if (static_branch_unlikely(&stats_enabled)) dm_stats_record_start(&md->stats, &io->stats_aux); @@ -2341,6 +2346,7 @@ int dm_setup_md_queue(struct mapped_device *md, struct dm_table *t) break; case DM_TYPE_BIO_BASED: case DM_TYPE_DAX_BIO_BASED: + blk_queue_flag_set(QUEUE_FLAG_IO_STAT, md->queue); break; case DM_TYPE_NONE: WARN_ON_ONCE(true); |