From 26f467a9548dcebe07d576deb6ceb02b947eaecc Mon Sep 17 00:00:00 2001 From: "martin f. krafft" Date: Fri, 28 May 2010 14:12:41 +0200 Subject: [PATCH] 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 Signed-off-by: NeilBrown --- Makefile | 13 +++++++++++-- mdadm.8 => mdadm.8.in | 14 +++++++++++--- super0.c | 3 +++ super1.c | 2 ++ 4 files changed, 27 insertions(+), 5 deletions(-) rename mdadm.8 => mdadm.8.in (99%) diff --git a/Makefile b/Makefile index 2517f75e..3af16650 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 90470d9d..da1a0a90 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 a0c7eb4f..83600cbf 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 8fa07453..216690d4 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; -- 2.39.2