From: Miroslav Cimerman <mc@raidlab.org>
To: Song Liu <song@kernel.org>, Yu Kuai <yukuai@fygo.io>
Cc: Li Nan <magiclinan@didiglobal.com>, Xiao Ni <xiao@kernel.org>,
NeilBrown <neil@brown.name>,
Mariusz Tkaczyk <mtkaczyk@kernel.org>, Kenta Akagi <k@mgml.me>,
linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 8/8] md/raid1: hold write-behind writes that failed on a device
Date: Fri, 27 Nov 2026 00:32:31 +0000 [thread overview]
Message-ID: <20261127003231.1180197-9-mc@raidlab.org> (raw)
In-Reply-To: <20261127003231.1180197-1-mc@raidlab.org>
With write-behind, raid1_end_write_request() completes the master bio
once only write-mostly copies are outstanding and one copy succeeded,
even if another copy failed. The write then completes before the
superblock records that failure.
Do not complete the master bio early when R1BIO_WriteError is set.
Fixes: 55ce74d4bfe1 ("md/raid1: ensure device failure recorded before write request returns.")
Cc: stable@vger.kernel.org
Signed-off-by: Miroslav Cimerman <mc@raidlab.org>
---
drivers/md/raid1.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 508673e8c02e..8c4ca1b0f18c 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -541,10 +541,12 @@ static void raid1_end_write_request(struct bio *bio)
* has safely reached all non-writemostly
* disks. Setting the Returned bit ensures that this
* gets done only once -- we don't ever want to return
- * -EIO here, instead we'll wait
+ * -EIO here, instead we'll wait. A write with a failed
+ * copy is held.
*/
if (atomic_read(&r1_bio->behind_remaining) >= (atomic_read(&r1_bio->remaining)-1) &&
- test_bit(R1BIO_Uptodate, &r1_bio->state)) {
+ test_bit(R1BIO_Uptodate, &r1_bio->state) &&
+ !test_bit(R1BIO_WriteError, &r1_bio->state)) {
/* Maybe we can return now */
if (!test_and_set_bit(R1BIO_Returned, &r1_bio->state)) {
struct bio *mbio = r1_bio->master_bio;
--
2.53.0
prev parent reply other threads:[~2026-11-27 0:32 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-27 0:32 [PATCH 0/8] md/raid1,raid10: fix writes acknowledged before a failure is recorded Miroslav Cimerman
2026-11-27 0:32 ` [PATCH 1/8] md/raid1,raid10: fail held writes when the array fails Miroslav Cimerman
2026-11-27 0:32 ` [PATCH 2/8] md/raid10: wait for the devices of the write in wait_blocked_dev() Miroslav Cimerman
2026-11-27 0:32 ` [PATCH 3/8] md/raid1,raid10: fail writes that waited while the array failed Miroslav Cimerman
2026-11-27 0:32 ` [PATCH 4/8] md/raid1,raid10: fail held writes that no working device has Miroslav Cimerman
2026-11-27 0:32 ` [PATCH 5/8] md/raid1,raid10: hold writes that fail on a faulty device Miroslav Cimerman
2026-11-27 0:32 ` [PATCH 6/8] md/raid1: set MD_SB_CHANGE_PENDING under device_lock in raid1_error() Miroslav Cimerman
2026-11-27 0:32 ` [PATCH 7/8] md/raid1,raid10: hold writes that skip a newly failed device Miroslav Cimerman
2026-11-27 0:32 ` Miroslav Cimerman [this message]
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=20261127003231.1180197-9-mc@raidlab.org \
--to=mc@raidlab.org \
--cc=k@mgml.me \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-raid@vger.kernel.org \
--cc=magiclinan@didiglobal.com \
--cc=mtkaczyk@kernel.org \
--cc=neil@brown.name \
--cc=song@kernel.org \
--cc=xiao@kernel.org \
--cc=yukuai@fygo.io \
/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
all inboxes | Powered by JetHome®