From: Kenta Akagi <k@mgml.me>
To: Song Liu <song@kernel.org>, Yu Kuai <yukuai@fnnas.com>,
Shaohua Li <shli@fb.com>, Mariusz Tkaczyk <mtkaczyk@kernel.org>,
Guoqing Jiang <jgq516@gmail.com>
Cc: linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org,
Kenta Akagi <k@mgml.me>
Subject: [PATCH v5 07/16] md/raid1: refactor handle_read_error()
Date: Tue, 28 Oct 2025 00:04:24 +0900 [thread overview]
Message-ID: <20251027150433.18193-8-k@mgml.me> (raw)
In-Reply-To: <20251027150433.18193-1-k@mgml.me>
For the failfast bio feature, the behavior of handle_read_error() will
be changed in a subsequent commit, but refactor it first.
This commit only refactors the code without functional changes. A
subsequent commit will replace md_error() with md_cond_error()
to implement proper failfast error handling.
Signed-off-by: Kenta Akagi <k@mgml.me>
---
drivers/md/raid1.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 69b7730f3875..a70ca6bc28f3 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -2675,24 +2675,22 @@ static void handle_read_error(struct r1conf *conf, struct r1bio *r1_bio)
r1_bio->bios[r1_bio->read_disk] = NULL;
rdev = conf->mirrors[r1_bio->read_disk].rdev;
- if (mddev->ro == 0
- && !test_bit(FailFast, &rdev->flags)) {
+ if (mddev->ro) {
+ r1_bio->bios[r1_bio->read_disk] = IO_BLOCKED;
+ } else if (test_bit(FailFast, &rdev->flags)) {
+ md_error(mddev, rdev);
+ } else {
freeze_array(conf, 1);
fix_read_error(conf, r1_bio);
unfreeze_array(conf);
- } else if (mddev->ro == 0 && test_bit(FailFast, &rdev->flags)) {
- md_error(mddev, rdev);
- } else {
- r1_bio->bios[r1_bio->read_disk] = IO_BLOCKED;
}
rdev_dec_pending(rdev, conf->mddev);
sector = r1_bio->sector;
- bio = r1_bio->master_bio;
/* Reuse the old r1_bio so that the IO_BLOCKED settings are preserved */
r1_bio->state = 0;
- raid1_read_request(mddev, bio, r1_bio->sectors, r1_bio);
+ raid1_read_request(mddev, r1_bio->master_bio, r1_bio->sectors, r1_bio);
allow_barrier(conf, sector);
}
--
2.50.1
next prev parent reply other threads:[~2025-10-27 15:05 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-27 15:04 [PATCH v5 00/16] Don't set MD_BROKEN on failfast bio failure Kenta Akagi
2025-10-27 15:04 ` [PATCH v5 01/16] md: move device_lock from conf to mddev Kenta Akagi
2025-10-30 1:59 ` Yu Kuai
2025-10-27 15:04 ` [PATCH v5 02/16] md: serialize md_error() Kenta Akagi
2025-10-30 2:11 ` Yu Kuai
2025-11-06 17:06 ` Kenta Akagi
2025-10-27 15:04 ` [PATCH v5 03/16] md: add pers->should_error() callback Kenta Akagi
2025-10-30 2:24 ` Yu Kuai
2025-10-27 15:04 ` [PATCH v5 04/16] md: introduce md_cond_error() Kenta Akagi
2025-10-27 15:04 ` [PATCH v5 05/16] md/raid1: implement pers->should_error() Kenta Akagi
2025-10-30 2:31 ` Yu Kuai
2025-10-27 15:04 ` [PATCH v5 06/16] md/raid10: " Kenta Akagi
2025-10-27 15:04 ` Kenta Akagi [this message]
2025-10-30 2:38 ` [PATCH v5 07/16] md/raid1: refactor handle_read_error() Yu Kuai
2025-10-27 15:04 ` [PATCH v5 08/16] md/raid10: " Kenta Akagi
2025-10-30 2:39 ` Yu Kuai
2025-10-27 15:04 ` [PATCH v5 09/16] md/raid10: fix failfast read error not rescheduled Kenta Akagi
2025-10-30 2:41 ` Yu Kuai
2025-10-27 15:04 ` [PATCH v5 10/16] md: prevent set MD_BROKEN on super_write failure with failfast Kenta Akagi
2025-10-27 15:04 ` [PATCH v5 11/16] md/raid1: Prevent set MD_BROKEN on failfast bio failure Kenta Akagi
2025-10-27 15:04 ` [PATCH v5 12/16] md/raid10: " Kenta Akagi
2025-10-27 15:04 ` [PATCH v5 13/16] md/raid1: add error message when setting MD_BROKEN Kenta Akagi
2025-10-27 15:04 ` [PATCH v5 14/16] md/raid10: Add " Kenta Akagi
2025-10-27 15:04 ` [PATCH v5 15/16] md: rename 'LastDev' rdev flag to 'RetryingSBWrite' Kenta Akagi
2025-10-27 15:04 ` [PATCH v5 16/16] md: Improve super_written() error logging Kenta Akagi
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=20251027150433.18193-8-k@mgml.me \
--to=k@mgml.me \
--cc=jgq516@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-raid@vger.kernel.org \
--cc=mtkaczyk@kernel.org \
--cc=shli@fb.com \
--cc=song@kernel.org \
--cc=yukuai@fnnas.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox