aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/dm-raid.c
diff options
context:
space:
mode:
authorJonathan E Brassow <jbrassow@redhat.com>2012-03-07 14:09:47 -0500
committerAlasdair G Kergon <agk@redhat.com>2012-03-07 14:09:47 -0500
commit3aa3b2b2b1edb813dc5342d0108befc39541542d (patch)
tree151000a59d089231fcefbf44539c89ee56436c84 /drivers/md/dm-raid.c
parentaf63bcb817cf708f53bcae6edc2e3fb7dd7d8051 (diff)
dm raid: set MD_CHANGE_DEVS when rebuilding
The 'rebuild' parameter is used to rebuild individual devices in an array (e.g. resynchronize a RAID1 device or recalculate a parity device in higher RAID). The MD_CHANGE_DEVS flag must be set when this parameter is given in order to write out the superblocks and make the change take immediate effect. The code that handles new devices in super_load already sets MD_CHANGE_DEVS and 'FirstUse'. (The 'FirstUse' flag was being set as a special case for rebuilds in super_init_validation.) Add a condition for rebuilds in super_load to take care of both flags without the special case in 'super_init_validation'. Signed-off-by: Jonathan Brassow <jbrassow@redhat.com> Cc: stable@kernel.org Signed-off-by: Alasdair G Kergon <agk@redhat.com>
Diffstat (limited to 'drivers/md/dm-raid.c')
-rw-r--r--drivers/md/dm-raid.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/drivers/md/dm-raid.c b/drivers/md/dm-raid.c
index 86cb7e5d83d5..f53bb389c18f 100644
--- a/drivers/md/dm-raid.c
+++ b/drivers/md/dm-raid.c
@@ -668,7 +668,14 @@ static int super_load(struct md_rdev *rdev, struct md_rdev *refdev)
668 return ret; 668 return ret;
669 669
670 sb = page_address(rdev->sb_page); 670 sb = page_address(rdev->sb_page);
671 if (sb->magic != cpu_to_le32(DM_RAID_MAGIC)) { 671
672 /*
673 * Two cases that we want to write new superblocks and rebuild:
674 * 1) New device (no matching magic number)
675 * 2) Device specified for rebuild (!In_sync w/ offset == 0)
676 */
677 if ((sb->magic != cpu_to_le32(DM_RAID_MAGIC)) ||
678 (!test_bit(In_sync, &rdev->flags) && !rdev->recovery_offset)) {
672 super_sync(rdev->mddev, rdev); 679 super_sync(rdev->mddev, rdev);
673 680
674 set_bit(FirstUse, &rdev->flags); 681 set_bit(FirstUse, &rdev->flags);
@@ -745,11 +752,8 @@ static int super_init_validation(struct mddev *mddev, struct md_rdev *rdev)
745 */ 752 */
746 rdev_for_each(r, t, mddev) { 753 rdev_for_each(r, t, mddev) {
747 if (!test_bit(In_sync, &r->flags)) { 754 if (!test_bit(In_sync, &r->flags)) {
748 if (!test_bit(FirstUse, &r->flags)) 755 DMINFO("Device %d specified for rebuild: "
749 DMERR("Superblock area of " 756 "Clearing superblock", r->raid_disk);
750 "rebuild device %d should have been "
751 "cleared.", r->raid_disk);
752 set_bit(FirstUse, &r->flags);
753 rebuilds++; 757 rebuilds++;
754 } else if (test_bit(FirstUse, &r->flags)) 758 } else if (test_bit(FirstUse, &r->flags))
755 new_devs++; 759 new_devs++;