Skip to content

Commit c29cfbe

Browse files
YuKuai-huaweiopsiff
authored andcommitted
md/raid1: fix data lost for writemostly rdev
commit 93dec51 upstream. 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 <ian@beware.dropbear.id.au> Closes: https://bugzilla.kernel.org/show_bug.cgi?id=220507 Link: https://lore.kernel.org/linux-raid/20250903014140.3690499-1-yukuai1@huaweicloud.com Signed-off-by: Yu Kuai <yukuai3@huawei.com> Reviewed-by: Li Nan <linan122@huawei.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> (cherry picked from commit deeaba4c54aef36c439071fa6e4a766a14f1a2b7) Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
1 parent f1f0b96 commit c29cfbe

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

drivers/md/raid1.c

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

1122-
behind_bio = bio_alloc_bioset(NULL, vcnt, 0, GFP_NOIO,
1122+
behind_bio = bio_alloc_bioset(NULL, vcnt, bio->bi_opf, GFP_NOIO,
11231123
&r1_bio->mddev->bio_set);
11241124

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

0 commit comments

Comments
 (0)