summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLi Nan <linan122@huawei.com>2024-01-17 11:19:46 +0800
committerSong Liu <song@kernel.org>2024-04-08 21:15:46 -0700
commit9d1110f99c253ccef82e480bfe9f38a12eb797a7 (patch)
tree0d9dc93d6676c34e0b609a625aa81a4b0317781b
parent3f9f231236ce7e48780d8a4f1f8cb9fae2df1e4e (diff)
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>
-rw-r--r--drivers/md/md.c4
-rw-r--r--drivers/md/md.h3
2 files changed, 6 insertions, 1 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c
index f28e41f9ac4a..00bbafcd27bb 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -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);
diff --git a/drivers/md/md.h b/drivers/md/md.h
index d0db98c0d33b..029dd0491a36 100644
--- a/drivers/md/md.h
+++ b/drivers/md/md.h
@@ -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)