Linux-Raid Archives on lore.kernel.org
 help / color / Atom feed
* [PATCH mdadm] Super1: allow RAID0 layout setting to be removed.
@ 2020-10-14  2:12 NeilBrown
  2020-10-14 15:42 ` Jes Sorensen
  0 siblings, 1 reply; 2+ messages in thread
From: NeilBrown @ 2020-10-14  2:12 UTC (permalink / raw)
  To: Jes Sorensen; +Cc: Linux RAID Mailing List


[-- Attachment #1: Type: text/plain, Size: 4768 bytes --]


Once the RAID0 layout has been set, the RAID0 array cannot be assembled
on an older kernel which doesn't understand layouts.
This is an intentional safety feature, but sometimes people need the
ability to roll-back to a previously working configuration.

So add "--update=layout-unspecified" to remove RAID0 layout information
from the superblock.
Running "--assemble --update=layout-unspecified" will cause the assembly
the fail when run on a newer kernel, but will allow it to work on
an older kernel.

Signed-off-by: NeilBrown <neilb@suse.de>
---
 md.4       | 13 +++++++++++++
 mdadm.8.in | 15 +++++++++++++--
 mdadm.c    |  5 +++--
 super1.c   |  6 +++++-
 4 files changed, 34 insertions(+), 5 deletions(-)

diff --git a/md.4 b/md.4
index aecff38a1d02..60fdd274cc50 100644
--- a/md.4
+++ b/md.4
@@ -215,6 +215,19 @@ option or the
 .B "--update=layout-alternate"
 option.
 
+Once you have updated the layout you will not be able to mount the array
+on an older kernel.  If you need to revert to an older kernel, the
+layout information can be erased with the
+.B "--update=layout-unspecificed"
+option.  If you use this option to 
+.B --assemble
+while running a newer kernel, the array will NOT assemble, but the
+metadata will be update so that it can be assembled on an older kernel.
+
+No that setting the layout to "unspecified" removes protections against
+this bug, and you must be sure that the kernel you use matches the
+layout of the array.
+
 .SS RAID1
 
 A RAID1 array is also known as a mirrored set (though mirrors tend to
diff --git a/mdadm.8.in b/mdadm.8.in
index ab832e858bca..34a93a8fb3cf 100644
--- a/mdadm.8.in
+++ b/mdadm.8.in
@@ -1213,6 +1213,7 @@ argument given to this flag can be one of
 .BR no\-ppl ,
 .BR layout\-original ,
 .BR layout\-alternate ,
+.BR layout\-unspecified ,
 .BR metadata ,
 or
 .BR super\-minor .
@@ -1368,8 +1369,9 @@ The
 .B layout\-original
 and
 .B layout\-alternate
-options are for RAID0 arrays in use before Linux 5.4.  If the array was being
-used with Linux 3.13 or earlier, then to assemble the array on a new kernel,
+options are for RAID0 arrays with non-uniform devices size that were in
+use before Linux 5.4.  If the array was being used with Linux 3.13 or
+earlier, then to assemble the array on a new kernel, 
 .B \-\-update=layout\-original
 must be given.  If the array was created and used with a kernel from Linux 3.14 to
 Linux 5.3, then
@@ -1379,6 +1381,15 @@ will happen normally.
 For more information, see
 .IR md (4).
 
+The
+.B layout\-unspecified
+option reverts the effect of
+.B layout\-orignal
+or
+.B layout\-alternate
+and allows the array to be again used on a kernel prior to Linux 5.3.
+This option should be used with great caution.
+
 .TP
 .BR \-\-freeze\-reshape
 Option is intended to be used in start-up scripts during initrd boot phase.
diff --git a/mdadm.c b/mdadm.c
index 1b3467fd4779..493d70e4d4ac 100644
--- a/mdadm.c
+++ b/mdadm.c
@@ -796,7 +796,8 @@ int main(int argc, char *argv[])
 			if (strcmp(c.update, "revert-reshape") == 0)
 				continue;
 			if (strcmp(c.update, "layout-original") == 0 ||
-			    strcmp(c.update, "layout-alternate") == 0)
+			    strcmp(c.update, "layout-alternate") == 0 ||
+			    strcmp(c.update, "layout-unspecified") == 0)
 				continue;
 			if (strcmp(c.update, "byteorder") == 0) {
 				if (ss) {
@@ -828,7 +829,7 @@ int main(int argc, char *argv[])
 		"     'summaries', 'homehost', 'home-cluster', 'byteorder', 'devicesize',\n"
 		"     'no-bitmap', 'metadata', 'revert-reshape'\n"
 		"     'bbl', 'no-bbl', 'force-no-bbl', 'ppl', 'no-ppl'\n"
-		"     'layout-original', 'layout-alternate'\n"
+		"     'layout-original', 'layout-alternate', 'layout-unspecified'\n"
 				);
 			exit(outf == stdout ? 0 : 2);
 
diff --git a/super1.c b/super1.c
index 76648835bf8f..8b0d6ff3d8bc 100644
--- a/super1.c
+++ b/super1.c
@@ -1551,11 +1551,15 @@ static int update_super1(struct supertype *st, struct mdinfo *info,
 	else if (strcmp(update, "nofailfast") == 0)
 		sb->devflags &= ~FailFast1;
 	else if (strcmp(update, "layout-original") == 0 ||
-		 strcmp(update, "layout-alternate") == 0) {
+		 strcmp(update, "layout-alternate") == 0 ||
+		 strcmp(update, "layout-unspecified") == 0) {
 		if (__le32_to_cpu(sb->level) != 0) {
 			pr_err("%s: %s only supported for RAID0\n",
 			       devname?:"", update);
 			rv = -1;
+		} else if (strcmp(update, "layout-unspecified") == 0) {
+			sb->feature_map &= ~__cpu_to_le32(MD_FEATURE_RAID0_LAYOUT);
+			sb->layout = 0;
 		} else {
 			sb->feature_map |= __cpu_to_le32(MD_FEATURE_RAID0_LAYOUT);
 			sb->layout = __cpu_to_le32(update[7] == 'o' ? 1 : 2);
-- 
2.28.0


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 853 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH mdadm] Super1: allow RAID0 layout setting to be removed.
  2020-10-14  2:12 [PATCH mdadm] Super1: allow RAID0 layout setting to be removed NeilBrown
@ 2020-10-14 15:42 ` Jes Sorensen
  0 siblings, 0 replies; 2+ messages in thread
From: Jes Sorensen @ 2020-10-14 15:42 UTC (permalink / raw)
  To: NeilBrown; +Cc: Linux RAID Mailing List

On 10/13/20 10:12 PM, NeilBrown wrote:
> 
> Once the RAID0 layout has been set, the RAID0 array cannot be assembled
> on an older kernel which doesn't understand layouts.
> This is an intentional safety feature, but sometimes people need the
> ability to roll-back to a previously working configuration.
> 
> So add "--update=layout-unspecified" to remove RAID0 layout information
> from the superblock.
> Running "--assemble --update=layout-unspecified" will cause the assembly
> the fail when run on a newer kernel, but will allow it to work on
> an older kernel.
> 
> Signed-off-by: NeilBrown <neilb@suse.de>

Applied!

Please press [enter] to start your upgrade to linux-2.2.26..... :)

Thanks,
Jes


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-14  2:12 [PATCH mdadm] Super1: allow RAID0 layout setting to be removed NeilBrown
2020-10-14 15:42 ` Jes Sorensen

Linux-Raid Archives on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-raid/0 linux-raid/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-raid linux-raid/ https://lore.kernel.org/linux-raid \
		linux-raid@vger.kernel.org
	public-inbox-index linux-raid

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-raid


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git