1

md: don't account sync_io if iostats of the disk is disabled

If iostats is disabled, disk_stats will not be updated and
part_stat_read_accum() only returns a constant value. In this case,
continuing to count sync_io and to check is_mddev_idle() is no longer
meaningful.

Signed-off-by: Li Nan <linan122@huawei.com>
Reviewed-by: Yu Kuai <yukuai3@huawei.com>
Link: https://lore.kernel.org/r/20240117031946.2324519-3-linan666@huaweicloud.com
Signed-off-by: Song Liu <song@kernel.org>
This commit is contained in:
Li Nan 2024-01-17 11:19:46 +08:00 committed by Song Liu
parent 3f9f231236
commit 9d1110f99c
2 changed files with 6 additions and 1 deletions

View File

@ -8583,6 +8583,10 @@ static int is_mddev_idle(struct mddev *mddev, int init)
rcu_read_lock();
rdev_for_each_rcu(rdev, mddev) {
struct gendisk *disk = rdev->bdev->bd_disk;
if (!init && !blk_queue_io_stat(disk->queue))
continue;
curr_events =
(long long)part_stat_read_accum(disk->part0, sectors) -
atomic64_read(&disk->sync_io);

View File

@ -621,7 +621,8 @@ extern void mddev_unlock(struct mddev *mddev);
static inline void md_sync_acct(struct block_device *bdev, unsigned long nr_sectors)
{
atomic64_add(nr_sectors, &bdev->bd_disk->sync_io);
if (blk_queue_io_stat(bdev->bd_disk->queue))
atomic64_add(nr_sectors, &bdev->bd_disk->sync_io);
}
static inline void md_sync_acct_bio(struct bio *bio, unsigned long nr_sectors)