From patchwork Mon Dec 11 07:56:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Li Nan X-Patchwork-Id: 13486759 Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07601CE; Sun, 10 Dec 2023 23:57:41 -0800 (PST) Received: from mail.maildlp.com (unknown [172.19.163.216]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4SpYxs0PPxz4f3jHf; Mon, 11 Dec 2023 15:57:37 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 3AFC21A0AF2; Mon, 11 Dec 2023 15:57:38 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgCnqxHwwHZlw69ZDQ--.3210S6; Mon, 11 Dec 2023 15:57:38 +0800 (CST) From: linan666@huaweicloud.com To: song@kernel.org, axboe@kernel.dk Cc: linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linan666@huaweicloud.com, yukuai3@huawei.com, yi.zhang@huawei.com, houtao1@huawei.com, yangerkun@huawei.com Subject: [PATCH 2/2] md: don't account sync_io if iostats of the disk is disabled Date: Mon, 11 Dec 2023 15:56:14 +0800 Message-Id: <20231211075614.1850003-3-linan666@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231211075614.1850003-1-linan666@huaweicloud.com> References: <20231211075614.1850003-1-linan666@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-CM-TRANSID: cCh0CgCnqxHwwHZlw69ZDQ--.3210S6 X-Coremail-Antispam: 1UD129KBjvJXoW7KFWxKF4kKr1xuF15XryDAwb_yoW8GFWrpF W8JFyayryjqw45ua4UZ34Dua4rG3srK39rArW7A393ZFy3JrnxGrWf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nan 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 --- drivers/md/md.h | 3 ++- drivers/md/md.c | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/md/md.h b/drivers/md/md.h index 1a4f976951c1..d57e765b4ec2 100644 --- a/drivers/md/md.h +++ b/drivers/md/md.h @@ -589,7 +589,8 @@ static inline void md_sync_acct(struct block_device *bdev, unsigned long nr_sect static inline void md_sync_acct_bio(struct bio *bio, unsigned long nr_sectors) { - md_sync_acct(bio->bi_bdev, nr_sectors); + if (blk_queue_io_stat(disk—>queue)) + md_sync_acct(bio->bi_bdev, nr_sectors); } struct md_personality diff --git a/drivers/md/md.c b/drivers/md/md.c index 1d71b2a9af03..9a3610bcc75f 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -8502,6 +8502,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 (blk_queue_io_stat(disk—>queue)) + continue; + curr_events = (long long)part_stat_read_accum(disk->part0, sectors) - atomic64_read(&disk->sync_io);