martin f. krafft: Compile-time switch to enable 0.9 metadata as default

Martin F. Krafft madduck at alioth.debian.org
Sat Aug 28 18:46:35 UTC 2010


Module: mdadm
Branch: master
Commit: 26f467a9548dcebe07d576deb6ceb02b947eaecc
URL:    http://git.debian.org/?p=pkg-mdadm/mdadm.git;a=commit;h=26f467a9548dcebe07d576deb6ceb02b947eaecc

Author: martin f. krafft <madduck at debian.org>
Date:   Fri May 28 14:12:41 2010 +0200

Compile-time switch to enable 0.9 metadata as default

This commit introduces DEFAULT_OLD_METADATA as a preprocessor
definition. If defined, it causes mdadm to assume metadata version 0.9
as default. If not defined, version 1.x (currently 1.2) is used as
default.

The man page mdadm.8 is also modified to reflect the chosen default.

The selftests will not work if the old default is chosen.

This patch was requested by Debian so they could distribute a current
mdadm together with boot loaders that only understand 0.90 metadata
for md-raid.

Preferred usage is simply
   make DEFAULT_OLD_METADATA=yes


Signed-off-by: martin f. krafft <madduck at debian.org>
Signed-off-by: NeilBrown <neilb at suse.de>

---

 Makefile              |   13 +++++++++++--
 mdadm.8 => mdadm.8.in |   14 +++++++++++---
 super0.c              |    3 +++
 super1.c              |    2 ++
 4 files changed, 27 insertions(+), 5 deletions(-)

diff --git a/Makefile b/Makefile
index 2517f75..3af1665 100644
--- a/Makefile
+++ b/Makefile
@@ -48,9 +48,15 @@ CWFLAGS += -Wp,-D_FORTIFY_SOURCE=2 -O
 endif
 
 ifdef DEBIAN
-CPPFLAGS= -DDEBIAN
+CPPFLAGS := -DDEBIAN
 else
-CPPFLAGS=
+CPPFLAGS :=
+endif
+ifdef DEFAULT_OLD_METADATA
+ CPPFLAG += -DDEFAULT_OLD_METADATA
+ DEFAULT_METADATA=0.90
+else
+ DEFAULT_METADATA=1.2
 endif
 
 SYSCONFDIR = /etc
@@ -180,6 +186,9 @@ mdassemble.klibc : $(ASSEMBLE_SRCS) mdadm.h
 	rm -f $(OBJS)
 	$(KLIBC_GCC) $(ASSEMBLE_FLAGS) -o mdassemble $(ASSEMBLE_SRCS)
 
+mdadm.8 : mdadm.8.in
+	sed -e 's/{DEFAULT_METADATA}/$(DEFAULT_METADATA)/g' mdadm.8.in > mdadm.8
+
 mdadm.man : mdadm.8
 	nroff -man mdadm.8 > mdadm.man
 
diff --git a/mdadm.8 b/mdadm.8.in
similarity index 99%
rename from mdadm.8
rename to mdadm.8.in
index 90470d9..da1a0a9 100644
--- a/mdadm.8
+++ b/mdadm.8.in
@@ -299,7 +299,7 @@ says to get a list of array devices from
 .TP
 .BR \-e ", " \-\-metadata=
 Declare the style of RAID metadata (superblock) to be used.  The
-default is 1.2 for
+default is {DEFAULT_METADATA} for
 .BR \-\-create ,
 and to guess for other operations.
 The default can be overridden by setting the
@@ -311,16 +311,24 @@ keyword in
 
 Options are:
 .RS
+.ie '{DEFAULT_METADATA}'0.90'
+.IP "0, 0.90, default"
+.el
 .IP "0, 0.90"
+..
 Use the original 0.90 format superblock.  This format limits arrays to
 28 component devices and limits component devices of levels 1 and
 greater to 2 terabytes.
+.ie '{DEFAULT_METADATA}'0.90'
+.IP "1, 1.0, 1.1, 1.2"
+.el
 .IP "1, 1.0, 1.1, 1.2 default"
+..
 Use the new version-1 format superblock.  This has few restrictions.
 The different sub-versions store the superblock at different locations
 on the device, either at the end (for 1.0), at the start (for 1.1) or
-4K from the start (for 1.2).  '1' is equivalent to '1.0', 'default' is
-equivalent to '1.2'.
+4K from the start (for 1.2).  "1" is equivalent to "1.0".
+'if '{DEFAULT_METADATA}'1.2'  "default" is equivalent to "1.2".
 .IP ddf
 Use the "Industry Standard" DDF (Disk Data Format) format defined by
 SNIA.
diff --git a/super0.c b/super0.c
index a0c7eb4..83600cb 100644
--- a/super0.c
+++ b/super0.c
@@ -922,6 +922,9 @@ static struct supertype *match_metadata_desc0(char *arg)
 	while (arg[0] == '0' && arg[1] == '0')
 		arg++;
 	if (strcmp(arg, "0") == 0 ||
+#ifdef DEFAULT_OLD_METADATA /* ifndef in super1.c */
+	    strcmp(arg, "default") == 0 ||
+#endif /* DEFAULT_OLD_METADATA */
 	    strcmp(arg, "0.90") == 0 ||
 	    strcmp(arg, "") == 0 /* no metadata  - i.e. non_persistent */
 		)
diff --git a/super1.c b/super1.c
index 8fa0745..216690d 100644
--- a/super1.c
+++ b/super1.c
@@ -1381,7 +1381,9 @@ static struct supertype *match_metadata_desc1(char *arg)
 		return st;
 	}
 	if (strcmp(arg, "1.2") == 0 ||
+#ifndef DEFAULT_OLD_METADATA /* ifdef in super0.c */
 	    strcmp(arg, "default") == 0 ||
+#endif /* DEFAULT_OLD_METADATA */
 	    strcmp(arg, "1.02") == 0) {
 		st->minor_version = 2;
 		return st;




More information about the pkg-mdadm-commits mailing list