Skip to content

Commit 93dec51

Browse files
committed
md/raid1: fix data lost for writemostly rdev
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: e879a0d ("md/raid1,raid10: don't ignore IO flags") Reported-and-tested-by: Ian Dall <[email protected]> Closes: https://bugzilla.kernel.org/show_bug.cgi?id=220507 Link: https://lore.kernel.org/linux-raid/[email protected] Signed-off-by: Yu Kuai <[email protected]> Reviewed-by: Li Nan <[email protected]>
1 parent 95a7c50 commit 93dec51

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/md/raid1.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1225,7 +1225,7 @@ static void alloc_behind_master_bio(struct r1bio *r1_bio,
12251225
int i = 0;
12261226
struct bio *behind_bio = NULL;
12271227

1228-
behind_bio = bio_alloc_bioset(NULL, vcnt, 0, GFP_NOIO,
1228+
behind_bio = bio_alloc_bioset(NULL, vcnt, bio->bi_opf, GFP_NOIO,
12291229
&r1_bio->mddev->bio_set);
12301230

12311231
/* discard op, we don't support writezero/writesame yet */

0 commit comments

Comments
 (0)