From nobody Fri Dec 19 20:17:20 2025 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8B1872459EC; Sun, 27 Apr 2025 08:37:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745743034; cv=none; b=EcuASN7XfEUVMOYsGZGS//PTkL+2rkh6x1C4eYQYb/6tjge2zTxSUHO3ZRtEQoZn20hXyklaHIyx2vu8EhR6wN0abeQZJjlYs2h0kI1+nnIJRYRiTY3wQGariHz3NCXdUmiXZAON66nQHjWlZ1QJs5r/byEBe1m+8lgRKB3E1sA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745743034; c=relaxed/simple; bh=Fy+XrpR+XQNXmNL2PJU2JswxEOnS0jPUJGAsgpm1quQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=GOjQhXOZgsecyb6FUkgovizlF80JzYVfAGUbAbT0MxuOOrAYTXFwIPd8XYaQmUKC08yErkne6gdAI1JE8IbdD/IFGrhs2MZ8WTyeeBUr8ym1tHVQA1YLT99bBk+EhatlxCVrGGYeHtlmso1rLzxa4Tdp0BTJBEgAC7Ik3Vb1mUs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.163.216]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4Zlg0x4RYDz4f3jtW; Sun, 27 Apr 2025 16:36:49 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.252]) by mail.maildlp.com (Postfix) with ESMTP id 607361A18EC; Sun, 27 Apr 2025 16:37:08 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP3 (Coremail) with SMTP id _Ch0CgDHGsWx7A1oOv4xKg--.7274S5; Sun, 27 Apr 2025 16:37:08 +0800 (CST) From: Yu Kuai To: hch@infradead.org, axboe@kernel.dk, xni@redhat.com, agk@redhat.com, snitzer@kernel.org, mpatocka@redhat.com, song@kernel.org, yukuai3@huawei.com, cl@linux.com, nadav.amit@gmail.com, ubizjak@gmail.com, akpm@linux-foundation.org Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, dm-devel@lists.linux.dev, linux-raid@vger.kernel.org, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com, johnny.chenyi@huawei.com Subject: [PATCH v2 1/9] blk-mq: remove blk_mq_in_flight() Date: Sun, 27 Apr 2025 16:29:20 +0800 Message-Id: <20250427082928.131295-2-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20250427082928.131295-1-yukuai1@huaweicloud.com> References: <20250427082928.131295-1-yukuai1@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: _Ch0CgDHGsWx7A1oOv4xKg--.7274S5 X-Coremail-Antispam: 1UD129KBjvJXoW7KFyrKrW7Wry8ArW3Kw4kZwb_yoW8Jw4UpF W5Gan8CrW2gr18uFy8tanrX3Wayws8KryxAwsxAry5tr18Kr13ZF18Zr4kZr4SvrZ3uFZr uFs0yFy7CF10g37anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUmvb4IE77IF4wAFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUGw A2048vs2IY020Ec7CjxVAFwI0_Gr0_Xr1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxS w2x7M28EF7xvwVC0I7IYx2IY67AKxVW7JVWDJwA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxV W8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v2 6rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMc Ij6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_ Jr0_Gr1lF7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7M4IIrI8v6xkF7I 0E8cxan2IY04v7MxkF7I0En4kS14v26r4a6rW5MxAIw28IcxkI7VAKI48JMxC20s026xCa FVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_Jr Wlx4CE17CEb7AF67AKxVW8ZVWrXwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1j 6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwCI42IY6xAIw20EY4v20xvaj40_Jr 0_JF4lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8JVW8JrUv cSsGvfC2KfnxnUUI43ZEXa7sRMv31JUUUUU== X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ Content-Type: text/plain; charset="utf-8" From: Yu Kuai It's not used and can be removed. Signed-off-by: Yu Kuai Reviewed-by: Christoph Hellwig Reviewed-by: Hannes Reinecke Reviewed-by: John Garry --- block/blk-mq.c | 10 ---------- block/blk-mq.h | 2 -- 2 files changed, 12 deletions(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index c2697db59109..301dbd3e1743 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -101,16 +101,6 @@ static bool blk_mq_check_inflight(struct request *rq, = void *priv) return true; } =20 -unsigned int blk_mq_in_flight(struct request_queue *q, - struct block_device *part) -{ - struct mq_inflight mi =3D { .part =3D part }; - - blk_mq_queue_tag_busy_iter(q, blk_mq_check_inflight, &mi); - - return mi.inflight[0] + mi.inflight[1]; -} - void blk_mq_in_flight_rw(struct request_queue *q, struct block_device *par= t, unsigned int inflight[2]) { diff --git a/block/blk-mq.h b/block/blk-mq.h index 3011a78cf16a..a23d5812d08f 100644 --- a/block/blk-mq.h +++ b/block/blk-mq.h @@ -246,8 +246,6 @@ static inline bool blk_mq_hw_queue_mapped(struct blk_mq= _hw_ctx *hctx) return hctx->nr_ctx && hctx->tags; } =20 -unsigned int blk_mq_in_flight(struct request_queue *q, - struct block_device *part); void blk_mq_in_flight_rw(struct request_queue *q, struct block_device *par= t, unsigned int inflight[2]); =20 --=20 2.39.2 From nobody Fri Dec 19 20:17:20 2025 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3AB8B2475CB; Sun, 27 Apr 2025 08:37:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745743035; cv=none; b=nTmrhuyuTxIAhbSCdGOLzg4ea1/QSig7zDPFy+uk4kdXOUvDwFPlNajmfjnpgjBzLOtvY3/ByeebQeIlXNkv/vKMldrjLazLSYaRQ8TiRwLKVLXrM+AhDK72D62FWrvJKwd+zdEIBKvD8Oo1aIjBIVOn2ZcXcTCW/S3xq8ucmXE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745743035; c=relaxed/simple; bh=fXcNQwWqeVyBqzxcd5v2VPNaXfbyZPMYGJAkOljc/Ac=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=g12tvrsahpblczQitw2wg7iplKZFMrpwGx/FnZ/fvTneroCyxDTy8D/B1pOVJuSUppXyeyuEzjc0dEq62VAeqjrDetBZdMJh3PAbG/IHPtR+D0ftZlT9q0dSqJh1RtJo+makircFuCxhJAyuqyNAYZ3ZmyltwvwvFEnEsHfmYTw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.163.235]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4Zlg0y2Pmqz4f3jqb; Sun, 27 Apr 2025 16:36:50 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.252]) by mail.maildlp.com (Postfix) with ESMTP id 2656D1A0ECD; Sun, 27 Apr 2025 16:37:09 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP3 (Coremail) with SMTP id _Ch0CgDHGsWx7A1oOv4xKg--.7274S6; Sun, 27 Apr 2025 16:37:08 +0800 (CST) From: Yu Kuai To: hch@infradead.org, axboe@kernel.dk, xni@redhat.com, agk@redhat.com, snitzer@kernel.org, mpatocka@redhat.com, song@kernel.org, yukuai3@huawei.com, cl@linux.com, nadav.amit@gmail.com, ubizjak@gmail.com, akpm@linux-foundation.org Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, dm-devel@lists.linux.dev, linux-raid@vger.kernel.org, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com, johnny.chenyi@huawei.com Subject: [PATCH v2 2/9] block: reuse part_in_flight_rw for part_in_flight Date: Sun, 27 Apr 2025 16:29:21 +0800 Message-Id: <20250427082928.131295-3-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20250427082928.131295-1-yukuai1@huaweicloud.com> References: <20250427082928.131295-1-yukuai1@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: _Ch0CgDHGsWx7A1oOv4xKg--.7274S6 X-Coremail-Antispam: 1UD129KBjvJXoWrtFyUXryDCr48Xr1UGF43GFg_yoW8Jr48pr 4SkasIyFWDGr1fur10qr4xXa4ftw4UK34xZ343A34ftF4UJFnxZr93Kwn2yrySvr97Zay5 u34YyFy7GF1UZw7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUmY14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_Jryl82xGYIkIc2 x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0 Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F4UJw A2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq3wAS 0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2 IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0 Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628vn2kIc2 xKxwCY1x0262kKe7AKxVW8ZVWrXwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWU JVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67 kF1VAFwI0_GFv_WrylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY 6xIIjxv20xvEc7CjxVAFwI0_Cr0_Gr1UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42 IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIev Ja73UjIFyTuYvjTRNiSHDUUUU X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ Content-Type: text/plain; charset="utf-8" From: Yu Kuai They are almost identical, to make code cleaner. Signed-off-by: Yu Kuai Reviewed-by: Christoph Hellwig Reviewed-by: Hannes Reinecke Reviewed-by: John Garry --- block/genhd.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/block/genhd.c b/block/genhd.c index c2bd86cd09de..f671d9ee00c4 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -125,21 +125,6 @@ static void part_stat_read_all(struct block_device *pa= rt, } } =20 -unsigned int part_in_flight(struct block_device *part) -{ - unsigned int inflight =3D 0; - int cpu; - - for_each_possible_cpu(cpu) { - inflight +=3D part_stat_local_read_cpu(part, in_flight[0], cpu) + - part_stat_local_read_cpu(part, in_flight[1], cpu); - } - if ((int)inflight < 0) - inflight =3D 0; - - return inflight; -} - static void part_in_flight_rw(struct block_device *part, unsigned int inflight[2]) { @@ -157,6 +142,15 @@ static void part_in_flight_rw(struct block_device *par= t, inflight[1] =3D 0; } =20 +unsigned int part_in_flight(struct block_device *part) +{ + unsigned int inflight[2]; + + part_in_flight_rw(part, inflight); + + return inflight[READ] + inflight[WRITE]; +} + /* * Can be deleted altogether. Later. * --=20 2.39.2 From nobody Fri Dec 19 20:17:20 2025 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E8ABF24729E; Sun, 27 Apr 2025 08:37:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745743034; cv=none; b=YuUmuMVQj8u70H3LV5zmAqS3eZrLeWR1s+X1KJSByuhQIE+3BqC7XnEvY/YD4td4MxxMmO50Po9osb072Q362/FzIekSHpXqtklUdP4L1I56C4RKU55e+CUvXJPUm9kDCCxK6thE0ezvsj/SQi99mjtBh5jbA4avLuWDvwv5PeA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745743034; c=relaxed/simple; bh=I3IP+6pZGUdxD1vyt2vEOwUCd6PtNM/JC/1BzMwekBo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=omssgG+FHgDT70Qwedl00pAqRIKx5egF6LAF2l8PtD1i5YjhG8LMjP83AGWtAhzQSgX8XaNKTuXJbnURYGg2v4vnX77Dhj+awf+g9Ht8kE01GI2WtOL0lSFecrRJdbEWP1dMjFCFNrExjrp2WmbNy2BMaZ0HKATcQPLCSNwXjHc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.93.142]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTPS id 4Zlg1L2pxMzYQv4h; Sun, 27 Apr 2025 16:37:10 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.252]) by mail.maildlp.com (Postfix) with ESMTP id D8D151A018D; Sun, 27 Apr 2025 16:37:09 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP3 (Coremail) with SMTP id _Ch0CgDHGsWx7A1oOv4xKg--.7274S7; Sun, 27 Apr 2025 16:37:09 +0800 (CST) From: Yu Kuai To: hch@infradead.org, axboe@kernel.dk, xni@redhat.com, agk@redhat.com, snitzer@kernel.org, mpatocka@redhat.com, song@kernel.org, yukuai3@huawei.com, cl@linux.com, nadav.amit@gmail.com, ubizjak@gmail.com, akpm@linux-foundation.org Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, dm-devel@lists.linux.dev, linux-raid@vger.kernel.org, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com, johnny.chenyi@huawei.com Subject: [PATCH v2 3/9] block: WARN if bdev inflight counter is negative Date: Sun, 27 Apr 2025 16:29:22 +0800 Message-Id: <20250427082928.131295-4-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20250427082928.131295-1-yukuai1@huaweicloud.com> References: <20250427082928.131295-1-yukuai1@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: _Ch0CgDHGsWx7A1oOv4xKg--.7274S7 X-Coremail-Antispam: 1UD129KBjvdXoWrtF18GF1xZFy8uryxur4kJFb_yoW3KFc_Gr n2g34DZw13GFZxArn0vF4YvrWv9w18JFZ3JFy2qF9xur4UXasagw1vyws8JFZ8Xa90gFyS kF9rZFy0yr13tjkaLaAFLSUrUUUUjb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbkkFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k26cxKx2IYs7xG 6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUWwA2048vs2IY02 0Ec7CjxVAFwI0_Xr0E3s1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xv wVC0I7IYx2IY67AKxVW7JVWDJwA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxVW8Jr0_Cr1UM2 8EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s0DM2AI xVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20x vE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xv r2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7M4IIrI8v6xkF7I0E8cxan2IY04 v7MxkF7I0En4kS14v26r4a6rW5MxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j 6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7 AF67AKxVW8ZVWrXwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE 2Ix0cI8IcVCY1x0267AKxVWxJVW8Jr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0x vEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVj vjDU0xZFpf9x0pRl_MsUUUUU= X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ Content-Type: text/plain; charset="utf-8" From: Yu Kuai Which means there is a BUG for related bio-based disk driver, or blk-mq for rq-based disk, it's better not to hide the BUG. Signed-off-by: Yu Kuai Reviewed-by: Christoph Hellwig Reviewed-by: Hannes Reinecke --- block/genhd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/block/genhd.c b/block/genhd.c index f671d9ee00c4..d158c25237b6 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -136,9 +136,9 @@ static void part_in_flight_rw(struct block_device *part, inflight[0] +=3D part_stat_local_read_cpu(part, in_flight[0], cpu); inflight[1] +=3D part_stat_local_read_cpu(part, in_flight[1], cpu); } - if ((int)inflight[0] < 0) + if (WARN_ON_ONCE((int)inflight[0] < 0)) inflight[0] =3D 0; - if ((int)inflight[1] < 0) + if (WARN_ON_ONCE((int)inflight[1] < 0)) inflight[1] =3D 0; } =20 --=20 2.39.2 From nobody Fri Dec 19 20:17:20 2025 Received: from dggsgout12.his.huawei.com (dggsgout12.his.huawei.com [45.249.212.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 115E224BCE8; Sun, 27 Apr 2025 08:37:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745743036; cv=none; b=pZV2AR0LrWqvp4CvleYw+ueb4gQ9U6DpVqf8sSh2wlsFYQWbfc9CX/tcfqEgDce9zjlOaFfFL3Ev7Kkdj+kMF/Q5r6CKA8B+DqIejUIQKjGBD50v4ScvrW62duyQfUID+2JyQZRFbiBFoYn/OuNeTeMpJfHra4mSga4G8wVO3uY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745743036; c=relaxed/simple; bh=ijmU0npkFWkOhFlJZmS1k2UfSaOwsdS9IBPLWBwjzwA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=YytbomFAiRgxGjUst0qVgzw2HK88c9PU14xLWR/5UQMTLq7B+9IDjveTzEqwv8BdojCSPmiQWzwF9a3pAs8WHFwfmPQH5Ky0S3//mTjzwmZWYdPuJW/FsGT+EWK0wQ+cnpgHqT7wNQE3UqfCI5frMgZFa28+KhLRjc2kSwhhYz0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.163.235]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4Zlg0t3P74z4f3jd2; Sun, 27 Apr 2025 16:36:46 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.252]) by mail.maildlp.com (Postfix) with ESMTP id 8EE381A0A35; Sun, 27 Apr 2025 16:37:10 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP3 (Coremail) with SMTP id _Ch0CgDHGsWx7A1oOv4xKg--.7274S8; Sun, 27 Apr 2025 16:37:10 +0800 (CST) From: Yu Kuai To: hch@infradead.org, axboe@kernel.dk, xni@redhat.com, agk@redhat.com, snitzer@kernel.org, mpatocka@redhat.com, song@kernel.org, yukuai3@huawei.com, cl@linux.com, nadav.amit@gmail.com, ubizjak@gmail.com, akpm@linux-foundation.org Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, dm-devel@lists.linux.dev, linux-raid@vger.kernel.org, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com, johnny.chenyi@huawei.com Subject: [PATCH v2 4/9] block: cleanup blk_mq_in_flight_rw() Date: Sun, 27 Apr 2025 16:29:23 +0800 Message-Id: <20250427082928.131295-5-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20250427082928.131295-1-yukuai1@huaweicloud.com> References: <20250427082928.131295-1-yukuai1@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: _Ch0CgDHGsWx7A1oOv4xKg--.7274S8 X-Coremail-Antispam: 1UD129KBjvJXoWxuF15Jw1xtw45KF47Ar43ZFb_yoWrZF45pr 45Ka98trW5Wr1fur1xtan7XF1fKw48KryIvwnxAr1ayr18Kr98ZFy8Gw1kAr1SvrykCFW3 C3WYyFy7GF1UC37anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUma14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F 4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq 3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7 IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4U M4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628vn2 kIc2xKxwCY1x0262kKe7AKxVW8ZVWrXwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkE bVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67 AF67kF1VAFwI0_GFv_WrylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI 42IY6xIIjxv20xvEc7CjxVAFwI0_Cr0_Gr1UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCw CI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r4UJVWxJrUvcSsG vfC2KfnxnUUI43ZEXa7sRiHUDtUUUUU== X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ Content-Type: text/plain; charset="utf-8" From: Yu Kuai Also add comment for part_inflight_show() for the difference between bio-based and rq-based device. Signed-off-by: Yu Kuai Reviewed-by: Christoph Hellwig --- block/blk-mq.c | 12 ++++++------ block/blk-mq.h | 3 +-- block/genhd.c | 43 +++++++++++++++++++++++++------------------ 3 files changed, 32 insertions(+), 26 deletions(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index 301dbd3e1743..0067e8226e05 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -89,7 +89,7 @@ struct mq_inflight { unsigned int inflight[2]; }; =20 -static bool blk_mq_check_inflight(struct request *rq, void *priv) +static bool blk_mq_check_in_driver(struct request *rq, void *priv) { struct mq_inflight *mi =3D priv; =20 @@ -101,14 +101,14 @@ static bool blk_mq_check_inflight(struct request *rq,= void *priv) return true; } =20 -void blk_mq_in_flight_rw(struct request_queue *q, struct block_device *par= t, - unsigned int inflight[2]) +void blk_mq_in_driver_rw(struct block_device *part, unsigned int inflight[= 2]) { struct mq_inflight mi =3D { .part =3D part }; =20 - blk_mq_queue_tag_busy_iter(q, blk_mq_check_inflight, &mi); - inflight[0] =3D mi.inflight[0]; - inflight[1] =3D mi.inflight[1]; + blk_mq_queue_tag_busy_iter(bdev_get_queue(part), blk_mq_check_in_driver, + &mi); + inflight[READ] =3D mi.inflight[READ]; + inflight[WRITE] =3D mi.inflight[WRITE]; } =20 #ifdef CONFIG_LOCKDEP diff --git a/block/blk-mq.h b/block/blk-mq.h index a23d5812d08f..4205da1a4836 100644 --- a/block/blk-mq.h +++ b/block/blk-mq.h @@ -246,8 +246,7 @@ static inline bool blk_mq_hw_queue_mapped(struct blk_mq= _hw_ctx *hctx) return hctx->nr_ctx && hctx->tags; } =20 -void blk_mq_in_flight_rw(struct request_queue *q, struct block_device *par= t, - unsigned int inflight[2]); +void blk_mq_in_driver_rw(struct block_device *part, unsigned int inflight[= 2]); =20 static inline void blk_mq_put_dispatch_budget(struct request_queue *q, int budget_token) diff --git a/block/genhd.c b/block/genhd.c index d158c25237b6..2470099b492b 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -126,27 +126,32 @@ static void part_stat_read_all(struct block_device *p= art, } =20 static void part_in_flight_rw(struct block_device *part, - unsigned int inflight[2]) + unsigned int inflight[2], bool mq_driver) { int cpu; =20 - inflight[0] =3D 0; - inflight[1] =3D 0; - for_each_possible_cpu(cpu) { - inflight[0] +=3D part_stat_local_read_cpu(part, in_flight[0], cpu); - inflight[1] +=3D part_stat_local_read_cpu(part, in_flight[1], cpu); + if (mq_driver) { + blk_mq_in_driver_rw(part, inflight); + } else { + for_each_possible_cpu(cpu) { + inflight[READ] +=3D part_stat_local_read_cpu( + part, in_flight[READ], cpu); + inflight[WRITE] +=3D part_stat_local_read_cpu( + part, in_flight[WRITE], cpu); + } } - if (WARN_ON_ONCE((int)inflight[0] < 0)) - inflight[0] =3D 0; - if (WARN_ON_ONCE((int)inflight[1] < 0)) - inflight[1] =3D 0; + + if (WARN_ON_ONCE((int)inflight[READ] < 0)) + inflight[READ] =3D 0; + if (WARN_ON_ONCE((int)inflight[WRITE] < 0)) + inflight[WRITE] =3D 0; } =20 unsigned int part_in_flight(struct block_device *part) { - unsigned int inflight[2]; + unsigned int inflight[2] =3D {0}; =20 - part_in_flight_rw(part, inflight); + part_in_flight_rw(part, inflight, false); =20 return inflight[READ] + inflight[WRITE]; } @@ -1036,19 +1041,21 @@ ssize_t part_stat_show(struct device *dev, (unsigned int)div_u64(stat.nsecs[STAT_FLUSH], NSEC_PER_MSEC)); } =20 +/* + * Show the number of IOs issued to driver. + * For bio-based device, started from bdev_start_io_acct(); + * For rq-based device, started from blk_mq_start_request(); + */ ssize_t part_inflight_show(struct device *dev, struct device_attribute *at= tr, char *buf) { struct block_device *bdev =3D dev_to_bdev(dev); struct request_queue *q =3D bdev_get_queue(bdev); - unsigned int inflight[2]; + unsigned int inflight[2] =3D {0}; =20 - if (queue_is_mq(q)) - blk_mq_in_flight_rw(q, bdev, inflight); - else - part_in_flight_rw(bdev, inflight); + part_in_flight_rw(bdev, inflight, queue_is_mq(q)); =20 - return sysfs_emit(buf, "%8u %8u\n", inflight[0], inflight[1]); + return sysfs_emit(buf, "%8u %8u\n", inflight[READ], inflight[WRITE]); } =20 static ssize_t disk_capability_show(struct device *dev, --=20 2.39.2 From nobody Fri Dec 19 20:17:20 2025 Received: from dggsgout12.his.huawei.com (dggsgout12.his.huawei.com [45.249.212.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5D7912472BD; Sun, 27 Apr 2025 08:37:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745743036; cv=none; b=n3AzPoj0JAMUW51O+8urYGpRvCBx5TLBWjGoERkRIwAWRUBHvQ//kh+8RPuJ9aWf8qn+KvYKa9/7rxNAEZze/CJZgO5fW1FntXjfhGpYSaKiqHcjVrWkw5eMiGqEtQDIPOVbjT8TezK2ULJ8p4ihkcb5f2PPD/qxg30+hTBvhn4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745743036; c=relaxed/simple; bh=3Zm8ayzm+HKCEu5hYRFXLS/uWZqvyuAb/t6xkLJTbOE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=nBnKT7OQv4xqWUYARluRMrLWyD6aclQYmUD3KEiGq0JiIz8Hd8qSML8v/EzmBBP8BmQZwU8odfWlm2bvUdeoPjpejXk3XG5TtyY1l7GghywESK6iHcQLfM8mG6nD8wBy3nGZJu7tHoml3iPTxZtrkf/1wUM1kYpZEhMzCyelxH8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.163.216]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4Zlg0v1XwVz4f3jcx; Sun, 27 Apr 2025 16:36:47 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.252]) by mail.maildlp.com (Postfix) with ESMTP id 4A9061A1E06; Sun, 27 Apr 2025 16:37:11 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP3 (Coremail) with SMTP id _Ch0CgDHGsWx7A1oOv4xKg--.7274S9; Sun, 27 Apr 2025 16:37:11 +0800 (CST) From: Yu Kuai To: hch@infradead.org, axboe@kernel.dk, xni@redhat.com, agk@redhat.com, snitzer@kernel.org, mpatocka@redhat.com, song@kernel.org, yukuai3@huawei.com, cl@linux.com, nadav.amit@gmail.com, ubizjak@gmail.com, akpm@linux-foundation.org Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, dm-devel@lists.linux.dev, linux-raid@vger.kernel.org, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com, johnny.chenyi@huawei.com Subject: [PATCH v2 5/9] block: export API to get the number of bdev inflight IO Date: Sun, 27 Apr 2025 16:29:24 +0800 Message-Id: <20250427082928.131295-6-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20250427082928.131295-1-yukuai1@huaweicloud.com> References: <20250427082928.131295-1-yukuai1@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: _Ch0CgDHGsWx7A1oOv4xKg--.7274S9 X-Coremail-Antispam: 1UD129KBjvJXoWxAF13Xr13Cr1Uuw1rJw1DZFb_yoWrAFWDpr 1UGas8ArZ0gr1fuF4Dtw4xWr1Sqw4qk34Ivw1xA34akF4DtrySvas2yr92yr4SvrZ7AFWU u34YkF97CF1jkw7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUmS14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F 4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq 3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7 IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4U M4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628vn2 kIc2xKxwCY1x0262kKe7AKxVW8ZVWrXwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkE bVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67 AF67kF1VAFwI0_GFv_WrylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUCVW8JwCI 42IY6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F4UJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF 4lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8Jr0_Cr1UYxBI daVFxhVjvjDU0xZFpf9x0pRQJ5wUUUUU= X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ Content-Type: text/plain; charset="utf-8" From: Yu Kuai - rename part_in_{flight, flight_rw} to bdev_count_{inflight, inflight_rw} - export bdev_count_inflight, to fix a problem in mdraid that foreground IO can be starved by background sync IO in later patches Signed-off-by: Yu Kuai Reviewed-by: Christoph Hellwig Reviewed-by: Hannes Reinecke --- block/blk-core.c | 2 +- block/blk.h | 1 - block/genhd.c | 22 ++++++++++++++++------ include/linux/part_stat.h | 2 ++ 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/block/blk-core.c b/block/blk-core.c index e8cc270a453f..b862c66018f2 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -1018,7 +1018,7 @@ void update_io_ticks(struct block_device *part, unsig= ned long now, bool end) stamp =3D READ_ONCE(part->bd_stamp); if (unlikely(time_after(now, stamp)) && likely(try_cmpxchg(&part->bd_stamp, &stamp, now)) && - (end || part_in_flight(part))) + (end || bdev_count_inflight(part))) __part_stat_add(part, io_ticks, now - stamp); =20 if (bdev_is_partition(part)) { diff --git a/block/blk.h b/block/blk.h index 006e3be433d2..f476f233f195 100644 --- a/block/blk.h +++ b/block/blk.h @@ -418,7 +418,6 @@ void blk_apply_bdi_limits(struct backing_dev_info *bdi, int blk_dev_init(void); =20 void update_io_ticks(struct block_device *part, unsigned long now, bool en= d); -unsigned int part_in_flight(struct block_device *part); =20 static inline void req_set_nomerge(struct request_queue *q, struct request= *req) { diff --git a/block/genhd.c b/block/genhd.c index 2470099b492b..fdaeafddfc4c 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -125,7 +125,7 @@ static void part_stat_read_all(struct block_device *par= t, } } =20 -static void part_in_flight_rw(struct block_device *part, +static void bdev_count_inflight_rw(struct block_device *part, unsigned int inflight[2], bool mq_driver) { int cpu; @@ -147,14 +147,24 @@ static void part_in_flight_rw(struct block_device *pa= rt, inflight[WRITE] =3D 0; } =20 -unsigned int part_in_flight(struct block_device *part) +/** + * bdev_count_inflight - get the number of inflight IOs for a block device. + * + * @part: the block device. + * + * Inflight here means started IO accounting, from bdev_start_io_acct() for + * bio-based block device, and from blk_account_io_start() for rq-based bl= ock + * device. + */ +unsigned int bdev_count_inflight(struct block_device *part) { unsigned int inflight[2] =3D {0}; =20 - part_in_flight_rw(part, inflight, false); + bdev_count_inflight_rw(part, inflight, false); =20 return inflight[READ] + inflight[WRITE]; } +EXPORT_SYMBOL_GPL(bdev_count_inflight); =20 /* * Can be deleted altogether. Later. @@ -1004,7 +1014,7 @@ ssize_t part_stat_show(struct device *dev, struct disk_stats stat; unsigned int inflight; =20 - inflight =3D part_in_flight(bdev); + inflight =3D bdev_count_inflight(bdev); if (inflight) { part_stat_lock(); update_io_ticks(bdev, jiffies, true); @@ -1053,7 +1063,7 @@ ssize_t part_inflight_show(struct device *dev, struct= device_attribute *attr, struct request_queue *q =3D bdev_get_queue(bdev); unsigned int inflight[2] =3D {0}; =20 - part_in_flight_rw(bdev, inflight, queue_is_mq(q)); + bdev_count_inflight_rw(bdev, inflight, queue_is_mq(q)); =20 return sysfs_emit(buf, "%8u %8u\n", inflight[READ], inflight[WRITE]); } @@ -1308,7 +1318,7 @@ static int diskstats_show(struct seq_file *seqf, void= *v) if (bdev_is_partition(hd) && !bdev_nr_sectors(hd)) continue; =20 - inflight =3D part_in_flight(hd); + inflight =3D bdev_count_inflight(hd); if (inflight) { part_stat_lock(); update_io_ticks(hd, jiffies, true); diff --git a/include/linux/part_stat.h b/include/linux/part_stat.h index c5e9cac0575e..eeeff2a04529 100644 --- a/include/linux/part_stat.h +++ b/include/linux/part_stat.h @@ -79,4 +79,6 @@ static inline void part_stat_set_all(struct block_device = *part, int value) #define part_stat_local_read_cpu(part, field, cpu) \ local_read(&(part_stat_get_cpu(part, field, cpu))) =20 +unsigned int bdev_count_inflight(struct block_device *part); + #endif /* _LINUX_PART_STAT_H */ --=20 2.39.2 From nobody Fri Dec 19 20:17:20 2025 Received: from dggsgout12.his.huawei.com (dggsgout12.his.huawei.com [45.249.212.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2DE7424EAB2; Sun, 27 Apr 2025 08:37:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745743037; cv=none; b=YLimWMZELOJVlJFk4toR4qQYwyVEgkhiJU9D3e7nO8IsIOSZklX3lUVxtmd9Prsj5rAGBfCbJSFMTa4/a9sIUJu93N6DK2anFAf6IZCkbGx2yxtDTg3x1xzF7Tl7I8C/sqRnDJ0DL9bbLwLUpblUA7an66DeeSAAKJXt0kM8/F0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745743037; c=relaxed/simple; bh=wO9Y0wqHdeWfdHbfJPLlykXM5N1LOb5pjmWpm6HDKfk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=MTEZCY/gJdMtMyvlybdLoWFVX4BTzdb9tnY5Elss+mf/Y90XYpwEquH/1ZZnLci9PVZ4wl0XfSmAMMu0riw642GLw3jekJlL86FPTkjiXi7GKo5FDlQivxZspn5/Wuj5LqzuN4fRI/7XiOLBRhpPDGRDubSXa7XIdPOxTwLENnY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.93.142]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4Zlg0v6Slfz4f3jd1; Sun, 27 Apr 2025 16:36:47 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.252]) by mail.maildlp.com (Postfix) with ESMTP id 056D21A018D; Sun, 27 Apr 2025 16:37:12 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP3 (Coremail) with SMTP id _Ch0CgDHGsWx7A1oOv4xKg--.7274S10; Sun, 27 Apr 2025 16:37:11 +0800 (CST) From: Yu Kuai To: hch@infradead.org, axboe@kernel.dk, xni@redhat.com, agk@redhat.com, snitzer@kernel.org, mpatocka@redhat.com, song@kernel.org, yukuai3@huawei.com, cl@linux.com, nadav.amit@gmail.com, ubizjak@gmail.com, akpm@linux-foundation.org Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, dm-devel@lists.linux.dev, linux-raid@vger.kernel.org, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com, johnny.chenyi@huawei.com Subject: [PATCH v2 6/9] md: record dm-raid gendisk in mddev Date: Sun, 27 Apr 2025 16:29:25 +0800 Message-Id: <20250427082928.131295-7-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20250427082928.131295-1-yukuai1@huaweicloud.com> References: <20250427082928.131295-1-yukuai1@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: _Ch0CgDHGsWx7A1oOv4xKg--.7274S10 X-Coremail-Antispam: 1UD129KBjvJXoW7AFy8Gw4xtF1kGF4rCr1ftFb_yoW8WF4fpa 1DC3yrArW5J39Fq3WDJr4DZa45X3WvqryrKFZxCaySvayavF98Ww1kKF42qr4DGrZIgFnx ur4jvrZ5Kry0yrJanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUmS14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F 4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq 3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7 IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4U M4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628vn2 kIc2xKxwCY1x0262kKe7AKxVW8ZVWrXwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkE bVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67 AF67kF1VAFwI0_GFv_WrylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUCVW8JwCI 42IY6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F4UJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF 4lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8Jr0_Cr1UYxBI daVFxhVjvjDU0xZFpf9x0pRQJ5wUUUUU= X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ Content-Type: text/plain; charset="utf-8" From: Yu Kuai Following patch will use gendisk to check if there are normal IO completed or inflight, to fix a problem in mdraid that foreground IO can be starved by background sync IO in later patches. Signed-off-by: Yu Kuai Reviewed-by: Xiao Ni --- drivers/md/dm-raid.c | 3 +++ drivers/md/md.h | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/md/dm-raid.c b/drivers/md/dm-raid.c index 6adc55fd90d3..127138c61be5 100644 --- a/drivers/md/dm-raid.c +++ b/drivers/md/dm-raid.c @@ -14,6 +14,7 @@ #include "raid5.h" #include "raid10.h" #include "md-bitmap.h" +#include "dm-core.h" =20 #include =20 @@ -3308,6 +3309,7 @@ static int raid_ctr(struct dm_target *ti, unsigned in= t argc, char **argv) =20 /* Disable/enable discard support on raid set. */ configure_discard_support(rs); + rs->md.dm_gendisk =3D ti->table->md->disk; =20 mddev_unlock(&rs->md); return 0; @@ -3327,6 +3329,7 @@ static void raid_dtr(struct dm_target *ti) =20 mddev_lock_nointr(&rs->md); md_stop(&rs->md); + rs->md.dm_gendisk =3D NULL; mddev_unlock(&rs->md); =20 if (work_pending(&rs->md.event_work)) diff --git a/drivers/md/md.h b/drivers/md/md.h index 1cf00a04bcdd..9d55b4630077 100644 --- a/drivers/md/md.h +++ b/drivers/md/md.h @@ -404,7 +404,8 @@ struct mddev { * are happening, so run/ * takeover/stop are not safe */ - struct gendisk *gendisk; + struct gendisk *gendisk; /* mdraid gendisk */ + struct gendisk *dm_gendisk; /* dm-raid gendisk */ =20 struct kobject kobj; int hold_active; --=20 2.39.2 From nobody Fri Dec 19 20:17:20 2025 Received: from dggsgout12.his.huawei.com (dggsgout12.his.huawei.com [45.249.212.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2DEEE24EAB3; Sun, 27 Apr 2025 08:37:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745743037; cv=none; b=BLJnXz9arK7ggB8jyhMDnVrqzAw7MkYVHWbCnlnYG5D35p3vf8hGzQum+8BHEFNLxIaY+Z/3oqvWjT/tlgpNSn3Avvr8TZB6vk/j4ToAWv3vJC/pxTRtQ4OQkWSPyOjwK5SX4FcR/K983nLBWbZpQ3jX9mW1GyTHWBaElINnRvg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745743037; c=relaxed/simple; bh=J8bFkfk+MCfF7XzZERo8lUNzg/aNDMc3ryTWN5qAMBQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=sE5CFsaD33zg8thh+aZq6D9kLgFoWBd0aLCBoTPIEQ3tivxmbtWZoWR5AC9OMga5fQKhxaVO6L75g5+spHq89iRoGD+Yzl8Vkw1xyjhLgChW1gsTasjUs/kdvH++Qgbn1obx7QM/MtPZiHPdn78OzUOBVbjI7aOsEgytqTgpRkU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.93.142]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTPS id 4Zlg1P5D4JzKHMkl; Sun, 27 Apr 2025 16:37:13 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.252]) by mail.maildlp.com (Postfix) with ESMTP id B73181A018D; Sun, 27 Apr 2025 16:37:12 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP3 (Coremail) with SMTP id _Ch0CgDHGsWx7A1oOv4xKg--.7274S11; Sun, 27 Apr 2025 16:37:12 +0800 (CST) From: Yu Kuai To: hch@infradead.org, axboe@kernel.dk, xni@redhat.com, agk@redhat.com, snitzer@kernel.org, mpatocka@redhat.com, song@kernel.org, yukuai3@huawei.com, cl@linux.com, nadav.amit@gmail.com, ubizjak@gmail.com, akpm@linux-foundation.org Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, dm-devel@lists.linux.dev, linux-raid@vger.kernel.org, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com, johnny.chenyi@huawei.com Subject: [PATCH v2 7/9] md: add a new api sync_io_depth Date: Sun, 27 Apr 2025 16:29:26 +0800 Message-Id: <20250427082928.131295-8-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20250427082928.131295-1-yukuai1@huaweicloud.com> References: <20250427082928.131295-1-yukuai1@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: _Ch0CgDHGsWx7A1oOv4xKg--.7274S11 X-Coremail-Antispam: 1UD129KBjvJXoWxKFW7uw47JrWrKw4fWF4xCrg_yoWxKr1fpa y7AFy3Gr1UZFZxXr43JFsxCa4rXr4fK3yUt3y7Gw1xJF13Wr9rGF1SqFW5XF9rWa4fCrnr ZF1UJFZ8ua1Iyr7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUmS14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F 4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq 3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7 IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4U M4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628vn2 kIc2xKxwCY1x0262kKe7AKxVW8ZVWrXwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkE bVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67 AF67kF1VAFwI0_GFv_WrylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUCVW8JwCI 42IY6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F4UJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF 4lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8Jr0_Cr1UYxBI daVFxhVjvjDU0xZFpf9x0pRQJ5wUUUUU= X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ Content-Type: text/plain; charset="utf-8" From: Yu Kuai Currently if sync speed is above speed_min and below speed_max, md_do_sync() will wait for all sync IOs to be done before issuing new sync IO, means sync IO depth is limited to just 1. This limit is too low, in order to prevent sync speed drop conspicuously after fixing is_mddev_idle() in the next patch, add a new api for limiting sync IO depth, the default value is 32. Signed-off-by: Yu Kuai Reviewed-by: Xiao Ni --- drivers/md/md.c | 109 +++++++++++++++++++++++++++++++++++++++--------- drivers/md/md.h | 1 + 2 files changed, 91 insertions(+), 19 deletions(-) diff --git a/drivers/md/md.c b/drivers/md/md.c index 9daa78c5fe33..541151bcfe81 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -111,32 +111,48 @@ static void md_wakeup_thread_directly(struct md_threa= d __rcu *thread); /* Default safemode delay: 200 msec */ #define DEFAULT_SAFEMODE_DELAY ((200 * HZ)/1000 +1) /* - * Current RAID-1,4,5 parallel reconstruction 'guaranteed speed limit' - * is 1000 KB/sec, so the extra system load does not show up that much. - * Increase it if you want to have more _guaranteed_ speed. Note that - * the RAID driver will use the maximum available bandwidth if the IO - * subsystem is idle. There is also an 'absolute maximum' reconstruction - * speed limit - in case reconstruction slows down your system despite - * idle IO detection. + * Current RAID-1,4,5,6,10 parallel reconstruction 'guaranteed speed limit' + * is sysctl_speed_limit_min, 1000 KB/sec by default, so the extra system = load + * does not show up that much. Increase it if you want to have more guaran= teed + * speed. Note that the RAID driver will use the maximum bandwidth + * sysctl_speed_limit_max, 200 MB/sec by default, if the IO subsystem is i= dle. * - * you can change it via /proc/sys/dev/raid/speed_limit_min and _max. - * or /sys/block/mdX/md/sync_speed_{min,max} + * Background sync IO speed control: + * + * - below speed min: + * no limit; + * - above speed min and below speed max: + * a) if mddev is idle, then no limit; + * b) if mddev is busy handling normal IO, then limit inflight sync IO + * to sync_io_depth; + * - above speed max: + * sync IO can't be issued; + * + * Following configurations can be changed via /proc/sys/dev/raid/ for sys= tem + * or /sys/block/mdX/md/ for one array. */ - static int sysctl_speed_limit_min =3D 1000; static int sysctl_speed_limit_max =3D 200000; -static inline int speed_min(struct mddev *mddev) +static int sysctl_sync_io_depth =3D 32; + +static int speed_min(struct mddev *mddev) { return mddev->sync_speed_min ? mddev->sync_speed_min : sysctl_speed_limit_min; } =20 -static inline int speed_max(struct mddev *mddev) +static int speed_max(struct mddev *mddev) { return mddev->sync_speed_max ? mddev->sync_speed_max : sysctl_speed_limit_max; } =20 +static int sync_io_depth(struct mddev *mddev) +{ + return mddev->sync_io_depth ? + mddev->sync_io_depth : sysctl_sync_io_depth; +} + static void rdev_uninit_serial(struct md_rdev *rdev) { if (!test_and_clear_bit(CollisionCheck, &rdev->flags)) @@ -293,14 +309,21 @@ static const struct ctl_table raid_table[] =3D { .procname =3D "speed_limit_min", .data =3D &sysctl_speed_limit_min, .maxlen =3D sizeof(int), - .mode =3D S_IRUGO|S_IWUSR, + .mode =3D 0644, .proc_handler =3D proc_dointvec, }, { .procname =3D "speed_limit_max", .data =3D &sysctl_speed_limit_max, .maxlen =3D sizeof(int), - .mode =3D S_IRUGO|S_IWUSR, + .mode =3D 0644, + .proc_handler =3D proc_dointvec, + }, + { + .procname =3D "sync_io_depth", + .data =3D &sysctl_sync_io_depth, + .maxlen =3D sizeof(int), + .mode =3D 0644, .proc_handler =3D proc_dointvec, }, }; @@ -5091,7 +5114,7 @@ static ssize_t sync_min_show(struct mddev *mddev, char *page) { return sprintf(page, "%d (%s)\n", speed_min(mddev), - mddev->sync_speed_min ? "local": "system"); + mddev->sync_speed_min ? "local" : "system"); } =20 static ssize_t @@ -5100,7 +5123,7 @@ sync_min_store(struct mddev *mddev, const char *buf, = size_t len) unsigned int min; int rv; =20 - if (strncmp(buf, "system", 6)=3D=3D0) { + if (strncmp(buf, "system", 6) =3D=3D 0) { min =3D 0; } else { rv =3D kstrtouint(buf, 10, &min); @@ -5120,7 +5143,7 @@ static ssize_t sync_max_show(struct mddev *mddev, char *page) { return sprintf(page, "%d (%s)\n", speed_max(mddev), - mddev->sync_speed_max ? "local": "system"); + mddev->sync_speed_max ? "local" : "system"); } =20 static ssize_t @@ -5129,7 +5152,7 @@ sync_max_store(struct mddev *mddev, const char *buf, = size_t len) unsigned int max; int rv; =20 - if (strncmp(buf, "system", 6)=3D=3D0) { + if (strncmp(buf, "system", 6) =3D=3D 0) { max =3D 0; } else { rv =3D kstrtouint(buf, 10, &max); @@ -5145,6 +5168,35 @@ sync_max_store(struct mddev *mddev, const char *buf,= size_t len) static struct md_sysfs_entry md_sync_max =3D __ATTR(sync_speed_max, S_IRUGO|S_IWUSR, sync_max_show, sync_max_store); =20 +static ssize_t +sync_io_depth_show(struct mddev *mddev, char *page) +{ + return sprintf(page, "%d (%s)\n", sync_io_depth(mddev), + mddev->sync_io_depth ? "local" : "system"); +} + +static ssize_t +sync_io_depth_store(struct mddev *mddev, const char *buf, size_t len) +{ + unsigned int max; + int rv; + + if (strncmp(buf, "system", 6) =3D=3D 0) { + max =3D 0; + } else { + rv =3D kstrtouint(buf, 10, &max); + if (rv < 0) + return rv; + if (max =3D=3D 0) + return -EINVAL; + } + mddev->sync_io_depth =3D max; + return len; +} + +static struct md_sysfs_entry md_sync_io_depth =3D +__ATTR_RW(sync_io_depth); + static ssize_t degraded_show(struct mddev *mddev, char *page) { @@ -5671,6 +5723,7 @@ static struct attribute *md_redundancy_attrs[] =3D { &md_mismatches.attr, &md_sync_min.attr, &md_sync_max.attr, + &md_sync_io_depth.attr, &md_sync_speed.attr, &md_sync_force_parallel.attr, &md_sync_completed.attr, @@ -8927,6 +8980,23 @@ static sector_t md_sync_position(struct mddev *mddev= , enum sync_action action) } } =20 +static bool sync_io_within_limit(struct mddev *mddev) +{ + int io_sectors; + + /* + * For raid456, sync IO is stripe(4k) per IO, for other levels, it's + * RESYNC_PAGES(64k) per IO. + */ + if (mddev->level =3D=3D 4 || mddev->level =3D=3D 5 || mddev->level =3D=3D= 6) + io_sectors =3D 8; + else + io_sectors =3D 128; + + return atomic_read(&mddev->recovery_active) < + io_sectors * sync_io_depth(mddev); +} + #define SYNC_MARKS 10 #define SYNC_MARK_STEP (3*HZ) #define UPDATE_FREQUENCY (5*60*HZ) @@ -9195,7 +9265,8 @@ void md_do_sync(struct md_thread *thread) msleep(500); goto repeat; } - if (!is_mddev_idle(mddev, 0)) { + if (!sync_io_within_limit(mddev) && + !is_mddev_idle(mddev, 0)) { /* * Give other IO more of a chance. * The faster the devices, the less we wait. diff --git a/drivers/md/md.h b/drivers/md/md.h index 9d55b4630077..b57842188f18 100644 --- a/drivers/md/md.h +++ b/drivers/md/md.h @@ -484,6 +484,7 @@ struct mddev { /* if zero, use the system-wide default */ int sync_speed_min; int sync_speed_max; + int sync_io_depth; =20 /* resync even though the same disks are shared among md-devices */ int parallel_resync; --=20 2.39.2 From nobody Fri Dec 19 20:17:20 2025 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 28FD02528E4; Sun, 27 Apr 2025 08:37:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745743039; cv=none; b=CJ7WXHIe4l9Ehe/0cs/EDmomFotB8y53wFqAJ7pjw7XnZ1o7qCSE7oh0yLdwyLGlqiOE0HTDtSEBVm2F/IxXZtV7Q+3222v0eKDo5UJgqaL2e7Ik4bN9nRT7+D8vP6VNLJMmRhtfQJAZFvTYkqNNV6iMEcBTcNzQ9vHMZhYl4NM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745743039; c=relaxed/simple; bh=d8x6X1UKL73FMoDBvbJl2pdTahVZvmdYcBByUlQtazc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=lYFJTg6iH1kLZqkp0wUZZ239U9stmK26Dlc56hx6Vb5OuqGq17E5FsnNC6QxoxLody2f4reEZlEmDo9zeqX7dOs3fE4OkYZUVWZoJGI7ZTe1s10nOFMwHmqV/oDv2KT79tX1vlcYU3ZbRPOg0//BSXe65qGTeFTa9RQQhrEeG0M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.163.216]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4Zlg0v60J9z4f3lDF; Sun, 27 Apr 2025 16:36:47 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.252]) by mail.maildlp.com (Postfix) with ESMTP id 745E21A1A9E; Sun, 27 Apr 2025 16:37:13 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP3 (Coremail) with SMTP id _Ch0CgDHGsWx7A1oOv4xKg--.7274S12; Sun, 27 Apr 2025 16:37:13 +0800 (CST) From: Yu Kuai To: hch@infradead.org, axboe@kernel.dk, xni@redhat.com, agk@redhat.com, snitzer@kernel.org, mpatocka@redhat.com, song@kernel.org, yukuai3@huawei.com, cl@linux.com, nadav.amit@gmail.com, ubizjak@gmail.com, akpm@linux-foundation.org Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, dm-devel@lists.linux.dev, linux-raid@vger.kernel.org, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com, johnny.chenyi@huawei.com Subject: [PATCH v2 8/9] md: fix is_mddev_idle() Date: Sun, 27 Apr 2025 16:29:27 +0800 Message-Id: <20250427082928.131295-9-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20250427082928.131295-1-yukuai1@huaweicloud.com> References: <20250427082928.131295-1-yukuai1@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: _Ch0CgDHGsWx7A1oOv4xKg--.7274S12 X-Coremail-Antispam: 1UD129KBjvJXoW3Xr48WrW5Xw1kJF1DGFW3ZFb_yoW7ArWxpa y3ua43tr48XF4Sqr45JFykua4Fg34fJ39xtFy3A34xZ3W5Grn0kF43KF4Yv3s8W3ykZFya qa15KF4DCa4UJFJanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUmS14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F 4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq 3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7 IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4U M4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628vn2 kIc2xKxwCY1x0262kKe7AKxVW8ZVWrXwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkE bVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67 AF67kF1VAFwI0_GFv_WrylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUCVW8JwCI 42IY6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F4UJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF 4lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8Jr0_Cr1UYxBI daVFxhVjvjDU0xZFpf9x0pRQJ5wUUUUU= X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ Content-Type: text/plain; charset="utf-8" From: Yu Kuai If sync_speed is above speed_min, then is_mddev_idle() will be called for each sync IO to check if the array is idle, and inflihgt sync_io will be limited if the array is not idle. However, while mkfs.ext4 for a large raid5 array while recovery is in progress, it's found that sync_speed is already above speed_min while lots of stripes are used for sync IO, causing long delay for mkfs.ext4. Root cause is the following checking from is_mddev_idle(): t1: submit sync IO: events1 =3D completed IO - issued sync IO t2: submit next sync IO: events2 =3D completed IO - issued sync IO if (events2 - events1 > 64) For consequence, the more sync IO issued, the less likely checking will pass. And when completed normal IO is more than issued sync IO, the condition will finally pass and is_mddev_idle() will return false, however, last_events will be updated hence is_mddev_idle() can only return false once in a while. Fix this problem by changing the checking as following: 1) mddev doesn't have normal IO completed; 2) mddev doesn't have normal IO inflight; 3) if any member disks is partition, and all other partitions doesn't have IO completed. Signed-off-by: Yu Kuai --- drivers/md/md.c | 84 +++++++++++++++++++++++++++---------------------- drivers/md/md.h | 3 +- 2 files changed, 48 insertions(+), 39 deletions(-) diff --git a/drivers/md/md.c b/drivers/md/md.c index 541151bcfe81..955efe0b40c6 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -8625,50 +8625,58 @@ void md_cluster_stop(struct mddev *mddev) put_cluster_ops(mddev); } =20 -static int is_mddev_idle(struct mddev *mddev, int init) +static bool is_rdev_holder_idle(struct md_rdev *rdev, bool init) { + unsigned long last_events =3D rdev->last_events; + + if (!bdev_is_partition(rdev->bdev)) + return true; + + /* + * If rdev is partition, and user doesn't issue IO to the array, the + * array is still not idle if user issues IO to other partitions. + */ + rdev->last_events =3D part_stat_read_accum(rdev->bdev->bd_disk->part0, + sectors) - + part_stat_read_accum(rdev->bdev, sectors); + + if (!init && rdev->last_events > last_events) + return false; + + return true; +} + +/* + * mddev is idle if following conditions are match since last check: + * 1) mddev doesn't have normal IO completed; + * 2) mddev doesn't have inflight normal IO; + * 3) if any member disk is partition, and other partitions doesn't have IO + * completed; + * + * Noted this checking rely on IO accounting is enabled. + */ +static bool is_mddev_idle(struct mddev *mddev, int init) +{ + unsigned long last_events =3D mddev->normal_IO_events; + struct gendisk *disk; struct md_rdev *rdev; - int idle; - int curr_events; + bool idle =3D true; =20 - idle =3D 1; - rcu_read_lock(); - rdev_for_each_rcu(rdev, mddev) { - struct gendisk *disk =3D rdev->bdev->bd_disk; + disk =3D mddev_is_dm(mddev) ? mddev->dm_gendisk : mddev->gendisk; + if (!disk) + return true; =20 - if (!init && !blk_queue_io_stat(disk->queue)) - continue; + mddev->normal_IO_events =3D part_stat_read_accum(disk->part0, sectors); + if (!init && (mddev->normal_IO_events > last_events || + bdev_count_inflight(disk->part0))) + idle =3D false; =20 - curr_events =3D (int)part_stat_read_accum(disk->part0, sectors) - - atomic_read(&disk->sync_io); - /* sync IO will cause sync_io to increase before the disk_stats - * as sync_io is counted when a request starts, and - * disk_stats is counted when it completes. - * So resync activity will cause curr_events to be smaller than - * when there was no such activity. - * non-sync IO will cause disk_stat to increase without - * increasing sync_io so curr_events will (eventually) - * be larger than it was before. Once it becomes - * substantially larger, the test below will cause - * the array to appear non-idle, and resync will slow - * down. - * If there is a lot of outstanding resync activity when - * we set last_event to curr_events, then all that activity - * completing might cause the array to appear non-idle - * and resync will be slowed down even though there might - * not have been non-resync activity. This will only - * happen once though. 'last_events' will soon reflect - * the state where there is little or no outstanding - * resync requests, and further resync activity will - * always make curr_events less than last_events. - * - */ - if (init || curr_events - rdev->last_events > 64) { - rdev->last_events =3D curr_events; - idle =3D 0; - } - } + rcu_read_lock(); + rdev_for_each_rcu(rdev, mddev) + if (!is_rdev_holder_idle(rdev, init)) + idle =3D false; rcu_read_unlock(); + return idle; } =20 diff --git a/drivers/md/md.h b/drivers/md/md.h index b57842188f18..da3fd514d20c 100644 --- a/drivers/md/md.h +++ b/drivers/md/md.h @@ -132,7 +132,7 @@ struct md_rdev { =20 sector_t sectors; /* Device size (in 512bytes sectors) */ struct mddev *mddev; /* RAID array if running */ - int last_events; /* IO event timestamp */ + unsigned long last_events; /* IO event timestamp */ =20 /* * If meta_bdev is non-NULL, it means that a separate device is @@ -520,6 +520,7 @@ struct mddev { * adding a spare */ =20 + unsigned long normal_IO_events; /* IO event timestamp */ atomic_t recovery_active; /* blocks scheduled, but not written */ wait_queue_head_t recovery_wait; sector_t recovery_cp; --=20 2.39.2 From nobody Fri Dec 19 20:17:20 2025 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DAB872522A2; Sun, 27 Apr 2025 08:37:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745743039; cv=none; b=rlAybkr4enFue4zjTKS4elfuMRDa3qQXt3s2L9ei6EL2qfT9CxFriLjwlYuAO7Pm07y4bEhTSOCkO0DdnAWgZXD9yX3cFwRe4iQcd08wsK8KrcvN5RWU9bc5DoNMtEUv5LWuwMMuHwCSjXYcYstZFuuzVHl3l3YM+jlian9VEV8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745743039; c=relaxed/simple; bh=4AhZnxuETTUIJ6MG4Zxm6HlGgHBJKzaFy+vqHioBzeg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=UEmsuUvB+UiMsN5K4h2iOOiGlgW587JTEJM1zaoIN4JPvlM1XHUORURO/I84mQjS4mkW2pFeuZRTPTrpPRtDyslq+0Xl9VZZILBtFb1k6YfvhTetYNdNzINnN8cwEuXWhOqNRd4hVGdOwMB+r08bu6UZLDH3fsuWcOpEi03zf8w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.163.235]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4Zlg132d34z4f3jtW; Sun, 27 Apr 2025 16:36:55 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.252]) by mail.maildlp.com (Postfix) with ESMTP id 2E6C91A094D; Sun, 27 Apr 2025 16:37:14 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP3 (Coremail) with SMTP id _Ch0CgDHGsWx7A1oOv4xKg--.7274S13; Sun, 27 Apr 2025 16:37:13 +0800 (CST) From: Yu Kuai To: hch@infradead.org, axboe@kernel.dk, xni@redhat.com, agk@redhat.com, snitzer@kernel.org, mpatocka@redhat.com, song@kernel.org, yukuai3@huawei.com, cl@linux.com, nadav.amit@gmail.com, ubizjak@gmail.com, akpm@linux-foundation.org Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, dm-devel@lists.linux.dev, linux-raid@vger.kernel.org, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com, johnny.chenyi@huawei.com Subject: [PATCH v2 9/9] md: cleanup accounting for issued sync IO Date: Sun, 27 Apr 2025 16:29:28 +0800 Message-Id: <20250427082928.131295-10-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20250427082928.131295-1-yukuai1@huaweicloud.com> References: <20250427082928.131295-1-yukuai1@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: _Ch0CgDHGsWx7A1oOv4xKg--.7274S13 X-Coremail-Antispam: 1UD129KBjvJXoW3Ww13JrWrJF4fKFy8uw18uFg_yoW7ur47pa 9xXa4xAFWUGrWF93WDJ3yqk3ZY9347KrW7ArW7u393W3WFyryDZF1UJFWYqF98AFW5urW5 Xa4kGan8CFs7tFUanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUmS14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F 4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq 3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7 IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4U M4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628vn2 kIc2xKxwCY1x0262kKe7AKxVW8ZVWrXwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkE bVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67 AF67kF1VAFwI0_GFv_WrylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUCVW8JwCI 42IY6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F4UJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF 4lIxAIcVC2z280aVAFwI0_Gr0_Cr1lIxAIcVC2z280aVCY1x0267AKxVW8Jr0_Cr1UYxBI daVFxhVjvjDU0xZFpf9x0pRQJ5wUUUUU= X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ Content-Type: text/plain; charset="utf-8" From: Yu Kuai It's no longer used and can be removed, also remove the field 'gendisk->sync_io'. Signed-off-by: Yu Kuai Reviewed-by: Xiao Ni --- drivers/md/md.h | 11 ----------- drivers/md/raid1.c | 3 --- drivers/md/raid10.c | 9 --------- drivers/md/raid5.c | 8 -------- include/linux/blkdev.h | 1 - 5 files changed, 32 deletions(-) diff --git a/drivers/md/md.h b/drivers/md/md.h index da3fd514d20c..4e6af8368e7e 100644 --- a/drivers/md/md.h +++ b/drivers/md/md.h @@ -717,17 +717,6 @@ static inline int mddev_trylock(struct mddev *mddev) } extern void mddev_unlock(struct mddev *mddev); =20 -static inline void md_sync_acct(struct block_device *bdev, unsigned long n= r_sectors) -{ - if (blk_queue_io_stat(bdev->bd_disk->queue)) - atomic_add(nr_sectors, &bdev->bd_disk->sync_io); -} - -static inline void md_sync_acct_bio(struct bio *bio, unsigned long nr_sect= ors) -{ - md_sync_acct(bio->bi_bdev, nr_sectors); -} - struct md_personality { struct md_submodule_head head; diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 0efc03cea24e..9cc01cf66872 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -2376,7 +2376,6 @@ static void sync_request_write(struct mddev *mddev, s= truct r1bio *r1_bio) =20 wbio->bi_end_io =3D end_sync_write; atomic_inc(&r1_bio->remaining); - md_sync_acct(conf->mirrors[i].rdev->bdev, bio_sectors(wbio)); =20 submit_bio_noacct(wbio); } @@ -3049,7 +3048,6 @@ static sector_t raid1_sync_request(struct mddev *mdde= v, sector_t sector_nr, bio =3D r1_bio->bios[i]; if (bio->bi_end_io =3D=3D end_sync_read) { read_targets--; - md_sync_acct_bio(bio, nr_sectors); if (read_targets =3D=3D 1) bio->bi_opf &=3D ~MD_FAILFAST; submit_bio_noacct(bio); @@ -3058,7 +3056,6 @@ static sector_t raid1_sync_request(struct mddev *mdde= v, sector_t sector_nr, } else { atomic_set(&r1_bio->remaining, 1); bio =3D r1_bio->bios[r1_bio->read_disk]; - md_sync_acct_bio(bio, nr_sectors); if (read_targets =3D=3D 1) bio->bi_opf &=3D ~MD_FAILFAST; submit_bio_noacct(bio); diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index 846c5f29486e..7abe79425b85 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -2425,7 +2425,6 @@ static void sync_request_write(struct mddev *mddev, s= truct r10bio *r10_bio) =20 atomic_inc(&conf->mirrors[d].rdev->nr_pending); atomic_inc(&r10_bio->remaining); - md_sync_acct(conf->mirrors[d].rdev->bdev, bio_sectors(tbio)); =20 if (test_bit(FailFast, &conf->mirrors[d].rdev->flags)) tbio->bi_opf |=3D MD_FAILFAST; @@ -2447,8 +2446,6 @@ static void sync_request_write(struct mddev *mddev, s= truct r10bio *r10_bio) bio_copy_data(tbio, fbio); d =3D r10_bio->devs[i].devnum; atomic_inc(&r10_bio->remaining); - md_sync_acct(conf->mirrors[d].replacement->bdev, - bio_sectors(tbio)); submit_bio_noacct(tbio); } =20 @@ -2582,13 +2579,10 @@ static void recovery_request_write(struct mddev *md= dev, struct r10bio *r10_bio) d =3D r10_bio->devs[1].devnum; if (wbio->bi_end_io) { atomic_inc(&conf->mirrors[d].rdev->nr_pending); - md_sync_acct(conf->mirrors[d].rdev->bdev, bio_sectors(wbio)); submit_bio_noacct(wbio); } if (wbio2) { atomic_inc(&conf->mirrors[d].replacement->nr_pending); - md_sync_acct(conf->mirrors[d].replacement->bdev, - bio_sectors(wbio2)); submit_bio_noacct(wbio2); } } @@ -3756,7 +3750,6 @@ static sector_t raid10_sync_request(struct mddev *mdd= ev, sector_t sector_nr, r10_bio->sectors =3D nr_sectors; =20 if (bio->bi_end_io =3D=3D end_sync_read) { - md_sync_acct_bio(bio, nr_sectors); bio->bi_status =3D 0; submit_bio_noacct(bio); } @@ -4879,7 +4872,6 @@ static sector_t reshape_request(struct mddev *mddev, = sector_t sector_nr, r10_bio->sectors =3D nr_sectors; =20 /* Now submit the read */ - md_sync_acct_bio(read_bio, r10_bio->sectors); atomic_inc(&r10_bio->remaining); read_bio->bi_next =3D NULL; submit_bio_noacct(read_bio); @@ -4939,7 +4931,6 @@ static void reshape_request_write(struct mddev *mddev= , struct r10bio *r10_bio) continue; =20 atomic_inc(&rdev->nr_pending); - md_sync_acct_bio(b, r10_bio->sectors); atomic_inc(&r10_bio->remaining); b->bi_next =3D NULL; submit_bio_noacct(b); diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index 6389383166c0..ca5b0e8ba707 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c @@ -1240,10 +1240,6 @@ static void ops_run_io(struct stripe_head *sh, struc= t stripe_head_state *s) } =20 if (rdev) { - if (s->syncing || s->expanding || s->expanded - || s->replacing) - md_sync_acct(rdev->bdev, RAID5_STRIPE_SECTORS(conf)); - set_bit(STRIPE_IO_STARTED, &sh->state); =20 bio_init(bi, rdev->bdev, &dev->vec, 1, op | op_flags); @@ -1300,10 +1296,6 @@ static void ops_run_io(struct stripe_head *sh, struc= t stripe_head_state *s) submit_bio_noacct(bi); } if (rrdev) { - if (s->syncing || s->expanding || s->expanded - || s->replacing) - md_sync_acct(rrdev->bdev, RAID5_STRIPE_SECTORS(conf)); - set_bit(STRIPE_IO_STARTED, &sh->state); =20 bio_init(rbi, rrdev->bdev, &dev->rvec, 1, op | op_flags); diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index e39c45bc0a97..f3a625b00734 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -182,7 +182,6 @@ struct gendisk { struct list_head slave_bdevs; #endif struct timer_rand_state *random; - atomic_t sync_io; /* RAID */ struct disk_events *ev; =20 #ifdef CONFIG_BLK_DEV_ZONED --=20 2.39.2