aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2007-08-22 17:01:53 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-08-22 22:52:46 -0400
commita88aa7865bc1d1d451af2d585ac0119164ce8e00 (patch)
tree2ecde2e24540c611f8930bbee94e1e428038f3a1 /drivers/md
parent918f02383fb9ff5dba29709f3199189eeac55021 (diff)
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: Neil Brown <neilb@suse.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/md')
-rw-r--r--drivers/md/raid1.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index ea2a58d28871..f33a729960ca 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -2154,11 +2154,25 @@ static int raid1_reshape(mddev_t *mddev)
2154 oldpool = conf->r1bio_pool; 2154 oldpool = conf->r1bio_pool;
2155 conf->r1bio_pool = newpool; 2155 conf->r1bio_pool = newpool;
2156 2156
2157 for (d=d2=0; d < conf->raid_disks; d++) 2157 for (d = d2 = 0; d < conf->raid_disks; d++) {
2158 if (conf->mirrors[d].rdev) { 2158 mdk_rdev_t *rdev = conf->mirrors[d].rdev;
2159 conf->mirrors[d].rdev->raid_disk = d2; 2159 if (rdev && rdev->raid_disk != d2) {
2160 newmirrors[d2++].rdev = conf->mirrors[d].rdev; 2160 char nm[20];
2161 sprintf(nm, "rd%d", rdev->raid_disk);
2162 sysfs_remove_link(&mddev->kobj, nm);
2163 rdev->raid_disk = d2;
2164 sprintf(nm, "rd%d", rdev->raid_disk);
2165 sysfs_remove_link(&mddev->kobj, nm);
2166 if (sysfs_create_link(&mddev->kobj,
2167 &rdev->kobj, nm))
2168 printk(KERN_WARNING
2169 "md/raid1: cannot register "
2170 "%s for %s\n",
2171 nm, mdname(mddev));
2161 } 2172 }
2173 if (rdev)
2174 newmirrors[d2++].rdev = rdev;
2175 }
2162 kfree(conf->mirrors); 2176 kfree(conf->mirrors);
2163 conf->mirrors = newmirrors; 2177 conf->mirrors = newmirrors;
2164 kfree(conf->poolinfo); 2178 kfree(conf->poolinfo);