All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yu Kuai <yukuai1@huaweicloud.com>
To: song@kernel.org, guoqing.jiang@linux.dev, jgq516@gmail.com
Cc: linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org,
	yukuai3@huawei.com, yukuai1@huaweicloud.com, yi.zhang@huawei.com,
	yangerkun@huawei.com
Subject: [PATCH v3] md/raid10: don't call bio_start_io_acct twice for bio which experienced read error
Date: Tue, 14 Mar 2023 09:22:58 +0800	[thread overview]
Message-ID: <20230314012258.2395894-1-yukuai1@huaweicloud.com> (raw)
In-Reply-To: <CAPhsuW5nw0tgVmm-iB++_x2K=dBNSyHNtfpLyKBArn6YZVoteA@mail.gmail.com>

From: Yu Kuai <yukuai3@huawei.com>

handle_read_error() will resumit r10_bio by raid10_read_request(), which
will call bio_start_io_acct() again, while bio_end_io_acct() will only
be called once.

Fix the problem by don't account io again from handle_read_error().

Fixes: 528bc2cf2fcc ("md/raid10: enable io accounting")
Suggested-by: Song Liu <song@kernel.org>
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
Changes in v3:
 - use r10_bo->start_time instead of adding a new paramater.
Changes in v3:
 - Change the patch title

 drivers/md/raid10.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 6c66357f92f5..3483fdf796ec 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -1244,7 +1244,8 @@ static void raid10_read_request(struct mddev *mddev, struct bio *bio,
 	}
 	slot = r10_bio->read_slot;
 
-	if (blk_queue_io_stat(bio->bi_bdev->bd_disk->queue))
+	if (!r10_bio->start_time &&
+	    blk_queue_io_stat(bio->bi_bdev->bd_disk->queue))
 		r10_bio->start_time = bio_start_io_acct(bio);
 	read_bio = bio_alloc_clone(rdev->bdev, bio, gfp, &mddev->bio_set);
 
@@ -1574,6 +1575,7 @@ static void __make_request(struct mddev *mddev, struct bio *bio, int sectors)
 	r10_bio->sector = bio->bi_iter.bi_sector;
 	r10_bio->state = 0;
 	r10_bio->read_slot = -1;
+	r10_bio->start_time = 0;
 	memset(r10_bio->devs, 0, sizeof(r10_bio->devs[0]) *
 			conf->geo.raid_disks);
 
-- 
2.31.1


  parent reply	other threads:[~2023-03-14  1:24 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-10  7:38 [PATCH v2 0/6] md/raid10: several simple obvious bugfix Yu Kuai
2023-03-10  7:38 ` [PATCH v2 1/6] md/raid10: don't call bio_start_io_acct twice for bio which experienced read error Yu Kuai
2023-03-13 22:08   ` Song Liu
2023-03-14  1:16     ` Yu Kuai
2023-03-14  1:22     ` Yu Kuai [this message]
2023-03-14 20:43       ` [PATCH v3] " Song Liu
2023-03-10  7:38 ` [PATCH v2 2/6] md: fix soft lockup in status_resync Yu Kuai
2023-03-13 22:24   ` Song Liu
2023-03-10  7:38 ` [PATCH v2 3/6] md/raid10: don't BUG_ON() in raise_barrier() Yu Kuai
2023-03-10  7:38 ` [PATCH v2 4/6] md/radi10: fix leak of 'r10bio->remaining' for recovery Yu Kuai
2023-03-10  7:38 ` [PATCH v2 5/6] md/raid10: fix memleak for 'conf->bio_split' Yu Kuai
2023-03-10  7:38 ` [PATCH v2 6/6] md/raid10: fix memleak of md thread Yu Kuai
2023-03-13 22:37 ` [PATCH v2 0/6] md/raid10: several simple obvious bugfix Song Liu
2023-03-14 12:02   ` Yu Kuai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230314012258.2395894-1-yukuai1@huaweicloud.com \
    --to=yukuai1@huaweicloud.com \
    --cc=guoqing.jiang@linux.dev \
    --cc=jgq516@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=song@kernel.org \
    --cc=yangerkun@huawei.com \
    --cc=yi.zhang@huawei.com \
    --cc=yukuai3@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.