[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250903014140.3690499-1-yukuai1@huaweicloud.com>
Date: Wed, 3 Sep 2025 09:41:40 +0800
From: Yu Kuai <yukuai1@...weicloud.com>
To: song@...nel.org,
ian@...are.dropbear.id.au
Cc: linux-raid@...r.kernel.org,
linux-kernel@...r.kernel.org,
yukuai3@...wei.com,
yukuai1@...weicloud.com,
yi.zhang@...wei.com,
yangerkun@...wei.com,
johnny.chenyi@...wei.com
Subject: [PATCH] md/raid1: fix data lost for writemostly rdev
From: Yu Kuai <yukuai3@...wei.com>
If writemostly is enabled, alloc_behind_master_bio() will allocate a new
bio for rdev, with bi_opf set to 0. Later, raid1_write_request() will
clone from this bio, hence bi_opf is still 0 for the cloned bio. Submit
this cloned bio will end up to be read, causing write data lost.
Fix this problem by inheriting bi_opf from original bio for
behind_mast_bio.
Fixes: e879a0d9cb08 ("md/raid1,raid10: don't ignore IO flags")
Reported-and-tested-by: Ian Dall <ian@...are.dropbear.id.au>
Closes: https://bugzilla.kernel.org/show_bug.cgi?id=220507
Signed-off-by: Yu Kuai <yukuai3@...wei.com>
---
drivers/md/raid1.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index f8434049f9b1..f391fd56d67f 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -1225,7 +1225,7 @@ static void alloc_behind_master_bio(struct r1bio *r1_bio,
int i = 0;
struct bio *behind_bio = NULL;
- behind_bio = bio_alloc_bioset(NULL, vcnt, 0, GFP_NOIO,
+ behind_bio = bio_alloc_bioset(NULL, vcnt, bio->bi_opf, GFP_NOIO,
&r1_bio->mddev->bio_set);
/* discard op, we don't support writezero/writesame yet */
--
2.39.2
Powered by blists - more mailing lists