[PATCH 8/8] md/raid1: hold write-behind writes that failed on a device
From: Miroslav Cimerman
Date: Thu Nov 26 2026 - 19:33:07 EST
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@xxxxxxxxxxxxxxx
Signed-off-by: Miroslav Cimerman <mc@xxxxxxxxxxx>
---
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