Blame SOURCES/imsm-don-t-skip-resync-when-an-invalid-ppl-header-is.patch

b7f731
From b23d07503d5940086ea0884d09a737ccb0a9e435 Mon Sep 17 00:00:00 2001
b7f731
From: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
b7f731
Date: Thu, 28 Sep 2017 14:41:14 +0200
b7f731
Subject: [PATCH 08/12] imsm: don't skip resync when an invalid ppl
b7f731
 header is found
b7f731
b7f731
If validate_ppl_imsm() detects an invalid ppl header it will be
b7f731
overwritten with a valid, empty ppl header. But if we are assembling an
b7f731
array after unclean shutdown this will cause the kernel to skip resync
b7f731
after ppl recovery. We don't want that because if there was an invalid
b7f731
ppl it's best to assume that the ppl recovery is not enough to make the
b7f731
array consistent and a full resync should be performed. So when
b7f731
overwriting the invalid ppl add one ppl_header_entry with a wrong
b7f731
checksum. This will prevent the kernel from skipping resync after ppl
b7f731
recovery.
b7f731
b7f731
Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
b7f731
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
b7f731
---
b7f731
 super-intel.c | 18 ++++++++++++++++--
b7f731
 1 file changed, 16 insertions(+), 2 deletions(-)
b7f731
b7f731
diff --git a/super-intel.c b/super-intel.c
b7f731
index 630fb6e..7b2327b 100644
b7f731
--- a/super-intel.c
b7f731
+++ b/super-intel.c
b7f731
@@ -6080,6 +6080,16 @@ static int write_init_ppl_imsm(struct supertype *st, struct mdinfo *info, int fd
b7f731
 	ppl_hdr = buf;
b7f731
 	memset(ppl_hdr->reserved, 0xff, PPL_HDR_RESERVED);
b7f731
 	ppl_hdr->signature = __cpu_to_le32(super->anchor->orig_family_num);
b7f731
+
b7f731
+	if (info->mismatch_cnt) {
b7f731
+		/*
b7f731
+		 * We are overwriting an invalid ppl. Make one entry with wrong
b7f731
+		 * checksum to prevent the kernel from skipping resync.
b7f731
+		 */
b7f731
+		ppl_hdr->entries_count = __cpu_to_le32(1);
b7f731
+		ppl_hdr->entries[0].checksum = ~0;
b7f731
+	}
b7f731
+
b7f731
 	ppl_hdr->checksum = __cpu_to_le32(~crc32c_le(~0, buf, PPL_HEADER_SIZE));
b7f731
 
b7f731
 	if (lseek64(fd, info->ppl_sector * 512, SEEK_SET) < 0) {
b7f731
@@ -6214,8 +6224,12 @@ out:
b7f731
 		}
b7f731
 	}
b7f731
 
b7f731
-	if (ret == 1 && map->map_state == IMSM_T_STATE_UNINITIALIZED)
b7f731
-		return st->ss->write_init_ppl(st, info, d->fd);
b7f731
+	if (ret == 1) {
b7f731
+		if (map->map_state == IMSM_T_STATE_UNINITIALIZED)
b7f731
+			ret = st->ss->write_init_ppl(st, info, d->fd);
b7f731
+		else
b7f731
+			info->mismatch_cnt++;
b7f731
+	}
b7f731
 
b7f731
 	return ret;
b7f731
 }
b7f731
-- 
b7f731
2.7.4
b7f731