Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

md: do not compute parity unless it is on a failed drive

If a block is computed (rather than read) then a check/repair operation
may be lead to believe that the data on disk is correct, when infact it
isn't. So only compute blocks for failed devices.

This issue has been around since at least 2.6.12, but has become harder to
hit in recent kernels since most reads bypass the cache.

echo repair > /sys/block/mdN/md/sync_action will set the parity blocks to the
correct state.

Cc: <stable@kernel.org>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
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>

authored by

Dan Williams and committed by
Linus Torvalds
c337869d a6d8113a

+4 -1
+4 -1
drivers/md/raid5.c
··· 2002 2002 * have quiesced. 2003 2003 */ 2004 2004 if ((s->uptodate == disks - 1) && 2005 + (s->failed && disk_idx == s->failed_num) && 2005 2006 !test_bit(STRIPE_OP_CHECK, &sh->ops.pending)) { 2006 2007 set_bit(STRIPE_OP_COMPUTE_BLK, &sh->ops.pending); 2007 2008 set_bit(R5_Wantcompute, &dev->flags); ··· 2088 2087 /* we would like to get this block, possibly 2089 2088 * by computing it, but we might not be able to 2090 2089 */ 2091 - if (s->uptodate == disks-1) { 2090 + if ((s->uptodate == disks - 1) && 2091 + (s->failed && (i == r6s->failed_num[0] || 2092 + i == r6s->failed_num[1]))) { 2092 2093 pr_debug("Computing stripe %llu block %d\n", 2093 2094 (unsigned long long)sh->sector, i); 2094 2095 compute_block_1(sh, i, 0);