Skip to content

Commit 61e4947

Browse files
ldorauneilbrown
authored andcommitted
md: Fix skipping recovery for read-only arrays.
Since: commit 7ceb17e md: Allow devices to be re-added to a read-only array. spares are activated on a read-only array. In case of raid1 and raid10 personalities it causes that not-in-sync devices are marked in-sync without checking if recovery has been finished. If a read-only array is degraded and one of its devices is not in-sync (because the array has been only partially recovered) recovery will be skipped. This patch adds checking if recovery has been finished before marking a device in-sync for raid1 and raid10 personalities. In case of raid5 personality such condition is already present (at raid5.c:6029). Bug was introduced in 3.10 and causes data corruption. Cc: [email protected] Signed-off-by: Pawel Baldysiak <[email protected]> Signed-off-by: Lukasz Dorau <[email protected]> Signed-off-by: NeilBrown <[email protected]>
1 parent 320437a commit 61e4947

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

drivers/md/raid1.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1479,6 +1479,7 @@ static int raid1_spare_active(struct mddev *mddev)
14791479
}
14801480
}
14811481
if (rdev
1482+
&& rdev->recovery_offset == MaxSector
14821483
&& !test_bit(Faulty, &rdev->flags)
14831484
&& !test_and_set_bit(In_sync, &rdev->flags)) {
14841485
count++;

drivers/md/raid10.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1782,6 +1782,7 @@ static int raid10_spare_active(struct mddev *mddev)
17821782
}
17831783
sysfs_notify_dirent_safe(tmp->replacement->sysfs_state);
17841784
} else if (tmp->rdev
1785+
&& tmp->rdev->recovery_offset == MaxSector
17851786
&& !test_bit(Faulty, &tmp->rdev->flags)
17861787
&& !test_and_set_bit(In_sync, &tmp->rdev->flags)) {
17871788
count++;

0 commit comments

Comments
 (0)