Skip to content

Commit 1a67dde

Browse files
committed
md/raid5: Properly remove excess drives after shrinking a raid5/6
We were removing the drives, from the array, but not removing symlinks from /sys/.... and not marking the device as having been removed. Signed-off-by: NeilBrown <[email protected]>
1 parent a639755 commit 1a67dde

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

drivers/md/raid5.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5097,8 +5097,15 @@ static void raid5_finish_reshape(mddev_t *mddev)
50975097
mddev->degraded--;
50985098
for (d = conf->raid_disks ;
50995099
d < conf->raid_disks - mddev->delta_disks;
5100-
d++)
5101-
raid5_remove_disk(mddev, d);
5100+
d++) {
5101+
mdk_rdev_t *rdev = conf->disks[d].rdev;
5102+
if (rdev && raid5_remove_disk(mddev, d) == 0) {
5103+
char nm[20];
5104+
sprintf(nm, "rd%d", rdev->raid_disk);
5105+
sysfs_remove_link(&mddev->kobj, nm);
5106+
rdev->raid_disk = -1;
5107+
}
5108+
}
51025109
}
51035110
mddev->layout = conf->algorithm;
51045111
mddev->chunk_sectors = conf->chunk_sectors;

0 commit comments

Comments
 (0)