]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
md: correctly update sysfs when a raid1 is reshaped
authorNeilBrown <neilb@suse.de>
Wed, 22 Aug 2007 21:01:53 +0000 (14:01 -0700)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Thu, 23 Aug 2007 02:52:46 +0000 (19:52 -0700)
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>
drivers/md/raid1.c

index ea2a58d28871acd030c03eafbbf86824ca2a7751..f33a729960ca3f58e4fd618605ca1c197523ef11 100644 (file)
@@ -2154,11 +2154,25 @@ static int raid1_reshape(mddev_t *mddev)
        oldpool = conf->r1bio_pool;
        conf->r1bio_pool = newpool;
 
-       for (d=d2=0; d < conf->raid_disks; d++)
-               if (conf->mirrors[d].rdev) {
-                       conf->mirrors[d].rdev->raid_disk = d2;
-                       newmirrors[d2++].rdev = conf->mirrors[d].rdev;
+       for (d = d2 = 0; d < conf->raid_disks; d++) {
+               mdk_rdev_t *rdev = conf->mirrors[d].rdev;
+               if (rdev && rdev->raid_disk != d2) {
+                       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);
        conf->mirrors = newmirrors;
        kfree(conf->poolinfo);