From: Song Liu Date: Mon, 13 Mar 2017 20:44:35 +0000 (-0700) Subject: md/r5cache: fix set_syndrome_sources() for data in cache X-Git-Tag: v4.10.6~19 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3e037a0fe0b67412eb743c66d22394dca18e6d54;p=thirdparty%2Fkernel%2Fstable.git md/r5cache: fix set_syndrome_sources() for data in cache commit 0977762f6d15f13caccc20d71a5dec47d098907d upstream. Before this patch, device InJournal will be included in prexor (SYNDROME_SRC_WANT_DRAIN) but not in reconstruct (SYNDROME_SRC_WRITTEN). So it will break parity calculation. With srctype == SYNDROME_SRC_WRITTEN, we need include both dev with non-null ->written and dev with R5_InJournal. This fixes logic in 1e6d690(md/r5cache: caching phase of r5cache) Signed-off-by: Song Liu Signed-off-by: Shaohua Li Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index 3c7e106c12a24..6661db2c85f00 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c @@ -1364,7 +1364,8 @@ static int set_syndrome_sources(struct page **srcs, (test_bit(R5_Wantdrain, &dev->flags) || test_bit(R5_InJournal, &dev->flags))) || (srctype == SYNDROME_SRC_WRITTEN && - dev->written)) { + (dev->written || + test_bit(R5_InJournal, &dev->flags)))) { if (test_bit(R5_InJournal, &dev->flags)) srcs[slot] = sh->dev[i].orig_page; else