Skip to content

Commit 5389042

Browse files
committed
md: change managed of recovery_disabled.
If we hit a read error while recovering a mirror, we want to abort the recovery without necessarily failing the disk - as having a disk this a read error is better than not having an array at all. Currently this is managed with a per-array flag "recovery_disabled" and is only implemented for RAID1. For RAID10 we will need finer grained control as we might want to disable recovery for individual devices separately. So push more of the decision making into the personality. 'recovery_disabled' is now a 'cookie' which is copied when the personality want to disable recovery and is changed when a device is added to the array as this is used as a trigger to 'try recovery again'. This will allow RAID10 to get the control that it needs. Signed-off-by: NeilBrown <neilb@suse.de>
1 parent a478a06 commit 5389042

4 files changed

Lines changed: 19 additions & 7 deletions

File tree

‎drivers/md/md.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1922,7 +1922,7 @@ static int bind_rdev_to_array(mdk_rdev_t * rdev, mddev_t * mddev)
19221922
bd_link_disk_holder(rdev->bdev, mddev->gendisk);
19231923

19241924
/* May as well allow recovery to be retried once */
1925-
mddev->recovery_disabled = 0;
1925+
mddev->recovery_disabled++;
19261926

19271927
return 0;
19281928

@@ -7070,7 +7070,7 @@ static int remove_and_add_spares(mddev_t *mddev)
70707070
}
70717071
}
70727072

7073-
if (mddev->degraded && !mddev->recovery_disabled) {
7073+
if (mddev->degraded) {
70747074
list_for_each_entry(rdev, &mddev->disks, same_set) {
70757075
if (rdev->raid_disk >= 0 &&
70767076
!test_bit(In_sync, &rdev->flags) &&

‎drivers/md/md.h‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,12 @@ struct mddev_s
239239
#define MD_RECOVERY_FROZEN 9
240240

241241
unsigned long recovery;
242-
int recovery_disabled; /* if we detect that recovery
243-
* will always fail, set this
244-
* so we don't loop trying */
242+
/* If a RAID personality determines that recovery (of a particular
243+
* device) will fail due to a read error on the source device, it
244+
* takes a copy of this number and does not attempt recovery again
245+
* until this number changes.
246+
*/
247+
int recovery_disabled;
245248

246249
int in_sync; /* know to not need resync */
247250
/* 'open_mutex' avoids races between 'md_open' and 'do_md_stop', so

‎drivers/md/raid1.c‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -956,7 +956,7 @@ static void error(mddev_t *mddev, mdk_rdev_t *rdev)
956956
* However don't try a recovery from this drive as
957957
* it is very likely to fail.
958958
*/
959-
mddev->recovery_disabled = 1;
959+
conf->recovery_disabled = mddev->recovery_disabled;
960960
return;
961961
}
962962
if (test_and_clear_bit(In_sync, &rdev->flags)) {
@@ -1052,6 +1052,9 @@ static int raid1_add_disk(mddev_t *mddev, mdk_rdev_t *rdev)
10521052
int first = 0;
10531053
int last = mddev->raid_disks - 1;
10541054

1055+
if (mddev->recovery_disabled == conf->recovery_disabled)
1056+
return -EBUSY;
1057+
10551058
if (rdev->raid_disk >= 0)
10561059
first = last = rdev->raid_disk;
10571060

@@ -1107,7 +1110,7 @@ static int raid1_remove_disk(mddev_t *mddev, int number)
11071110
* is not possible.
11081111
*/
11091112
if (!test_bit(Faulty, &rdev->flags) &&
1110-
!mddev->recovery_disabled &&
1113+
mddev->recovery_disabled != conf->recovery_disabled &&
11111114
mddev->degraded < conf->raid_disks) {
11121115
err = -EBUSY;
11131116
goto abort;

‎drivers/md/raid1.h‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ struct r1_private_data_s {
4848
* (fresh device added).
4949
* Cleared when a sync completes.
5050
*/
51+
int recovery_disabled; /* when the same as
52+
* mddev->recovery_disabled
53+
* we don't allow recovery
54+
* to be attempted as we
55+
* expect a read error
56+
*/
5157

5258
wait_queue_head_t wait_barrier;
5359

0 commit comments

Comments
 (0)