dcavalca / rpms / mdadm

Forked from rpms/mdadm 3 years ago
Clone

Blame SOURCES/0055-Assemble-add-support-for-RAID0-layouts.patch

2910d5
From 027c099fd1a31fb3815e592de75d0791a22353b4 Mon Sep 17 00:00:00 2001
2910d5
From: NeilBrown <neilb@suse.de>
2910d5
Date: Mon, 4 Nov 2019 14:27:49 +1100
2910d5
Subject: [RHEL8.2 PATCH 55/61] Assemble: add support for RAID0 layouts.
2910d5
2910d5
If you have a RAID0 array with varying sized devices
2910d5
on a kernel before 5.4, you cannot assembling it on
2910d5
5.4 or later without explicitly setting the layout.
2910d5
This is now possible with
2910d5
  --update=layout-original (For 3.13 and earlier kernels)
2910d5
or
2910d5
  --update=layout-alternate (for 3.14 and later kernels)
2910d5
2910d5
Signed-off-by: NeilBrown <neilb@suse.de>
2910d5
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2910d5
---
2910d5
 Assemble.c |  8 ++++++++
2910d5
 md.4       |  7 +++++++
2910d5
 mdadm.8.in | 17 +++++++++++++++++
2910d5
 mdadm.c    |  4 ++++
2910d5
 super1.c   | 12 +++++++++++-
2910d5
 5 files changed, 47 insertions(+), 1 deletion(-)
2910d5
2910d5
diff --git a/Assemble.c b/Assemble.c
2910d5
index b2e6914..6b5a7c8 100644
2910d5
--- a/Assemble.c
2910d5
+++ b/Assemble.c
2910d5
@@ -1031,6 +1031,11 @@ static int start_array(int mdfd,
2910d5
 				pr_err("failed to add %s to %s: %s\n",
2910d5
 				       devices[j].devname, mddev,
2910d5
 				       strerror(errno));
2910d5
+				if (errno == EINVAL && content->array.level == 0 &&
2910d5
+				    content->array.layout != 0) {
2910d5
+					cont_err("Possibly your kernel doesn't support RAID0 layouts.\n");
2910d5
+					cont_err("Please upgrade.\n");
2910d5
+				}
2910d5
 				if (i < content->array.raid_disks * 2 ||
2910d5
 				    i == bestcnt)
2910d5
 					okcnt--;
2910d5
@@ -1220,6 +1225,9 @@ static int start_array(int mdfd,
2910d5
 			return 0;
2910d5
 		}
2910d5
 		pr_err("failed to RUN_ARRAY %s: %s\n", mddev, strerror(errno));
2910d5
+		if (errno == 524 /* ENOTSUP */ &&
2910d5
+		    content->array.level == 0 && content->array.layout == 0)
2910d5
+			cont_err("Please use --update=layout-original or --update=layout-alternate\n");
2910d5
 
2910d5
 		if (!enough(content->array.level, content->array.raid_disks,
2910d5
 			    content->array.layout, 1, avail))
2910d5
diff --git a/md.4 b/md.4
2910d5
index 6fe2755..0712af2 100644
2910d5
--- a/md.4
2910d5
+++ b/md.4
2910d5
@@ -208,6 +208,13 @@ array,
2910d5
 will record the chosen layout in the metadata in a way that allows newer
2910d5
 kernels to assemble the array without needing a module parameter.
2910d5
 
2910d5
+To assemble an old array on a new kernel without using the module parameter,
2910d5
+use either the
2910d5
+.B "--update=layout-original"
2910d5
+option or the
2910d5
+.B "--update=layout-alternate"
2910d5
+option.
2910d5
+
2910d5
 .SS RAID1
2910d5
 
2910d5
 A RAID1 array is also known as a mirrored set (though mirrors tend to
2910d5
diff --git a/mdadm.8.in b/mdadm.8.in
2910d5
index fc9b6a6..6b63bb4 100644
2910d5
--- a/mdadm.8.in
2910d5
+++ b/mdadm.8.in
2910d5
@@ -1213,6 +1213,8 @@ argument given to this flag can be one of
2910d5
 .BR no\-bbl ,
2910d5
 .BR ppl ,
2910d5
 .BR no\-ppl ,
2910d5
+.BR layout\-original ,
2910d5
+.BR layout\-alternate ,
2910d5
 .BR metadata ,
2910d5
 or
2910d5
 .BR super\-minor .
2910d5
@@ -1364,6 +1366,21 @@ The
2910d5
 .B no\-ppl
2910d5
 option will disable PPL in the superblock.
2910d5
 
2910d5
+The
2910d5
+.B layout\-original
2910d5
+and
2910d5
+.B layout\-alternate
2910d5
+options are for RAID0 arrays in use before Linux 5.4.  If the array was being
2910d5
+used with Linux 3.13 or earlier, then to assemble the array on a new kernel,
2910d5
+.B \-\-update=layout\-original
2910d5
+must be given.  If the array was created and used with a kernel from Linux 3.14 to
2910d5
+Linux 5.3, then
2910d5
+.B \-\-update=layout\-alternate
2910d5
+must be given.  This only needs to be given once.  Subsequent assembly of the array
2910d5
+will happen normally.
2910d5
+For more information, see
2910d5
+.IR md (4).
2910d5
+
2910d5
 .TP
2910d5
 .BR \-\-freeze\-reshape
2910d5
 Option is intended to be used in start-up scripts during initrd boot phase.
2910d5
diff --git a/mdadm.c b/mdadm.c
2910d5
index e438f9c..256a97e 100644
2910d5
--- a/mdadm.c
2910d5
+++ b/mdadm.c
2910d5
@@ -795,6 +795,9 @@ int main(int argc, char *argv[])
2910d5
 				continue;
2910d5
 			if (strcmp(c.update, "revert-reshape") == 0)
2910d5
 				continue;
2910d5
+			if (strcmp(c.update, "layout-original") == 0 ||
2910d5
+			    strcmp(c.update, "layout-alternate") == 0)
2910d5
+				continue;
2910d5
 			if (strcmp(c.update, "byteorder") == 0) {
2910d5
 				if (ss) {
2910d5
 					pr_err("must not set metadata type with --update=byteorder.\n");
2910d5
@@ -825,6 +828,7 @@ int main(int argc, char *argv[])
2910d5
 		"     'summaries', 'homehost', 'home-cluster', 'byteorder', 'devicesize',\n"
2910d5
 		"     'no-bitmap', 'metadata', 'revert-reshape'\n"
2910d5
 		"     'bbl', 'no-bbl', 'force-no-bbl', 'ppl', 'no-ppl'\n"
2910d5
+		"     'layout-original', 'layout-alternate'\n"
2910d5
 				);
2910d5
 			exit(outf == stdout ? 0 : 2);
2910d5
 
2910d5
diff --git a/super1.c b/super1.c
2910d5
index cedbb53..e0d80be 100644
2910d5
--- a/super1.c
2910d5
+++ b/super1.c
2910d5
@@ -1550,7 +1550,17 @@ static int update_super1(struct supertype *st, struct mdinfo *info,
2910d5
 		sb->devflags |= FailFast1;
2910d5
 	else if (strcmp(update, "nofailfast") == 0)
2910d5
 		sb->devflags &= ~FailFast1;
2910d5
-	else
2910d5
+	else if (strcmp(update, "layout-original") == 0 ||
2910d5
+		 strcmp(update, "layout-alternate") == 0) {
2910d5
+		if (__le32_to_cpu(sb->level) != 0) {
2910d5
+			pr_err("%s: %s only supported for RAID0\n",
2910d5
+			       devname?:"", update);
2910d5
+			rv = -1;
2910d5
+		} else {
2910d5
+			sb->feature_map |= __cpu_to_le32(MD_FEATURE_RAID0_LAYOUT);
2910d5
+			sb->layout = __cpu_to_le32(update[7] == 'o' ? 1 : 2);
2910d5
+		}
2910d5
+	} else
2910d5
 		rv = -1;
2910d5
 
2910d5
 	sb->sb_csum = calc_sb_1_csum(sb);
2910d5
-- 
2910d5
2.7.5
2910d5