md: bug fixes for 2.6.23-rc
PATCH 1/1 md: bug fixes for 2.6.23-rc
Following 2 patches contain bugfixes for md. Both apply to earlier kernels, but probably aren't significant enough for -stable (no oops, no data corruption, no security hole).
They should go in 2.6.23 though.
Thanks,
NeilBrown
[PATCH 001 of 2] md: Make sure a re-add after a restart honours bitmap when resyncing. [PATCH 002 of 2] md: Correctly update sysfs when a raid1 is reshaped.
PATCH 1/1 md: Make sure a re-add after a restart honours bitmap when resyncing.
Commit 1757128438d41670ded8bc3bc735325cc07dc8f9 was slightly bad. If an array has a write-intent bitmap, and you remove a drive, then readd it, only the changed parts should be resynced. However after the above commit, this only works if the array has not been shut down and restarted.
This is because it sets 'fullsync' at little more often than it should. This patch is more careful.
### Diffstat output
./drivers/md/raid1.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/md/raid1.c +2 -1
@@ -1972,7 +1972,8 @@ static int run(mddev_t *mddev) !test_bit(In_sync, &disk->rdev->flags)) { disk->head_position =0 ; mddev->degraded++; - conf->fullsync =1 ; +if (disk->rdev) + conf->fullsync =1 ; } }if (mddev->degraded == conf->raid_disks) {
PATCH 1/1 md: Correctly update sysfs when a raid1 is reshaped.
In reply to NeilBrownWhen 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.
### Diffstat output
./drivers/md/raid1.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-)
drivers/md/raid1.c +18 -4
@@ -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);