Commit a88aa786 authored by NeilBrown's avatar NeilBrown Committed by Linus Torvalds

md: correctly update sysfs when a raid1 is reshaped

When a raid1 array is reshaped (number of drives changed), the list of devices
is compacted, so that slots for missing devices are filled with working
devices from later slots.  This requires the "rd%d" symlinks in sysfs to be
updated.
Signed-off-by: default avatarNeil Brown <neilb@suse.de>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 918f0238
...@@ -2154,11 +2154,25 @@ static int raid1_reshape(mddev_t *mddev) ...@@ -2154,11 +2154,25 @@ static int raid1_reshape(mddev_t *mddev)
oldpool = conf->r1bio_pool; oldpool = conf->r1bio_pool;
conf->r1bio_pool = newpool; conf->r1bio_pool = newpool;
for (d=d2=0; d < conf->raid_disks; d++) for (d = d2 = 0; d < conf->raid_disks; d++) {
if (conf->mirrors[d].rdev) { mdk_rdev_t *rdev = conf->mirrors[d].rdev;
conf->mirrors[d].rdev->raid_disk = d2; if (rdev && rdev->raid_disk != d2) {
newmirrors[d2++].rdev = conf->mirrors[d].rdev; char nm[20];
sprintf(nm, "rd%d", rdev->raid_disk);
sysfs_remove_link(&mddev->kobj, nm);
rdev->raid_disk = d2;
sprintf(nm, "rd%d", rdev->raid_disk);
sysfs_remove_link(&mddev->kobj, nm);
if (sysfs_create_link(&mddev->kobj,
&rdev->kobj, nm))
printk(KERN_WARNING
"md/raid1: cannot register "
"%s for %s\n",
nm, mdname(mddev));
} }
if (rdev)
newmirrors[d2++].rdev = rdev;
}
kfree(conf->mirrors); kfree(conf->mirrors);
conf->mirrors = newmirrors; conf->mirrors = newmirrors;
kfree(conf->poolinfo); kfree(conf->poolinfo);
......
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