summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorShaohua Li <shli@fb.com>2018-10-01 18:36:36 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-11-13 11:08:35 -0800
commit6596e997745c4b434b688e9d4c6f737648efd981 (patch)
tree57d12cdcbf1fb6ee63a6f9f3b354f51d1ec947ee /drivers
parent3d267c56c75c9304d0b6cc9d0f129fbf4a835b07 (diff)
MD: fix invalid stored role for a disk
[ Upstream commit d595567dc4f0c1d90685ec1e2e296e2cad2643ac ] If we change the number of array's device after device is removed from array, then add the device back to array, we can see that device is added as active role instead of spare which we expected. Please see the below link for details: https://marc.info/?l=linux-raid&m=153736982015076&w=2 This is caused by that we prefer to use device's previous role which is recorded by saved_raid_disk, but we should respect the new number of conf->raid_disks since it could be changed after device is removed. Reported-by: Gioh Kim <gi-oh.kim@profitbricks.com> Tested-by: Gioh Kim <gi-oh.kim@profitbricks.com> Acked-by: Guoqing Jiang <gqjiang@suse.com> Signed-off-by: Shaohua Li <shli@fb.com> Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/md/md.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 8668793262d0..85459c17cc60 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -1776,6 +1776,10 @@ static int super_1_validate(struct mddev *mddev, struct md_rdev *rdev)
} else
set_bit(In_sync, &rdev->flags);
rdev->raid_disk = role;
+ if (role >= mddev->raid_disks) {
+ rdev->saved_raid_disk = -1;
+ rdev->raid_disk = -1;
+ }
break;
}
if (sb->devflags & WriteMostly1)