Skip to content

Commit 9d1110f

Browse files
Li Nanliu-song-6
authored andcommitted
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 <[email protected]> Reviewed-by: Yu Kuai <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Song Liu <[email protected]>
1 parent 3f9f231 commit 9d1110f

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

drivers/md/md.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8583,6 +8583,10 @@ static int is_mddev_idle(struct mddev *mddev, int init)
85838583
rcu_read_lock();
85848584
rdev_for_each_rcu(rdev, mddev) {
85858585
struct gendisk *disk = rdev->bdev->bd_disk;
8586+
8587+
if (!init && !blk_queue_io_stat(disk->queue))
8588+
continue;
8589+
85868590
curr_events =
85878591
(long long)part_stat_read_accum(disk->part0, sectors) -
85888592
atomic64_read(&disk->sync_io);

drivers/md/md.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,8 @@ extern void mddev_unlock(struct mddev *mddev);
621621

622622
static inline void md_sync_acct(struct block_device *bdev, unsigned long nr_sectors)
623623
{
624-
atomic64_add(nr_sectors, &bdev->bd_disk->sync_io);
624+
if (blk_queue_io_stat(bdev->bd_disk->queue))
625+
atomic64_add(nr_sectors, &bdev->bd_disk->sync_io);
625626
}
626627

627628
static inline void md_sync_acct_bio(struct bio *bio, unsigned long nr_sectors)

0 commit comments

Comments
 (0)