Home Home > GIT Browse
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShaohua Li <shli@fb.com>2018-10-14 17:05:07 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-11-13 11:12:59 -0800
commit5c4f8ea1f31301875411a3b6d18e03ae99864d0e (patch)
tree6a6471a6021d7de9ba057ce13d0be2647efc8f23
parentddf734ede053ad9cf1e9555b63cb00dccbf144cf (diff)
MD: fix invalid stored role for a disk - try2
commit 9e753ba9b9b405e3902d9f08aec5f2ea58a0c317 upstream. Commit d595567dc4f0 (MD: fix invalid stored role for a disk) broke linear hotadd. Let's only fix the role for disks in raid1/10. Based on Guoqing's original patch. Reported-by: kernel test robot <rong.a.chen@intel.com> Cc: Gioh Kim <gi-oh.kim@profitbricks.com> Cc: Guoqing Jiang <gqjiang@suse.com> Signed-off-by: Shaohua Li <shli@fb.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/md/md.c4
-rw-r--r--drivers/md/raid1.c1
-rw-r--r--drivers/md/raid10.c1
3 files changed, 2 insertions, 4 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 5db14846693d..71665e2c30eb 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -1779,10 +1779,6 @@ 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)
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 8e05c1092aef..c9362463d266 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -1736,6 +1736,7 @@ static int raid1_add_disk(struct mddev *mddev, struct md_rdev *rdev)
*/
if (rdev->saved_raid_disk >= 0 &&
rdev->saved_raid_disk >= first &&
+ rdev->saved_raid_disk < conf->raid_disks &&
conf->mirrors[rdev->saved_raid_disk].rdev == NULL)
first = last = rdev->saved_raid_disk;
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 8c93d44a052c..e555221fb75b 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -1808,6 +1808,7 @@ static int raid10_add_disk(struct mddev *mddev, struct md_rdev *rdev)
first = last = rdev->raid_disk;
if (rdev->saved_raid_disk >= first &&
+ rdev->saved_raid_disk < conf->geo.raid_disks &&
conf->mirrors[rdev->saved_raid_disk].rdev == NULL)
mirror = rdev->saved_raid_disk;
else