From 37dd4e28e95229be8bd62f79ccdb5e745f8b0b0206e002304e01490b79a85431 Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Tue, 22 May 2012 05:18:08 +0000 Subject: [PATCH 1/3] - boot.md/mkinitrd-boot.sh: complete any incremental assembly before attempting to assemble arrays. If incremental assembly has partialy assembled degraded arrays, now is the time to start them going. (bnc#752869) - mdamd.cron: send daily reports if any arrays are degraded. OBS-URL: https://build.opensuse.org/package/show/Base:System/mdadm?expand=0&rev=57 --- boot.md | 2 ++ mdadm.changes | 11 +++++++++++ mdadm.cron | 35 +++++++++++++++++++++++++++++++++++ mdadm.spec | 3 +++ mkinitrd-boot.sh | 3 +++ 5 files changed, 54 insertions(+) create mode 100644 mdadm.cron diff --git a/boot.md b/boot.md index 1385899..aa539cd 100644 --- a/boot.md +++ b/boot.md @@ -125,6 +125,8 @@ case "$1" in # empty or missing /etc/mdadm.conf, "unused" rc_status -u else + # firstly finish any incremental assembly that has started. + $mdadm_BIN -IRs $mdadm_BIN -A -s -c $mdadm_CONFIG # a status of 2 is not an error test $? -eq 0 -o $? -eq 2 diff --git a/mdadm.changes b/mdadm.changes index 8d06d5c..630588a 100644 --- a/mdadm.changes +++ b/mdadm.changes @@ -1,3 +1,14 @@ +------------------------------------------------------------------- +Tue May 22 05:15:52 UTC 2012 - nfbrown@suse.com + +- boot.md/mkinitrd-boot.sh: complete any incremental + assembly before attempting to assemble arrays. + If incremental assembly has partialy assembled + degraded arrays, now is the time to start them going. + (bnc#752869) +- mdamd.cron: send daily reports if any arrays are + degraded. + ------------------------------------------------------------------- Fri May 18 07:16:59 UTC 2012 - nfbrown@suse.com diff --git a/mdadm.cron b/mdadm.cron new file mode 100644 index 0000000..f8fe7bc --- /dev/null +++ b/mdadm.cron @@ -0,0 +1,35 @@ +#!/bin/sh + +# Run "mdadm --monitor --oneshot" once a day to ensure +# degraded arrays don't go unnoticed. + +mdadm_BIN=/sbin/mdadm +mdadm_CONFIG=/etc/sysconfig/mdadm + +[ -x $mdadm_BIN ] || exit 0 + +[ -r $mdadm_CONFIG ] && . $mdadm_CONFIG + +if [ x$MDADM_MAIL != x"" ]; then + MDADM_MAIL="-m \"$MDADM_MAIL\"" +fi + +if [ x$MDADM_PROGRAM != x"" ]; then + MDADM_PROGRAM="-p \"$MDADM_PROGRAM\"" +fi + +if [ x$MDADM_SCAN = x"yes" ]; then + MDADM_SCAN="-s" +else + MDADM_SCAN="" +fi + +if [ x$MDADM_CONFIG != x"" ]; then + MDADM_CONFIG="-c \"$MDADM_CONFIG\"" +fi + +# using --syslog avoids annoying warnings if no MAIL or PROGRAM are given +# in sysconfig or mdadm.conf +eval $mdadm_BIN -F $MDADM_RAIDDEVICES --oneshot --syslog $MDADM_MAIL $MDADM_PROGRAM $MDADM_SCAN $MDADM_SEND_MAIL $MDADM_CONFIG + +exit 0 diff --git a/mdadm.spec b/mdadm.spec index 7546e38..964bec6 100644 --- a/mdadm.spec +++ b/mdadm.spec @@ -35,6 +35,7 @@ Source3: mdadmd Source4: boot.md Source5: mkinitrd-setup.sh Source6: mkinitrd-boot.sh +Source7: mdadm.cron %description Mdadm is a program that can be used to control Linux md devices. It is @@ -59,6 +60,8 @@ install -m 755 %{S:4} %{S:3} $RPM_BUILD_ROOT%{_sysconfdir}/init.d/ install -d $RPM_BUILD_ROOT/lib/mkinitrd/scripts install -m 755 %{S:5} $RPM_BUILD_ROOT/lib/mkinitrd/scripts/setup-md.sh install -m 755 %{S:6} $RPM_BUILD_ROOT/lib/mkinitrd/scripts/boot-md.sh +install -d $RPM_BUILD_ROOT/etc/cron.daily +install -m 755 %{S:7} $RPM_BUILD_ROOT/etc/cron.daily/mdadm install -m 644 %{S:2} $RPM_BUILD_ROOT%{_var}/adm/fillup-templates/ ln -sf ../../etc/init.d/mdadmd $RPM_BUILD_ROOT/%{_sbindir}/rcmdadmd rm -rf $RPM_BUILD_ROOT/run/mdadm diff --git a/mkinitrd-boot.sh b/mkinitrd-boot.sh index dec40ce..3cca304 100644 --- a/mkinitrd-boot.sh +++ b/mkinitrd-boot.sh @@ -127,6 +127,9 @@ md_assemble() fi } +# run any degraded arrays assembled incrementally +wait_for_events +$mdadm --incremental --run --scan md_assemble "$resumedev" md_assemble "$rootdev" if [ -n "$md_dev" ] ; then From 7bd795bf3e12f5303a281fc22a049edae9542a5cd01fa21ac6f87855f4c2b64e Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Tue, 22 May 2012 05:25:59 +0000 Subject: [PATCH 2/3] Add missing %files entry OBS-URL: https://build.opensuse.org/package/show/Base:System/mdadm?expand=0&rev=58 --- mdadm.spec | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mdadm.spec b/mdadm.spec index 964bec6..b2c647c 100644 --- a/mdadm.spec +++ b/mdadm.spec @@ -117,8 +117,10 @@ rm -rf $RPM_BUILD_ROOT %dir /lib/mkinitrd/scripts /lib/mkinitrd/scripts/setup-md.sh /lib/mkinitrd/scripts/boot-md.sh -%dir /lib/udev %dir /lib/udev/rules.d /lib/udev/rules.d/64-md-raid.rules +%dir /etc +%dir /etc/cron.daily +/etc/cron.daily/mdadm %changelog From 0650dcc2aa693b08390893028bcbbfacc7ea5fc091e50a14133314260c492a39 Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Thu, 24 May 2012 01:54:00 +0000 Subject: [PATCH 3/3] - udev-rules.fix: make sure systemd doesn't try to mount array before it is fully assembled. (bnc#752869) OBS-URL: https://build.opensuse.org/package/show/Base:System/mdadm?expand=0&rev=59 --- mdadm.changes | 7 +++++++ mdadm.spec | 2 ++ udev-rules.fix | 28 ++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+) create mode 100644 udev-rules.fix diff --git a/mdadm.changes b/mdadm.changes index 630588a..9967e18 100644 --- a/mdadm.changes +++ b/mdadm.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Thu May 24 01:52:37 UTC 2012 - nfbrown@suse.com + +- udev-rules.fix: make sure systemd doesn't try + to mount array before it is fully assembled. + (bnc#752869) + ------------------------------------------------------------------- Tue May 22 05:15:52 UTC 2012 - nfbrown@suse.com diff --git a/mdadm.spec b/mdadm.spec index b2c647c..0bcb71c 100644 --- a/mdadm.spec +++ b/mdadm.spec @@ -36,6 +36,7 @@ Source4: boot.md Source5: mkinitrd-setup.sh Source6: mkinitrd-boot.sh Source7: mdadm.cron +Patch1: udev-rules.fix %description Mdadm is a program that can be used to control Linux md devices. It is @@ -44,6 +45,7 @@ programs but with a very different interface. %prep %setup -q -a1 +%patch1 -p1 %build make %{?_smp_mflags} CC="%__cc" CXFLAGS="$RPM_OPT_FLAGS -Wno-error" diff --git a/udev-rules.fix b/udev-rules.fix new file mode 100644 index 0000000..c218957 --- /dev/null +++ b/udev-rules.fix @@ -0,0 +1,28 @@ +From 339b77467a7ad5e5354b5ab0542f8148b18c898c Mon Sep 17 00:00:00 2001 +From: NeilBrown +Date: Thu, 24 May 2012 11:49:49 +1000 +Subject: [PATCH] udev-rules: prevent systemd from mount devices before they + are ready. + +When an array is assembled incrementally, systemd might see it +before it is ready, try to mount it, fail, and give up. +Result is that array doesn't get mounted. + +If we ask udev to tell systemd that it isn't ready yet in this +case, systemd waits until it is ready, and all are happy. + +Signed-off-by: NeilBrown + +diff --git a/udev-md-raid.rules b/udev-md-raid.rules +index f564f70..814c897 100644 +--- a/udev-md-raid.rules ++++ b/udev-md-raid.rules +@@ -28,7 +28,7 @@ ENV{DEVTYPE}=="partition", GOTO="md_ignore_state" + # never leave state 'inactive' + ATTR{md/metadata_version}=="external:[A-Za-z]*", ATTR{md/array_state}=="inactive", GOTO="md_ignore_state" + TEST!="md/array_state", GOTO="md_end" +-ATTR{md/array_state}=="|clear|inactive", GOTO="md_end" ++ATTR{md/array_state}=="|clear|inactive", ENV{SYSTEMD_READY}="0", GOTO="md_end" + LABEL="md_ignore_state" + + IMPORT{program}="/sbin/mdadm --detail --export $tempnode"