Blame SOURCES/Don-t-abort-starting-the-array-if-kernel-does-not-su.patch

b7f731
From 2c8890e926a4c7f9169b5054e3dbf84426fe1025 Mon Sep 17 00:00:00 2001
b7f731
From: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
b7f731
Date: Thu, 28 Sep 2017 14:41:07 +0200
b7f731
Subject: [PATCH 01/12] Don't abort starting the array if kernel does
b7f731
 not support ppl
b7f731
b7f731
Change the behavior of assemble and create for consistency-policy=ppl
b7f731
for external metadata arrays. If the kernel does not support ppl, don't
b7f731
abort but print a warning and start the array without ppl
b7f731
(consistency-policy=resync). No change for native md arrays because the
b7f731
kernel will not allow starting the array if it finds an unsupported
b7f731
feature bit in the superblock.
b7f731
b7f731
In sysfs_add_disk() check consistency_policy in the mdinfo structure
b7f731
that represents the array, not the disk and read the current consistency
b7f731
policy from sysfs in mdmon's manage_member(). This is necessary to make
b7f731
sysfs_add_disk() honor the actual consistency policy and not what is in
b7f731
the metadata. Also remove all the places where consistency_policy is set
b7f731
for a disk's mdinfo - it is a property of the array, not the disk.
b7f731
b7f731
Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
b7f731
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
b7f731
---
b7f731
 managemon.c   | 11 ++++++++---
b7f731
 super-intel.c |  4 +---
b7f731
 sysfs.c       |  6 +++---
b7f731
 3 files changed, 12 insertions(+), 9 deletions(-)
b7f731
b7f731
diff --git a/managemon.c b/managemon.c
b7f731
index 68f0c2d..cc3c6f1 100644
b7f731
--- a/managemon.c
b7f731
+++ b/managemon.c
b7f731
@@ -477,7 +477,7 @@ static void manage_member(struct mdstat_ent *mdstat,
b7f731
 	char buf[64];
b7f731
 	int frozen;
b7f731
 	struct supertype *container = a->container;
b7f731
-	unsigned long long int component_size = 0;
b7f731
+	struct mdinfo *mdi;
b7f731
 
b7f731
 	if (container == NULL)
b7f731
 		/* Raced with something */
b7f731
@@ -489,8 +489,13 @@ static void manage_member(struct mdstat_ent *mdstat,
b7f731
 		// MORE
b7f731
 	}
b7f731
 
b7f731
-	if (sysfs_get_ll(&a->info, NULL, "component_size", &component_size) >= 0)
b7f731
-		a->info.component_size = component_size << 1;
b7f731
+	mdi = sysfs_read(-1, mdstat->devnm,
b7f731
+			 GET_COMPONENT|GET_CONSISTENCY_POLICY);
b7f731
+	if (mdi) {
b7f731
+		a->info.component_size = mdi->component_size;
b7f731
+		a->info.consistency_policy = mdi->consistency_policy;
b7f731
+		sysfs_free(mdi);
b7f731
+	}
b7f731
 
b7f731
 	/* honor 'frozen' */
b7f731
 	if (sysfs_get_str(&a->info, NULL, "metadata_version", buf, sizeof(buf)) > 0)
b7f731
diff --git a/super-intel.c b/super-intel.c
b7f731
index bbe7bc7..e3dcd3d 100644
b7f731
--- a/super-intel.c
b7f731
+++ b/super-intel.c
b7f731
@@ -7669,7 +7669,6 @@ static struct mdinfo *container_content_imsm(struct supertype *st, char *subarra
b7f731
 			} else {
b7f731
 				info_d->component_size = blocks_per_member(map);
b7f731
 			}
b7f731
-			info_d->consistency_policy = this->consistency_policy;
b7f731
 
b7f731
 			info_d->bb.supported = 1;
b7f731
 			get_volume_badblocks(super->bbm_log, ord_to_idx(ord),
b7f731
@@ -8758,8 +8757,7 @@ static struct mdinfo *imsm_activate_spare(struct active_array *a,
b7f731
 		di->component_size = a->info.component_size;
b7f731
 		di->container_member = inst;
b7f731
 		di->bb.supported = 1;
b7f731
-		if (dev->rwh_policy == RWH_DISTRIBUTED) {
b7f731
-			di->consistency_policy = CONSISTENCY_POLICY_PPL;
b7f731
+		if (a->info.consistency_policy == CONSISTENCY_POLICY_PPL) {
b7f731
 			di->ppl_sector = get_ppl_sector(super, inst);
b7f731
 			di->ppl_size = (PPL_HEADER_SIZE + PPL_ENTRY_SPACE) >> 9;
b7f731
 		}
b7f731
diff --git a/sysfs.c b/sysfs.c
b7f731
index 68ddd5f..bf5c8c5 100644
b7f731
--- a/sysfs.c
b7f731
+++ b/sysfs.c
b7f731
@@ -709,8 +709,8 @@ int sysfs_set_array(struct mdinfo *info, int vers)
b7f731
 		if (sysfs_set_str(info, NULL, "consistency_policy",
b7f731
 				  map_num(consistency_policies,
b7f731
 					  info->consistency_policy))) {
b7f731
-			pr_err("This kernel does not support PPL\n");
b7f731
-			return 1;
b7f731
+			pr_err("This kernel does not support PPL. Falling back to consistency-policy=resync.\n");
b7f731
+			info->consistency_policy = CONSISTENCY_POLICY_RESYNC;
b7f731
 		}
b7f731
 	}
b7f731
 
b7f731
@@ -745,7 +745,7 @@ int sysfs_add_disk(struct mdinfo *sra, struct mdinfo *sd, int resume)
b7f731
 	rv = sysfs_set_num(sra, sd, "offset", sd->data_offset);
b7f731
 	rv |= sysfs_set_num(sra, sd, "size", (sd->component_size+1) / 2);
b7f731
 	if (sra->array.level != LEVEL_CONTAINER) {
b7f731
-		if (sd->consistency_policy == CONSISTENCY_POLICY_PPL) {
b7f731
+		if (sra->consistency_policy == CONSISTENCY_POLICY_PPL) {
b7f731
 			rv |= sysfs_set_num(sra, sd, "ppl_sector", sd->ppl_sector);
b7f731
 			rv |= sysfs_set_num(sra, sd, "ppl_size", sd->ppl_size);
b7f731
 		}
b7f731
-- 
b7f731
2.7.4
b7f731