Commit 5e3604168b5994e591db2dece06867a035cd5146

Authored by Jonathan E Brassow
Committed by Greg Kroah-Hartman
1 parent 73b249403d

dm raid: set MD_CHANGE_DEVS when rebuilding

commit 3aa3b2b2b1edb813dc5342d0108befc39541542d upstream.

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>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Showing 1 changed file with 10 additions and 6 deletions Side-by-side Diff

drivers/md/dm-raid.c
... ... @@ -667,7 +667,14 @@
667 667 return ret;
668 668  
669 669 sb = page_address(rdev->sb_page);
670   - if (sb->magic != cpu_to_le32(DM_RAID_MAGIC)) {
  670 +
  671 + /*
  672 + * Two cases that we want to write new superblocks and rebuild:
  673 + * 1) New device (no matching magic number)
  674 + * 2) Device specified for rebuild (!In_sync w/ offset == 0)
  675 + */
  676 + if ((sb->magic != cpu_to_le32(DM_RAID_MAGIC)) ||
  677 + (!test_bit(In_sync, &rdev->flags) && !rdev->recovery_offset)) {
671 678 super_sync(rdev->mddev, rdev);
672 679  
673 680 set_bit(FirstUse, &rdev->flags);
... ... @@ -744,11 +751,8 @@
744 751 */
745 752 rdev_for_each(r, t, mddev) {
746 753 if (!test_bit(In_sync, &r->flags)) {
747   - if (!test_bit(FirstUse, &r->flags))
748   - DMERR("Superblock area of "
749   - "rebuild device %d should have been "
750   - "cleared.", r->raid_disk);
751   - set_bit(FirstUse, &r->flags);
  754 + DMINFO("Device %d specified for rebuild: "
  755 + "Clearing superblock", r->raid_disk);
752 756 rebuilds++;
753 757 } else if (test_bit(FirstUse, &r->flags))
754 758 new_devs++;