diff options
author | Shaohua Li <shli@fb.com> | 2018-10-14 20:05:07 -0400 |
---|---|---|
committer | Shaohua Li <shli@fb.com> | 2018-10-14 20:05:07 -0400 |
commit | 9e753ba9b9b405e3902d9f08aec5f2ea58a0c317 (patch) | |
tree | e13775c41d767d74ea43520db9d064829f7a133b /drivers/md | |
parent | f8f83d8ffeb47041ff0937ecac6d10bcb388cd9f (diff) |
MD: fix invalid stored role for a disk - try2
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>
Diffstat (limited to 'drivers/md')
-rw-r--r-- | drivers/md/md.c | 4 | ||||
-rw-r--r-- | drivers/md/raid1.c | 1 | ||||
-rw-r--r-- | drivers/md/raid10.c | 1 |
3 files changed, 2 insertions, 4 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c index 62bf96daa157..4c0f3e0331d5 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c | |||
@@ -1774,10 +1774,6 @@ static int super_1_validate(struct mddev *mddev, struct md_rdev *rdev) | |||
1774 | } else | 1774 | } else |
1775 | set_bit(In_sync, &rdev->flags); | 1775 | set_bit(In_sync, &rdev->flags); |
1776 | rdev->raid_disk = role; | 1776 | rdev->raid_disk = role; |
1777 | if (role >= mddev->raid_disks) { | ||
1778 | rdev->saved_raid_disk = -1; | ||
1779 | rdev->raid_disk = -1; | ||
1780 | } | ||
1781 | break; | 1777 | break; |
1782 | } | 1778 | } |
1783 | if (sb->devflags & WriteMostly1) | 1779 | if (sb->devflags & WriteMostly1) |
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 4e990246225e..1d54109071cc 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c | |||
@@ -1734,6 +1734,7 @@ static int raid1_add_disk(struct mddev *mddev, struct md_rdev *rdev) | |||
1734 | */ | 1734 | */ |
1735 | if (rdev->saved_raid_disk >= 0 && | 1735 | if (rdev->saved_raid_disk >= 0 && |
1736 | rdev->saved_raid_disk >= first && | 1736 | rdev->saved_raid_disk >= first && |
1737 | rdev->saved_raid_disk < conf->raid_disks && | ||
1737 | conf->mirrors[rdev->saved_raid_disk].rdev == NULL) | 1738 | conf->mirrors[rdev->saved_raid_disk].rdev == NULL) |
1738 | first = last = rdev->saved_raid_disk; | 1739 | first = last = rdev->saved_raid_disk; |
1739 | 1740 | ||
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index 749848b2c477..a52f43b151b5 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) | |||
1808 | first = last = rdev->raid_disk; | 1808 | first = last = rdev->raid_disk; |
1809 | 1809 | ||
1810 | if (rdev->saved_raid_disk >= first && | 1810 | if (rdev->saved_raid_disk >= first && |
1811 | rdev->saved_raid_disk < conf->geo.raid_disks && | ||
1811 | conf->mirrors[rdev->saved_raid_disk].rdev == NULL) | 1812 | conf->mirrors[rdev->saved_raid_disk].rdev == NULL) |
1812 | mirror = rdev->saved_raid_disk; | 1813 | mirror = rdev->saved_raid_disk; |
1813 | else | 1814 | else |