md/raid10: don't clear bitmap during recovery if array will still be degraded.

If we have a raid10 with multiple missing devices, and we recover just
one of these to a spare, then we risk (depending on the bitmap and
array chunk size) clearing bits of the bitmap for which recovery isn't
complete (because a device is still missing).

This can lead to a subsequent "re-add" being recovered without
any IO happening, which would result in loss of data.

This patch takes the safe approach of not clearing bitmap bits
if the array will still be degraded.

This patch is suitable for all active -stable kernels.

Cc: stable@kernel.org
Signed-off-by: NeilBrown <neilb@suse.de>

NeilBrown 18055569 b74fd282

+6 -6
+6 -6
drivers/md/raid10.c
··· 1809 r10_bio->sector = sect; 1810 1811 raid10_find_phys(conf, r10_bio); 1812 - /* Need to check if this section will still be 1813 * degraded 1814 */ 1815 - for (j=0; j<conf->copies;j++) { 1816 - int d = r10_bio->devs[j].devnum; 1817 - if (conf->mirrors[d].rdev == NULL || 1818 - test_bit(Faulty, &conf->mirrors[d].rdev->flags)) { 1819 still_degraded = 1; 1820 break; 1821 } 1822 - } 1823 must_sync = bitmap_start_sync(mddev->bitmap, sect, 1824 &sync_blocks, still_degraded); 1825
··· 1809 r10_bio->sector = sect; 1810 1811 raid10_find_phys(conf, r10_bio); 1812 + 1813 + /* Need to check if the array will still be 1814 * degraded 1815 */ 1816 + for (j=0; j<conf->raid_disks; j++) 1817 + if (conf->mirrors[j].rdev == NULL || 1818 + test_bit(Faulty, &conf->mirrors[j].rdev->flags)) { 1819 still_degraded = 1; 1820 break; 1821 } 1822 + 1823 must_sync = bitmap_start_sync(mddev->bitmap, sect, 1824 &sync_blocks, still_degraded); 1825