Skip to content

Commit 50faba7

Browse files
committed
Merge tag 'md-6.11-20240815' of https://git.kernel.org/pub/scm/linux/kernel/git/song/md into block-6.11
Pull MD fix from Song: "This patch fixes a potential data corruption in degraded raid0 array with slow (WriteMostly) drives. This issue was introduced in upstream 6.9 kernel." * tag 'md-6.11-20240815' of https://git.kernel.org/pub/scm/linux/kernel/git/song/md: md/raid1: Fix data corruption for degraded array with slow disk
2 parents 7db4042 + c916ca3 commit 50faba7

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

drivers/md/raid1.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,12 @@ static int choose_first_rdev(struct r1conf *conf, struct r1bio *r1_bio,
617617
return -1;
618618
}
619619

620+
static bool rdev_in_recovery(struct md_rdev *rdev, struct r1bio *r1_bio)
621+
{
622+
return !test_bit(In_sync, &rdev->flags) &&
623+
rdev->recovery_offset < r1_bio->sector + r1_bio->sectors;
624+
}
625+
620626
static int choose_bb_rdev(struct r1conf *conf, struct r1bio *r1_bio,
621627
int *max_sectors)
622628
{
@@ -635,6 +641,7 @@ static int choose_bb_rdev(struct r1conf *conf, struct r1bio *r1_bio,
635641

636642
rdev = conf->mirrors[disk].rdev;
637643
if (!rdev || test_bit(Faulty, &rdev->flags) ||
644+
rdev_in_recovery(rdev, r1_bio) ||
638645
test_bit(WriteMostly, &rdev->flags))
639646
continue;
640647

@@ -673,7 +680,8 @@ static int choose_slow_rdev(struct r1conf *conf, struct r1bio *r1_bio,
673680

674681
rdev = conf->mirrors[disk].rdev;
675682
if (!rdev || test_bit(Faulty, &rdev->flags) ||
676-
!test_bit(WriteMostly, &rdev->flags))
683+
!test_bit(WriteMostly, &rdev->flags) ||
684+
rdev_in_recovery(rdev, r1_bio))
677685
continue;
678686

679687
/* there are no bad blocks, we can use this disk */
@@ -733,9 +741,7 @@ static bool rdev_readable(struct md_rdev *rdev, struct r1bio *r1_bio)
733741
if (!rdev || test_bit(Faulty, &rdev->flags))
734742
return false;
735743

736-
/* still in recovery */
737-
if (!test_bit(In_sync, &rdev->flags) &&
738-
rdev->recovery_offset < r1_bio->sector + r1_bio->sectors)
744+
if (rdev_in_recovery(rdev, r1_bio))
739745
return false;
740746

741747
/* don't read from slow disk unless have to */

0 commit comments

Comments
 (0)