dcavalca / rpms / mdadm

Forked from rpms/mdadm 3 years ago
Clone

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

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