Commit 93be75ff authored by NeilBrown's avatar NeilBrown

md: integrate spares into array at earliest opportunity.

As v1.x metadata can record that a member of the array is
not completely recovered, it make sense to record that a
spare has become a regular member of the array at the earliest
opportunity.
So remove the tests on "recovery_offset > 0" in super_1_sync
as they really aren't needed, and schedule a metadata update
immediately after adding spares to a degraded array.

This means that if a crash happens immediately after a recovery
starts, the new device will be included in the array and recovery will
continue from wherever it was up to.  Previously this didn't happen
unless recovery was at least 1/16 of the way through.
Signed-off-by: default avatarNeilBrown <neilb@suse.de>
parent aa98aa31
...@@ -1508,12 +1508,10 @@ static void super_1_sync(mddev_t *mddev, mdk_rdev_t *rdev) ...@@ -1508,12 +1508,10 @@ static void super_1_sync(mddev_t *mddev, mdk_rdev_t *rdev)
if (rdev->raid_disk >= 0 && if (rdev->raid_disk >= 0 &&
!test_bit(In_sync, &rdev->flags)) { !test_bit(In_sync, &rdev->flags)) {
if (rdev->recovery_offset > 0) { sb->feature_map |=
sb->feature_map |= cpu_to_le32(MD_FEATURE_RECOVERY_OFFSET);
cpu_to_le32(MD_FEATURE_RECOVERY_OFFSET); sb->recovery_offset =
sb->recovery_offset = cpu_to_le64(rdev->recovery_offset);
cpu_to_le64(rdev->recovery_offset);
}
} }
if (mddev->reshape_position != MaxSector) { if (mddev->reshape_position != MaxSector) {
...@@ -1547,7 +1545,7 @@ static void super_1_sync(mddev_t *mddev, mdk_rdev_t *rdev) ...@@ -1547,7 +1545,7 @@ static void super_1_sync(mddev_t *mddev, mdk_rdev_t *rdev)
sb->dev_roles[i] = cpu_to_le16(0xfffe); sb->dev_roles[i] = cpu_to_le16(0xfffe);
else if (test_bit(In_sync, &rdev2->flags)) else if (test_bit(In_sync, &rdev2->flags))
sb->dev_roles[i] = cpu_to_le16(rdev2->raid_disk); sb->dev_roles[i] = cpu_to_le16(rdev2->raid_disk);
else if (rdev2->raid_disk >= 0 && rdev2->recovery_offset > 0) else if (rdev2->raid_disk >= 0)
sb->dev_roles[i] = cpu_to_le16(rdev2->raid_disk); sb->dev_roles[i] = cpu_to_le16(rdev2->raid_disk);
else else
sb->dev_roles[i] = cpu_to_le16(0xffff); sb->dev_roles[i] = cpu_to_le16(0xffff);
...@@ -6786,6 +6784,7 @@ static int remove_and_add_spares(mddev_t *mddev) ...@@ -6786,6 +6784,7 @@ static int remove_and_add_spares(mddev_t *mddev)
nm, mdname(mddev)); nm, mdname(mddev));
spares++; spares++;
md_new_event(mddev); md_new_event(mddev);
set_bit(MD_CHANGE_DEVS, &mddev->flags);
} else } else
break; break;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment