Skip to content

Commit 1ec4922

Browse files
committed
md/raid1: fix write behind issues introduced by bio_clone_bioset_partial
There are two issues, introduced by commit 8e58e32(md/raid1: use bio_clone_bioset_partial() in case of write behind): - bio_clone_bioset_partial() uses bytes instead of sectors as parameters - in writebehind mode, we return bio if all !writemostly disk bios finish, which could happen before writemostly disk bios run. So all writemostly disk bios should have their bvec. Here we just make sure all bios are cloned instead of fast cloned. Reviewed-by: Ming Lei <[email protected]> Signed-off-by: Shaohua Li <[email protected]>
1 parent aff8da0 commit 1ec4922

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

drivers/md/raid1.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1472,8 +1472,8 @@ static void raid1_write_request(struct mddev *mddev, struct bio *bio)
14721472
!waitqueue_active(&bitmap->behind_wait)) {
14731473
mbio = bio_clone_bioset_partial(bio, GFP_NOIO,
14741474
mddev->bio_set,
1475-
offset,
1476-
max_sectors);
1475+
offset << 9,
1476+
max_sectors << 9);
14771477
alloc_behind_pages(mbio, r1_bio);
14781478
}
14791479

@@ -1485,8 +1485,15 @@ static void raid1_write_request(struct mddev *mddev, struct bio *bio)
14851485
}
14861486

14871487
if (!mbio) {
1488-
mbio = bio_clone_fast(bio, GFP_NOIO, mddev->bio_set);
1489-
bio_trim(mbio, offset, max_sectors);
1488+
if (r1_bio->behind_bvecs)
1489+
mbio = bio_clone_bioset_partial(bio, GFP_NOIO,
1490+
mddev->bio_set,
1491+
offset << 9,
1492+
max_sectors << 9);
1493+
else {
1494+
mbio = bio_clone_fast(bio, GFP_NOIO, mddev->bio_set);
1495+
bio_trim(mbio, offset, max_sectors);
1496+
}
14901497
}
14911498

14921499
if (r1_bio->behind_bvecs) {

0 commit comments

Comments
 (0)