linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pawel Baldysiak <pawel.baldysiak@intel.com>
To: jes.sorensen@gmail.com
Cc: linux-raid@vger.kernel.org,
	Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Subject: [PATCH 08/12] imsm: don't skip resync when an invalid ppl header is found
Date: Thu, 28 Sep 2017 14:41:14 +0200	[thread overview]
Message-ID: <20170928124118.23361-9-pawel.baldysiak@intel.com> (raw)
In-Reply-To: <20170928124118.23361-1-pawel.baldysiak@intel.com>

From: Artur Paszkiewicz <artur.paszkiewicz@intel.com>

If validate_ppl_imsm() detects an invalid ppl header it will be
overwritten with a valid, empty ppl header. But if we are assembling an
array after unclean shutdown this will cause the kernel to skip resync
after ppl recovery. We don't want that because if there was an invalid
ppl it's best to assume that the ppl recovery is not enough to make the
array consistent and a full resync should be performed. So when
overwriting the invalid ppl add one ppl_header_entry with a wrong
checksum. This will prevent the kernel from skipping resync after ppl
recovery.

Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
---
 super-intel.c | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/super-intel.c b/super-intel.c
index 6c48725d..016a6028 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -6080,6 +6080,16 @@ static int write_init_ppl_imsm(struct supertype *st, struct mdinfo *info, int fd
 	ppl_hdr = buf;
 	memset(ppl_hdr->reserved, 0xff, PPL_HDR_RESERVED);
 	ppl_hdr->signature = __cpu_to_le32(super->anchor->orig_family_num);
+
+	if (info->mismatch_cnt) {
+		/*
+		 * We are overwriting an invalid ppl. Make one entry with wrong
+		 * checksum to prevent the kernel from skipping resync.
+		 */
+		ppl_hdr->entries_count = __cpu_to_le32(1);
+		ppl_hdr->entries[0].checksum = ~0;
+	}
+
 	ppl_hdr->checksum = __cpu_to_le32(~crc32c_le(~0, buf, PPL_HEADER_SIZE));
 
 	if (lseek64(fd, info->ppl_sector * 512, SEEK_SET) < 0) {
@@ -6214,8 +6224,12 @@ out:
 		}
 	}
 
-	if (ret == 1 && map->map_state == IMSM_T_STATE_UNINITIALIZED)
-		return st->ss->write_init_ppl(st, info, d->fd);
+	if (ret == 1) {
+		if (map->map_state == IMSM_T_STATE_UNINITIALIZED)
+			ret = st->ss->write_init_ppl(st, info, d->fd);
+		else
+			info->mismatch_cnt++;
+	}
 
 	return ret;
 }
-- 
2.13.5


  parent reply	other threads:[~2017-09-28 12:41 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-28 12:41 [PATCH 00/12] Multiple PPL support and PPL bugfixes Pawel Baldysiak
2017-09-28 12:41 ` [PATCH 01/12] Don't abort starting the array if kernel does not support ppl Pawel Baldysiak
2017-09-28 12:41 ` [PATCH 02/12] super1: Add support for multiple-ppls Pawel Baldysiak
2017-09-28 12:41 ` [PATCH 03/12] imsm: Add support for multiple ppls Pawel Baldysiak
2017-09-28 12:41 ` [PATCH 04/12] imsm: validate multiple ppls during assemble Pawel Baldysiak
2017-09-28 12:41 ` [PATCH 05/12] Zeroout whole ppl space during creation/force assemble Pawel Baldysiak
2017-09-28 12:41 ` [PATCH 06/12] imsm: switch to multiple ppls automatically during assemble Pawel Baldysiak
2017-09-28 12:41 ` [PATCH 07/12] Grow: fix switching on PPL during recovery Pawel Baldysiak
2017-09-28 12:41 ` Pawel Baldysiak [this message]
2017-09-28 12:41 ` [PATCH 09/12] imsm: Write empty PPL header if assembling regular clean array Pawel Baldysiak
2017-09-28 12:41 ` [PATCH 10/12] imsm: always do ppl recovery when starting a rebuilding array Pawel Baldysiak
2017-09-28 12:41 ` [PATCH 11/12] imsm: use correct map when validating ppl Pawel Baldysiak
2017-09-28 12:41 ` [PATCH 12/12] imsm: write initial ppl on a disk added for rebuild Pawel Baldysiak
2017-10-02 20:16 ` [PATCH 00/12] Multiple PPL support and PPL bugfixes Jes Sorensen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170928124118.23361-9-pawel.baldysiak@intel.com \
    --to=pawel.baldysiak@intel.com \
    --cc=artur.paszkiewicz@intel.com \
    --cc=jes.sorensen@gmail.com \
    --cc=linux-raid@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).