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

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