From bc6e213f2ef2cb443c5095080ffcf8bfd2c9d4c4fad2620218a819822bc56660 Mon Sep 17 00:00:00 2001 From: Michal Marek Date: Mon, 11 Jan 2010 14:06:42 +0000 Subject: [PATCH 1/3] Accepting request 29126 from home:michal-m:branches:Base:System Copy from home:michal-m:branches:Base:System/mdadm via accept of submit request 29126 revision 2. Request was accepted with message: Reviewed ok OBS-URL: https://build.opensuse.org/request/show/29126 OBS-URL: https://build.opensuse.org/package/show/Base:System/mdadm?expand=0&rev=10 --- ...missing-space-in-detail-brief-output.patch | 32 ------ ...-null-dereference-in-set_member_info.patch | 48 -------- mdadm-3.0.2.tar.bz2 | 3 - mdadm-3.0.3.tar.bz2 | 3 + mdadm.changes | 19 ++++ mdadm.spec | 6 +- mkinitrd-boot.sh | 49 +++++---- mkinitrd-setup.sh | 103 ++++++++++++++---- 8 files changed, 129 insertions(+), 134 deletions(-) delete mode 100644 0001-Add-missing-space-in-detail-brief-output.patch delete mode 100644 0002-Fix-null-dereference-in-set_member_info.patch delete mode 100644 mdadm-3.0.2.tar.bz2 create mode 100644 mdadm-3.0.3.tar.bz2 diff --git a/0001-Add-missing-space-in-detail-brief-output.patch b/0001-Add-missing-space-in-detail-brief-output.patch deleted file mode 100644 index 34e888c..0000000 --- a/0001-Add-missing-space-in-detail-brief-output.patch +++ /dev/null @@ -1,32 +0,0 @@ -From 0e90271e53c0f6efb33e904cf407498350e2a14d Mon Sep 17 00:00:00 2001 -From: NeilBrown -Date: Thu, 1 Oct 2009 12:38:31 +1000 -Subject: [PATCH 1/2] Add missing space in "--detail --brief" output. - -We need a space between the device name and the word "level".. - -Signed-off-by: NeilBrown ---- - Detail.c | 4 ++-- - 1 files changed, 2 insertions(+), 2 deletions(-) - -diff --git a/Detail.c b/Detail.c -index 001012a..a70db34 100644 ---- a/Detail.c -+++ b/Detail.c -@@ -207,11 +207,11 @@ int Detail(char *dev, int brief, int export, int test, char *homehost) - printf("ARRAY %s", dev); - if (brief > 1) { - if (array.raid_disks) -- printf("level=%s num-devices=%d", -+ printf(" level=%s num-devices=%d", - c?c:"-unknown-", - array.raid_disks ); - else -- printf("level=container num-devices=%d", -+ printf(" level=container num-devices=%d", - array.nr_disks); - } - if (container) { --- -1.6.3.3 diff --git a/0002-Fix-null-dereference-in-set_member_info.patch b/0002-Fix-null-dereference-in-set_member_info.patch deleted file mode 100644 index dfbb818..0000000 --- a/0002-Fix-null-dereference-in-set_member_info.patch +++ /dev/null @@ -1,48 +0,0 @@ -From 2b9aa337af7291d3f141322da96c9f667c99d53c Mon Sep 17 00:00:00 2001 -From: NeilBrown -Date: Thu, 1 Oct 2009 12:51:04 +1000 -Subject: [PATCH 2/2] Fix null-dereference in set_member_info - -set_member_info would try to dereference ->metadata_version, without -checking that it isn't NULL. - -Signed-off-by: NeilBrown ---- - mapfile.c | 15 +++++++++------ - 1 files changed, 9 insertions(+), 6 deletions(-) - -diff --git a/mapfile.c b/mapfile.c -index a3038be..ed59db5 100644 ---- a/mapfile.c -+++ b/mapfile.c -@@ -303,19 +303,22 @@ struct map_ent *map_by_name(struct map_ent **map, char *name) - */ - static void set_member_info(struct supertype *st, struct mdstat_ent *ent) - { -- char version[strlen(ent->metadata_version)+1]; - - st->subarray[0] = '\0'; - -- if (strncmp(ent->metadata_version, "external:", 9) != 0) -+ if (ent->metadata_version == NULL || -+ strncmp(ent->metadata_version, "external:", 9) != 0) - return; - -- strcpy(version, ent->metadata_version); -- -- if (is_subarray(&version[9])) { -- char *subarray = strrchr(version, '/'); -+ if (is_subarray(&ent->metadata_version[9])) { -+ char version[strlen(ent->metadata_version)+1]; -+ char *subarray; - char *name = &version[10]; - -+ strcpy(version, ent->metadata_version); -+ subarray = strrchr(version, '/'); -+ name = &version[10]; -+ - if (!subarray) - return; - *subarray++ = '\0'; --- -1.6.3.3 diff --git a/mdadm-3.0.2.tar.bz2 b/mdadm-3.0.2.tar.bz2 deleted file mode 100644 index 2db571a..0000000 --- a/mdadm-3.0.2.tar.bz2 +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:821c2a073daed4916973226a6c623de5d697cceb077de935e2b1c316b11f3da7 -size 252754 diff --git a/mdadm-3.0.3.tar.bz2 b/mdadm-3.0.3.tar.bz2 new file mode 100644 index 0000000..00e1e12 --- /dev/null +++ b/mdadm-3.0.3.tar.bz2 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b51a52aebfb83b09ae7faee9eebb4d49a7ad27767bcc9569079df62c7d510599 +size 257554 diff --git a/mdadm.changes b/mdadm.changes index 950cbb8..8cf1029 100644 --- a/mdadm.changes +++ b/mdadm.changes @@ -1,8 +1,27 @@ +------------------------------------------------------------------- +Wed Jan 6 15:47:03 CET 2010 - mmarek@suse.cz + +- mkinitrd-*.sh: fix booting from partitionable md devices and + from container devices (bnc#565219). + ------------------------------------------------------------------- Tue Dec 15 20:26:46 CET 2009 - jengelh@medozas.de - enable parallel building +------------------------------------------------------------------- +Fri Dec 4 18:00:40 CET 2009 - mmarek@suse.cz + +- Support for partitionable md devices in mkinitrd scripts + (fate#305883). + +------------------------------------------------------------------- +Tue Nov 3 11:03:54 CET 2009 - mmarek@suse.cz + +- update to 3.0.3 (fate#307159) + * mdmon improvements (needed for fate#306823) + * other fixes + ------------------------------------------------------------------- Fri Oct 30 16:49:40 CET 2009 - mmarek@suse.cz diff --git a/mdadm.spec b/mdadm.spec index dd7a4d9..b88cfb7 100644 --- a/mdadm.spec +++ b/mdadm.spec @@ -19,7 +19,7 @@ Name: mdadm -Version: 3.0.2 +Version: 3.0.3 Release: 3 BuildRequires: sgmltool PreReq: %fillup_prereq %insserv_prereq @@ -31,8 +31,6 @@ Url: http://www.kernel.org/pub/linux/utils/raid/mdadm/ Summary: Utility for Configuring MD Setup BuildRoot: %{_tmppath}/%{name}-%{version}-build Source: %{name}-%{version}.tar.bz2 -Patch1: 0001-Add-missing-space-in-detail-brief-output.patch -Patch2: 0002-Fix-null-dereference-in-set_member_info.patch Source1: Software-RAID.HOWTO.tar.bz2 Source2: sysconfig.mdadm Source3: mdadmd @@ -53,8 +51,6 @@ Authors: %prep %setup -q -a1 -%patch1 -p1 -%patch2 -p1 %build %{suse_update_config -f} diff --git a/mkinitrd-boot.sh b/mkinitrd-boot.sh index 0e216d4..a7f54cd 100644 --- a/mkinitrd-boot.sh +++ b/mkinitrd-boot.sh @@ -1,7 +1,7 @@ #!/bin/bash #%stage: softraid #%programs: /sbin/mdadm /sbin/mdmon -#%modules: raid0 raid1 raid456 +#%modules: raid0 raid1 raid10 raid456 #%if: -n "$need_mdadm" # ##### MD (Software-)Raid @@ -33,36 +33,41 @@ if [ -f /sys/module/md_mod/parameters/start_ro ]; then echo 1 > /sys/module/md_mod/parameters/start_ro fi -if [ -n "$need_mdadm" ]; then - - if [ -f /etc/mdadm.conf ] ; then - mdconf="-Ac /etc/mdadm.conf" - [ -z "$md_dev" ] && md_dev="--scan" +md_assemble() +{ + local dev=$1 mdconf container + + case "$dev" in + /dev/md[0-9]*p[0-9]*) + dev=${dev%p[0-9]*} + esac + if test -f /etc/mdadm.conf; then + mdconf="-c /etc/mdadm.conf" + container=$( \ + sed -rn "s:^ARRAY +$dev .*container=([^ ]*).*:\\1:p" \ + /etc/mdadm.conf) + else + mdconf="-c partitions" fi + if test -n "$container"; then + mdadm -A $mdconf --uuid="$container" /dev/md/container + fi + mdadm -A $mdconf $mdarg "$dev" +} + +if [ -n "$need_mdadm" ]; then if [ -n "$md_uuid" ] ; then mdarg="--uuid=$md_uuid" - elif [ -n "$md_uuid" ] ; then - mdarg="$mdarg --uuid=$md_uuid" - fi - if [ -n "$md_minor" ] ; then - mdarg="$mdarg --super-minor=$md_minor" - md_dev="/dev/md$md_minor" - elif [ -z "$md_minor" -a -n "$md_minor" ] ; then - mdarg="$mdarg --super-minor=$md_minor" fi case $resumedev in - /dev/md*) - echo 1 > /sys/module/md_mod/parameters/start_ro - resume_minor="${resumedev#/dev/md}" - mdadm -Ac partitions -m $resume_minor --auto=md $resumedev - ;; + /dev/md*) + md_assemble "$resumedev" esac - if [ "$md_dev" ] ; then - /sbin/mdadm $mdconf --auto=md $md_dev || /sbin/mdadm -Ac partitions $mdarg --auto=md $md_dev + if [ -n "$md_dev" ] ; then + md_assemble "$md_dev" fi wait_for_events fi - diff --git a/mkinitrd-setup.sh b/mkinitrd-setup.sh index 29e177b..52c1cb7 100644 --- a/mkinitrd-setup.sh +++ b/mkinitrd-setup.sh @@ -4,40 +4,95 @@ # mdblockdev= +# Full mdadm.conf generated by mdadm. +# Contains all created MD RAIDs +mdadm_conf=$(mdadm --examine --brief --scan) + +cont_list= +md_devs= + +# blockdev contains real devices (/dev/X) for root, resume, journal, dumb +echo "blockdev: $blockdev" for bd in $blockdev ; do - # get information about the current blockdev - update_blockdev $bd - mdconf=$(mdadm -Db $bd 2> /dev/null | sed -n "s@/dev/md[0-9]*@/dev/md$blockminor@p") - if [ -n "$mdconf" ] ; then - md_tmpblockdev=$(mdadm -Dbv $bd 2> /dev/null | sed -n "1D;s/,/ /g;s/^ *devices=\(.*\)/\1/p") - md_dev=${bd##/dev/} - dup_found=0 - for dup in $md_devs; do - if [ x"$dup" = x"$md_dev" ]; then - dup_found=1 - break - fi - done - if [ $dup_found -eq 0 ]; then - mdblockdev="$mdblockdev $md_tmpblockdev" - eval md_conf_${md_dev}=\"$mdconf\" - md_devs="$md_devs $md_dev" - root_md=1 - else - echo "setup-md.sh: $md_dev found multiple times" >&2 + is_part_dev=false + case $bd in + /dev/md[0-9]*p[0-9]*) + # Partitionable MD RAID. This is partition on RAID. Get the RAID + bd=${bd%%p[0-9]*} + is_part_dev=true + ;; + /dev/md[0-9]*) + ;; + *) + mdblockdev="$mdblockdev $bd" + continue + ;; + esac + # Check if this device is already added (possible for partitionable). + md_dev=${bd##/dev/} + dup_found=false + for dup in $md_devs; do + if [ x"$dup" = x"$md_dev" ]; then + dup_found=true + break fi - else - mdblockdev="$mdblockdev $bd" + done + if $dup_found; then + if ! $is_part_dev; then + echo "setup-md.sh: $md_dev found multiple times" >&2 + fi + continue + fi + # Get UUID of block device + tmp_uuid=$(mdadm -D $bd --export 2>/dev/null | grep UUID=) + if [ -n "$tmp_uuid" ]; then + md_tmpblockdev=$(mdadm -Dbv $bd 2> /dev/null | sed -n "1D;s/,/ /g;s/^ *devices=\(.*\)/\1/p") + uuid=${tmp_uuid##MD_} + # Get the corresponding line from config + arr_line=$(echo "$mdadm_conf" | grep "$uuid") + if test -z "$arr_line"; then + continue + fi + # Check for container + cont_line= + cont=$(echo "$arr_line" | sed -n "s/.*container=\([0-9a-z]\{8\}:[0-9a-z]\{8\}:[0-9a-z]\{8\}:[0-9a-z]\{8\}\).*/\1/p") + if [ -n "$cont" ]; then + cnt_dup=0 + for cnt in $cont_list; do + if [ x"$cont"= x"$cnt" ]; then + cnt_dup=1 + fi + done + if [ $cnt_dup -eq 0 ]; then + cont_list="$cont_list $cont" + cont_line=$(echo "$mdadm_conf" | grep "UUID=$cont") + cont_line="$cont_line\n" + fi + fi + # add a line with the "real" md device name so that boot-md.sh finds it + cfg_dev=$(echo "$arr_line" | sed -rn 's/^ARRAY +([^ ]*).*/\1/p; T; q') + real_dev=$(readlink -f "$cfg_dev") + if test -n "$real_dev" -a "$real_dev" != "$cfg_dev"; then + arr_line="$arr_line$(echo -e "\\n$arr_line" | \ + sed -r "s:^(ARRAY +)$cfg_dev:\\1$real_dev:")" + fi + mdblockdev="$mdblockdev $md_tmpblockdev" + # Add ARRAY line (with container line before if needed). + cfg_line=$(echo -e "$cont_line$arr_line") + eval md_conf_${md_dev}=\""$cfg_line"\" + md_devs="$md_devs $md_dev" + root_md=1 fi done +# Any 'md' device is replaced by it's component disks. blockdev="$mdblockdev" if [ -n "$root_md" ] ; then need_mdadm=1 - echo "DEVICE partitions" > $tmp_mnt/etc/mdadm.conf + echo -n "" > $tmp_mnt/etc/mdadm.conf for md in $md_devs; do - eval echo \$md_conf_$md >> $tmp_mnt/etc/mdadm.conf + eval echo -e \"\$md_conf_$md\" >> $tmp_mnt/etc/mdadm.conf done fi From 94b53566432ea3ffb454be56f8c1e69f62d318a50a65e31890dfe9d7d6d7ee55 Mon Sep 17 00:00:00 2001 From: OBS User autobuild Date: Mon, 11 Jan 2010 14:50:56 +0000 Subject: [PATCH 2/3] checked in OBS-URL: https://build.opensuse.org/package/show/Base:System/mdadm?expand=0&rev=11 --- ...missing-space-in-detail-brief-output.patch | 32 ++++++ ...-null-dereference-in-set_member_info.patch | 48 +++++++++ mdadm-3.0.2.tar.bz2 | 3 + mdadm-3.0.3.tar.bz2 | 3 - mdadm.changes | 19 ---- mdadm.spec | 6 +- mkinitrd-boot.sh | 49 +++++---- mkinitrd-setup.sh | 99 +++++-------------- 8 files changed, 132 insertions(+), 127 deletions(-) create mode 100644 0001-Add-missing-space-in-detail-brief-output.patch create mode 100644 0002-Fix-null-dereference-in-set_member_info.patch create mode 100644 mdadm-3.0.2.tar.bz2 delete mode 100644 mdadm-3.0.3.tar.bz2 diff --git a/0001-Add-missing-space-in-detail-brief-output.patch b/0001-Add-missing-space-in-detail-brief-output.patch new file mode 100644 index 0000000..34e888c --- /dev/null +++ b/0001-Add-missing-space-in-detail-brief-output.patch @@ -0,0 +1,32 @@ +From 0e90271e53c0f6efb33e904cf407498350e2a14d Mon Sep 17 00:00:00 2001 +From: NeilBrown +Date: Thu, 1 Oct 2009 12:38:31 +1000 +Subject: [PATCH 1/2] Add missing space in "--detail --brief" output. + +We need a space between the device name and the word "level".. + +Signed-off-by: NeilBrown +--- + Detail.c | 4 ++-- + 1 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/Detail.c b/Detail.c +index 001012a..a70db34 100644 +--- a/Detail.c ++++ b/Detail.c +@@ -207,11 +207,11 @@ int Detail(char *dev, int brief, int export, int test, char *homehost) + printf("ARRAY %s", dev); + if (brief > 1) { + if (array.raid_disks) +- printf("level=%s num-devices=%d", ++ printf(" level=%s num-devices=%d", + c?c:"-unknown-", + array.raid_disks ); + else +- printf("level=container num-devices=%d", ++ printf(" level=container num-devices=%d", + array.nr_disks); + } + if (container) { +-- +1.6.3.3 diff --git a/0002-Fix-null-dereference-in-set_member_info.patch b/0002-Fix-null-dereference-in-set_member_info.patch new file mode 100644 index 0000000..dfbb818 --- /dev/null +++ b/0002-Fix-null-dereference-in-set_member_info.patch @@ -0,0 +1,48 @@ +From 2b9aa337af7291d3f141322da96c9f667c99d53c Mon Sep 17 00:00:00 2001 +From: NeilBrown +Date: Thu, 1 Oct 2009 12:51:04 +1000 +Subject: [PATCH 2/2] Fix null-dereference in set_member_info + +set_member_info would try to dereference ->metadata_version, without +checking that it isn't NULL. + +Signed-off-by: NeilBrown +--- + mapfile.c | 15 +++++++++------ + 1 files changed, 9 insertions(+), 6 deletions(-) + +diff --git a/mapfile.c b/mapfile.c +index a3038be..ed59db5 100644 +--- a/mapfile.c ++++ b/mapfile.c +@@ -303,19 +303,22 @@ struct map_ent *map_by_name(struct map_ent **map, char *name) + */ + static void set_member_info(struct supertype *st, struct mdstat_ent *ent) + { +- char version[strlen(ent->metadata_version)+1]; + + st->subarray[0] = '\0'; + +- if (strncmp(ent->metadata_version, "external:", 9) != 0) ++ if (ent->metadata_version == NULL || ++ strncmp(ent->metadata_version, "external:", 9) != 0) + return; + +- strcpy(version, ent->metadata_version); +- +- if (is_subarray(&version[9])) { +- char *subarray = strrchr(version, '/'); ++ if (is_subarray(&ent->metadata_version[9])) { ++ char version[strlen(ent->metadata_version)+1]; ++ char *subarray; + char *name = &version[10]; + ++ strcpy(version, ent->metadata_version); ++ subarray = strrchr(version, '/'); ++ name = &version[10]; ++ + if (!subarray) + return; + *subarray++ = '\0'; +-- +1.6.3.3 diff --git a/mdadm-3.0.2.tar.bz2 b/mdadm-3.0.2.tar.bz2 new file mode 100644 index 0000000..2db571a --- /dev/null +++ b/mdadm-3.0.2.tar.bz2 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:821c2a073daed4916973226a6c623de5d697cceb077de935e2b1c316b11f3da7 +size 252754 diff --git a/mdadm-3.0.3.tar.bz2 b/mdadm-3.0.3.tar.bz2 deleted file mode 100644 index 00e1e12..0000000 --- a/mdadm-3.0.3.tar.bz2 +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:b51a52aebfb83b09ae7faee9eebb4d49a7ad27767bcc9569079df62c7d510599 -size 257554 diff --git a/mdadm.changes b/mdadm.changes index 8cf1029..950cbb8 100644 --- a/mdadm.changes +++ b/mdadm.changes @@ -1,27 +1,8 @@ -------------------------------------------------------------------- -Wed Jan 6 15:47:03 CET 2010 - mmarek@suse.cz - -- mkinitrd-*.sh: fix booting from partitionable md devices and - from container devices (bnc#565219). - ------------------------------------------------------------------- Tue Dec 15 20:26:46 CET 2009 - jengelh@medozas.de - enable parallel building -------------------------------------------------------------------- -Fri Dec 4 18:00:40 CET 2009 - mmarek@suse.cz - -- Support for partitionable md devices in mkinitrd scripts - (fate#305883). - -------------------------------------------------------------------- -Tue Nov 3 11:03:54 CET 2009 - mmarek@suse.cz - -- update to 3.0.3 (fate#307159) - * mdmon improvements (needed for fate#306823) - * other fixes - ------------------------------------------------------------------- Fri Oct 30 16:49:40 CET 2009 - mmarek@suse.cz diff --git a/mdadm.spec b/mdadm.spec index b88cfb7..dd7a4d9 100644 --- a/mdadm.spec +++ b/mdadm.spec @@ -19,7 +19,7 @@ Name: mdadm -Version: 3.0.3 +Version: 3.0.2 Release: 3 BuildRequires: sgmltool PreReq: %fillup_prereq %insserv_prereq @@ -31,6 +31,8 @@ Url: http://www.kernel.org/pub/linux/utils/raid/mdadm/ Summary: Utility for Configuring MD Setup BuildRoot: %{_tmppath}/%{name}-%{version}-build Source: %{name}-%{version}.tar.bz2 +Patch1: 0001-Add-missing-space-in-detail-brief-output.patch +Patch2: 0002-Fix-null-dereference-in-set_member_info.patch Source1: Software-RAID.HOWTO.tar.bz2 Source2: sysconfig.mdadm Source3: mdadmd @@ -51,6 +53,8 @@ Authors: %prep %setup -q -a1 +%patch1 -p1 +%patch2 -p1 %build %{suse_update_config -f} diff --git a/mkinitrd-boot.sh b/mkinitrd-boot.sh index a7f54cd..0e216d4 100644 --- a/mkinitrd-boot.sh +++ b/mkinitrd-boot.sh @@ -1,7 +1,7 @@ #!/bin/bash #%stage: softraid #%programs: /sbin/mdadm /sbin/mdmon -#%modules: raid0 raid1 raid10 raid456 +#%modules: raid0 raid1 raid456 #%if: -n "$need_mdadm" # ##### MD (Software-)Raid @@ -33,41 +33,36 @@ if [ -f /sys/module/md_mod/parameters/start_ro ]; then echo 1 > /sys/module/md_mod/parameters/start_ro fi -md_assemble() -{ - local dev=$1 mdconf container - - case "$dev" in - /dev/md[0-9]*p[0-9]*) - dev=${dev%p[0-9]*} - esac - if test -f /etc/mdadm.conf; then - mdconf="-c /etc/mdadm.conf" - container=$( \ - sed -rn "s:^ARRAY +$dev .*container=([^ ]*).*:\\1:p" \ - /etc/mdadm.conf) - else - mdconf="-c partitions" - fi - if test -n "$container"; then - mdadm -A $mdconf --uuid="$container" /dev/md/container - fi - mdadm -A $mdconf $mdarg "$dev" -} - if [ -n "$need_mdadm" ]; then + if [ -f /etc/mdadm.conf ] ; then + mdconf="-Ac /etc/mdadm.conf" + [ -z "$md_dev" ] && md_dev="--scan" + fi + if [ -n "$md_uuid" ] ; then mdarg="--uuid=$md_uuid" + elif [ -n "$md_uuid" ] ; then + mdarg="$mdarg --uuid=$md_uuid" + fi + if [ -n "$md_minor" ] ; then + mdarg="$mdarg --super-minor=$md_minor" + md_dev="/dev/md$md_minor" + elif [ -z "$md_minor" -a -n "$md_minor" ] ; then + mdarg="$mdarg --super-minor=$md_minor" fi case $resumedev in - /dev/md*) - md_assemble "$resumedev" + /dev/md*) + echo 1 > /sys/module/md_mod/parameters/start_ro + resume_minor="${resumedev#/dev/md}" + mdadm -Ac partitions -m $resume_minor --auto=md $resumedev + ;; esac - if [ -n "$md_dev" ] ; then - md_assemble "$md_dev" + if [ "$md_dev" ] ; then + /sbin/mdadm $mdconf --auto=md $md_dev || /sbin/mdadm -Ac partitions $mdarg --auto=md $md_dev fi wait_for_events fi + diff --git a/mkinitrd-setup.sh b/mkinitrd-setup.sh index 52c1cb7..29e177b 100644 --- a/mkinitrd-setup.sh +++ b/mkinitrd-setup.sh @@ -4,95 +4,40 @@ # mdblockdev= -# Full mdadm.conf generated by mdadm. -# Contains all created MD RAIDs -mdadm_conf=$(mdadm --examine --brief --scan) - -cont_list= -md_devs= - -# blockdev contains real devices (/dev/X) for root, resume, journal, dumb -echo "blockdev: $blockdev" for bd in $blockdev ; do - is_part_dev=false - case $bd in - /dev/md[0-9]*p[0-9]*) - # Partitionable MD RAID. This is partition on RAID. Get the RAID - bd=${bd%%p[0-9]*} - is_part_dev=true - ;; - /dev/md[0-9]*) - ;; - *) - mdblockdev="$mdblockdev $bd" - continue - ;; - esac - # Check if this device is already added (possible for partitionable). - md_dev=${bd##/dev/} - dup_found=false - for dup in $md_devs; do - if [ x"$dup" = x"$md_dev" ]; then - dup_found=true - break - fi - done - if $dup_found; then - if ! $is_part_dev; then - echo "setup-md.sh: $md_dev found multiple times" >&2 - fi - continue - fi - # Get UUID of block device - tmp_uuid=$(mdadm -D $bd --export 2>/dev/null | grep UUID=) - if [ -n "$tmp_uuid" ]; then + # get information about the current blockdev + update_blockdev $bd + mdconf=$(mdadm -Db $bd 2> /dev/null | sed -n "s@/dev/md[0-9]*@/dev/md$blockminor@p") + if [ -n "$mdconf" ] ; then md_tmpblockdev=$(mdadm -Dbv $bd 2> /dev/null | sed -n "1D;s/,/ /g;s/^ *devices=\(.*\)/\1/p") - uuid=${tmp_uuid##MD_} - # Get the corresponding line from config - arr_line=$(echo "$mdadm_conf" | grep "$uuid") - if test -z "$arr_line"; then - continue - fi - # Check for container - cont_line= - cont=$(echo "$arr_line" | sed -n "s/.*container=\([0-9a-z]\{8\}:[0-9a-z]\{8\}:[0-9a-z]\{8\}:[0-9a-z]\{8\}\).*/\1/p") - if [ -n "$cont" ]; then - cnt_dup=0 - for cnt in $cont_list; do - if [ x"$cont"= x"$cnt" ]; then - cnt_dup=1 + md_dev=${bd##/dev/} + dup_found=0 + for dup in $md_devs; do + if [ x"$dup" = x"$md_dev" ]; then + dup_found=1 + break fi - done - if [ $cnt_dup -eq 0 ]; then - cont_list="$cont_list $cont" - cont_line=$(echo "$mdadm_conf" | grep "UUID=$cont") - cont_line="$cont_line\n" - fi + done + if [ $dup_found -eq 0 ]; then + mdblockdev="$mdblockdev $md_tmpblockdev" + eval md_conf_${md_dev}=\"$mdconf\" + md_devs="$md_devs $md_dev" + root_md=1 + else + echo "setup-md.sh: $md_dev found multiple times" >&2 fi - # add a line with the "real" md device name so that boot-md.sh finds it - cfg_dev=$(echo "$arr_line" | sed -rn 's/^ARRAY +([^ ]*).*/\1/p; T; q') - real_dev=$(readlink -f "$cfg_dev") - if test -n "$real_dev" -a "$real_dev" != "$cfg_dev"; then - arr_line="$arr_line$(echo -e "\\n$arr_line" | \ - sed -r "s:^(ARRAY +)$cfg_dev:\\1$real_dev:")" - fi - mdblockdev="$mdblockdev $md_tmpblockdev" - # Add ARRAY line (with container line before if needed). - cfg_line=$(echo -e "$cont_line$arr_line") - eval md_conf_${md_dev}=\""$cfg_line"\" - md_devs="$md_devs $md_dev" - root_md=1 + else + mdblockdev="$mdblockdev $bd" fi done -# Any 'md' device is replaced by it's component disks. blockdev="$mdblockdev" if [ -n "$root_md" ] ; then need_mdadm=1 - echo -n "" > $tmp_mnt/etc/mdadm.conf + echo "DEVICE partitions" > $tmp_mnt/etc/mdadm.conf for md in $md_devs; do - eval echo -e \"\$md_conf_$md\" >> $tmp_mnt/etc/mdadm.conf + eval echo \$md_conf_$md >> $tmp_mnt/etc/mdadm.conf done fi From b9f2c8ae10c99d673953a865f06f511eced5fac99b5e33cd30047237256ab5f0 Mon Sep 17 00:00:00 2001 From: OBS User buildservice-autocommit Date: Mon, 11 Jan 2010 14:50:57 +0000 Subject: [PATCH 3/3] Updating link to change in openSUSE:Factory/mdadm revision 36.0 OBS-URL: https://build.opensuse.org/package/show/Base:System/mdadm?expand=0&rev=8e44a773e803500d04d6cdde9396dc8b --- ...missing-space-in-detail-brief-output.patch | 32 ------ ...-null-dereference-in-set_member_info.patch | 48 -------- mdadm-3.0.2.tar.bz2 | 3 - mdadm-3.0.3.tar.bz2 | 3 + mdadm.changes | 19 ++++ mdadm.spec | 12 +- mkinitrd-boot.sh | 49 +++++---- mkinitrd-setup.sh | 103 ++++++++++++++---- 8 files changed, 132 insertions(+), 137 deletions(-) delete mode 100644 0001-Add-missing-space-in-detail-brief-output.patch delete mode 100644 0002-Fix-null-dereference-in-set_member_info.patch delete mode 100644 mdadm-3.0.2.tar.bz2 create mode 100644 mdadm-3.0.3.tar.bz2 diff --git a/0001-Add-missing-space-in-detail-brief-output.patch b/0001-Add-missing-space-in-detail-brief-output.patch deleted file mode 100644 index 34e888c..0000000 --- a/0001-Add-missing-space-in-detail-brief-output.patch +++ /dev/null @@ -1,32 +0,0 @@ -From 0e90271e53c0f6efb33e904cf407498350e2a14d Mon Sep 17 00:00:00 2001 -From: NeilBrown -Date: Thu, 1 Oct 2009 12:38:31 +1000 -Subject: [PATCH 1/2] Add missing space in "--detail --brief" output. - -We need a space between the device name and the word "level".. - -Signed-off-by: NeilBrown ---- - Detail.c | 4 ++-- - 1 files changed, 2 insertions(+), 2 deletions(-) - -diff --git a/Detail.c b/Detail.c -index 001012a..a70db34 100644 ---- a/Detail.c -+++ b/Detail.c -@@ -207,11 +207,11 @@ int Detail(char *dev, int brief, int export, int test, char *homehost) - printf("ARRAY %s", dev); - if (brief > 1) { - if (array.raid_disks) -- printf("level=%s num-devices=%d", -+ printf(" level=%s num-devices=%d", - c?c:"-unknown-", - array.raid_disks ); - else -- printf("level=container num-devices=%d", -+ printf(" level=container num-devices=%d", - array.nr_disks); - } - if (container) { --- -1.6.3.3 diff --git a/0002-Fix-null-dereference-in-set_member_info.patch b/0002-Fix-null-dereference-in-set_member_info.patch deleted file mode 100644 index dfbb818..0000000 --- a/0002-Fix-null-dereference-in-set_member_info.patch +++ /dev/null @@ -1,48 +0,0 @@ -From 2b9aa337af7291d3f141322da96c9f667c99d53c Mon Sep 17 00:00:00 2001 -From: NeilBrown -Date: Thu, 1 Oct 2009 12:51:04 +1000 -Subject: [PATCH 2/2] Fix null-dereference in set_member_info - -set_member_info would try to dereference ->metadata_version, without -checking that it isn't NULL. - -Signed-off-by: NeilBrown ---- - mapfile.c | 15 +++++++++------ - 1 files changed, 9 insertions(+), 6 deletions(-) - -diff --git a/mapfile.c b/mapfile.c -index a3038be..ed59db5 100644 ---- a/mapfile.c -+++ b/mapfile.c -@@ -303,19 +303,22 @@ struct map_ent *map_by_name(struct map_ent **map, char *name) - */ - static void set_member_info(struct supertype *st, struct mdstat_ent *ent) - { -- char version[strlen(ent->metadata_version)+1]; - - st->subarray[0] = '\0'; - -- if (strncmp(ent->metadata_version, "external:", 9) != 0) -+ if (ent->metadata_version == NULL || -+ strncmp(ent->metadata_version, "external:", 9) != 0) - return; - -- strcpy(version, ent->metadata_version); -- -- if (is_subarray(&version[9])) { -- char *subarray = strrchr(version, '/'); -+ if (is_subarray(&ent->metadata_version[9])) { -+ char version[strlen(ent->metadata_version)+1]; -+ char *subarray; - char *name = &version[10]; - -+ strcpy(version, ent->metadata_version); -+ subarray = strrchr(version, '/'); -+ name = &version[10]; -+ - if (!subarray) - return; - *subarray++ = '\0'; --- -1.6.3.3 diff --git a/mdadm-3.0.2.tar.bz2 b/mdadm-3.0.2.tar.bz2 deleted file mode 100644 index 2db571a..0000000 --- a/mdadm-3.0.2.tar.bz2 +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:821c2a073daed4916973226a6c623de5d697cceb077de935e2b1c316b11f3da7 -size 252754 diff --git a/mdadm-3.0.3.tar.bz2 b/mdadm-3.0.3.tar.bz2 new file mode 100644 index 0000000..00e1e12 --- /dev/null +++ b/mdadm-3.0.3.tar.bz2 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b51a52aebfb83b09ae7faee9eebb4d49a7ad27767bcc9569079df62c7d510599 +size 257554 diff --git a/mdadm.changes b/mdadm.changes index 950cbb8..8cf1029 100644 --- a/mdadm.changes +++ b/mdadm.changes @@ -1,8 +1,27 @@ +------------------------------------------------------------------- +Wed Jan 6 15:47:03 CET 2010 - mmarek@suse.cz + +- mkinitrd-*.sh: fix booting from partitionable md devices and + from container devices (bnc#565219). + ------------------------------------------------------------------- Tue Dec 15 20:26:46 CET 2009 - jengelh@medozas.de - enable parallel building +------------------------------------------------------------------- +Fri Dec 4 18:00:40 CET 2009 - mmarek@suse.cz + +- Support for partitionable md devices in mkinitrd scripts + (fate#305883). + +------------------------------------------------------------------- +Tue Nov 3 11:03:54 CET 2009 - mmarek@suse.cz + +- update to 3.0.3 (fate#307159) + * mdmon improvements (needed for fate#306823) + * other fixes + ------------------------------------------------------------------- Fri Oct 30 16:49:40 CET 2009 - mmarek@suse.cz diff --git a/mdadm.spec b/mdadm.spec index dd7a4d9..1d63461 100644 --- a/mdadm.spec +++ b/mdadm.spec @@ -1,7 +1,7 @@ # -# spec file for package mdadm (Version 3.0.2) +# spec file for package mdadm (Version 3.0.3) # -# Copyright (c) 2009 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2010 SUSE LINUX Products GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -19,8 +19,8 @@ Name: mdadm -Version: 3.0.2 -Release: 3 +Version: 3.0.3 +Release: 1 BuildRequires: sgmltool PreReq: %fillup_prereq %insserv_prereq Obsoletes: raidtools @@ -31,8 +31,6 @@ Url: http://www.kernel.org/pub/linux/utils/raid/mdadm/ Summary: Utility for Configuring MD Setup BuildRoot: %{_tmppath}/%{name}-%{version}-build Source: %{name}-%{version}.tar.bz2 -Patch1: 0001-Add-missing-space-in-detail-brief-output.patch -Patch2: 0002-Fix-null-dereference-in-set_member_info.patch Source1: Software-RAID.HOWTO.tar.bz2 Source2: sysconfig.mdadm Source3: mdadmd @@ -53,8 +51,6 @@ Authors: %prep %setup -q -a1 -%patch1 -p1 -%patch2 -p1 %build %{suse_update_config -f} diff --git a/mkinitrd-boot.sh b/mkinitrd-boot.sh index 0e216d4..a7f54cd 100644 --- a/mkinitrd-boot.sh +++ b/mkinitrd-boot.sh @@ -1,7 +1,7 @@ #!/bin/bash #%stage: softraid #%programs: /sbin/mdadm /sbin/mdmon -#%modules: raid0 raid1 raid456 +#%modules: raid0 raid1 raid10 raid456 #%if: -n "$need_mdadm" # ##### MD (Software-)Raid @@ -33,36 +33,41 @@ if [ -f /sys/module/md_mod/parameters/start_ro ]; then echo 1 > /sys/module/md_mod/parameters/start_ro fi -if [ -n "$need_mdadm" ]; then - - if [ -f /etc/mdadm.conf ] ; then - mdconf="-Ac /etc/mdadm.conf" - [ -z "$md_dev" ] && md_dev="--scan" +md_assemble() +{ + local dev=$1 mdconf container + + case "$dev" in + /dev/md[0-9]*p[0-9]*) + dev=${dev%p[0-9]*} + esac + if test -f /etc/mdadm.conf; then + mdconf="-c /etc/mdadm.conf" + container=$( \ + sed -rn "s:^ARRAY +$dev .*container=([^ ]*).*:\\1:p" \ + /etc/mdadm.conf) + else + mdconf="-c partitions" fi + if test -n "$container"; then + mdadm -A $mdconf --uuid="$container" /dev/md/container + fi + mdadm -A $mdconf $mdarg "$dev" +} + +if [ -n "$need_mdadm" ]; then if [ -n "$md_uuid" ] ; then mdarg="--uuid=$md_uuid" - elif [ -n "$md_uuid" ] ; then - mdarg="$mdarg --uuid=$md_uuid" - fi - if [ -n "$md_minor" ] ; then - mdarg="$mdarg --super-minor=$md_minor" - md_dev="/dev/md$md_minor" - elif [ -z "$md_minor" -a -n "$md_minor" ] ; then - mdarg="$mdarg --super-minor=$md_minor" fi case $resumedev in - /dev/md*) - echo 1 > /sys/module/md_mod/parameters/start_ro - resume_minor="${resumedev#/dev/md}" - mdadm -Ac partitions -m $resume_minor --auto=md $resumedev - ;; + /dev/md*) + md_assemble "$resumedev" esac - if [ "$md_dev" ] ; then - /sbin/mdadm $mdconf --auto=md $md_dev || /sbin/mdadm -Ac partitions $mdarg --auto=md $md_dev + if [ -n "$md_dev" ] ; then + md_assemble "$md_dev" fi wait_for_events fi - diff --git a/mkinitrd-setup.sh b/mkinitrd-setup.sh index 29e177b..52c1cb7 100644 --- a/mkinitrd-setup.sh +++ b/mkinitrd-setup.sh @@ -4,40 +4,95 @@ # mdblockdev= +# Full mdadm.conf generated by mdadm. +# Contains all created MD RAIDs +mdadm_conf=$(mdadm --examine --brief --scan) + +cont_list= +md_devs= + +# blockdev contains real devices (/dev/X) for root, resume, journal, dumb +echo "blockdev: $blockdev" for bd in $blockdev ; do - # get information about the current blockdev - update_blockdev $bd - mdconf=$(mdadm -Db $bd 2> /dev/null | sed -n "s@/dev/md[0-9]*@/dev/md$blockminor@p") - if [ -n "$mdconf" ] ; then - md_tmpblockdev=$(mdadm -Dbv $bd 2> /dev/null | sed -n "1D;s/,/ /g;s/^ *devices=\(.*\)/\1/p") - md_dev=${bd##/dev/} - dup_found=0 - for dup in $md_devs; do - if [ x"$dup" = x"$md_dev" ]; then - dup_found=1 - break - fi - done - if [ $dup_found -eq 0 ]; then - mdblockdev="$mdblockdev $md_tmpblockdev" - eval md_conf_${md_dev}=\"$mdconf\" - md_devs="$md_devs $md_dev" - root_md=1 - else - echo "setup-md.sh: $md_dev found multiple times" >&2 + is_part_dev=false + case $bd in + /dev/md[0-9]*p[0-9]*) + # Partitionable MD RAID. This is partition on RAID. Get the RAID + bd=${bd%%p[0-9]*} + is_part_dev=true + ;; + /dev/md[0-9]*) + ;; + *) + mdblockdev="$mdblockdev $bd" + continue + ;; + esac + # Check if this device is already added (possible for partitionable). + md_dev=${bd##/dev/} + dup_found=false + for dup in $md_devs; do + if [ x"$dup" = x"$md_dev" ]; then + dup_found=true + break fi - else - mdblockdev="$mdblockdev $bd" + done + if $dup_found; then + if ! $is_part_dev; then + echo "setup-md.sh: $md_dev found multiple times" >&2 + fi + continue + fi + # Get UUID of block device + tmp_uuid=$(mdadm -D $bd --export 2>/dev/null | grep UUID=) + if [ -n "$tmp_uuid" ]; then + md_tmpblockdev=$(mdadm -Dbv $bd 2> /dev/null | sed -n "1D;s/,/ /g;s/^ *devices=\(.*\)/\1/p") + uuid=${tmp_uuid##MD_} + # Get the corresponding line from config + arr_line=$(echo "$mdadm_conf" | grep "$uuid") + if test -z "$arr_line"; then + continue + fi + # Check for container + cont_line= + cont=$(echo "$arr_line" | sed -n "s/.*container=\([0-9a-z]\{8\}:[0-9a-z]\{8\}:[0-9a-z]\{8\}:[0-9a-z]\{8\}\).*/\1/p") + if [ -n "$cont" ]; then + cnt_dup=0 + for cnt in $cont_list; do + if [ x"$cont"= x"$cnt" ]; then + cnt_dup=1 + fi + done + if [ $cnt_dup -eq 0 ]; then + cont_list="$cont_list $cont" + cont_line=$(echo "$mdadm_conf" | grep "UUID=$cont") + cont_line="$cont_line\n" + fi + fi + # add a line with the "real" md device name so that boot-md.sh finds it + cfg_dev=$(echo "$arr_line" | sed -rn 's/^ARRAY +([^ ]*).*/\1/p; T; q') + real_dev=$(readlink -f "$cfg_dev") + if test -n "$real_dev" -a "$real_dev" != "$cfg_dev"; then + arr_line="$arr_line$(echo -e "\\n$arr_line" | \ + sed -r "s:^(ARRAY +)$cfg_dev:\\1$real_dev:")" + fi + mdblockdev="$mdblockdev $md_tmpblockdev" + # Add ARRAY line (with container line before if needed). + cfg_line=$(echo -e "$cont_line$arr_line") + eval md_conf_${md_dev}=\""$cfg_line"\" + md_devs="$md_devs $md_dev" + root_md=1 fi done +# Any 'md' device is replaced by it's component disks. blockdev="$mdblockdev" if [ -n "$root_md" ] ; then need_mdadm=1 - echo "DEVICE partitions" > $tmp_mnt/etc/mdadm.conf + echo -n "" > $tmp_mnt/etc/mdadm.conf for md in $md_devs; do - eval echo \$md_conf_$md >> $tmp_mnt/etc/mdadm.conf + eval echo -e \"\$md_conf_$md\" >> $tmp_mnt/etc/mdadm.conf done fi