From 702c57405a98b9e8f97290c707efb93461becd67bdfd55e98348bb97adbf4543 Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Wed, 22 Jan 2014 04:59:00 +0000 Subject: [PATCH] - mdmonitor run "mdadm --monitor" from systemd instead of init.d sciprt (bnc#849523) - remove mdadmd due to above. - udev-rules-try-mdadm-I-on-change-events.patch (bnc#851993) - policy-NULL-path-isn-t-really-acceptable-use-the-dev.patch - DDF-really-ignore-DDF-metadata-on-partitions.patch - Assemble-avoid-infinite-loop-when-auto-assembling-pa.patch - DDF-fix-detection-of-failed-devices-during-assembly.patch - Grow-fix-problems-with-prematurely-aborting-of-resha.patch - IMSM-don-t-crash-when-creating-an-array-with-missing.patch - mdmon-don-t-complain-about-notifying-parent-when-the.patch - systemd-mdmon-set-IMSM_NO_PLATFORM-1.patch - mdmon-.service-remove-over-ride-of-Standard-IO.patch Various upstream bug fixes. OBS-URL: https://build.opensuse.org/package/show/Base:System/mdadm?expand=0&rev=101 --- ...nfinite-loop-when-auto-assembling-pa.patch | 34 ++++ ...on-of-failed-devices-during-assembly.patch | 79 +++++++++ ...ly-ignore-DDF-metadata-on-partitions.patch | 25 +++ ...s-with-prematurely-aborting-of-resha.patch | 58 +++++++ ...-when-creating-an-array-with-missing.patch | 25 +++ mdadm.changes | 20 +++ mdadm.spec | 50 ++++-- mdadmd | 150 ------------------ ...vice-remove-over-ride-of-Standard-IO.patch | 24 +++ ...lain-about-notifying-parent-when-the.patch | 43 +++++ mdmonitor | 117 ++++++++++++++ ...-isn-t-really-acceptable-use-the-dev.patch | 64 ++++++++ systemd-mdadm-last-resort@.timer | 1 + systemd-mdmon-set-IMSM_NO_PLATFORM-1.patch | 28 ++++ udev-rules-try-mdadm-I-on-change-events.patch | 32 ++++ 15 files changed, 590 insertions(+), 160 deletions(-) create mode 100644 Assemble-avoid-infinite-loop-when-auto-assembling-pa.patch create mode 100644 DDF-fix-detection-of-failed-devices-during-assembly.patch create mode 100644 DDF-really-ignore-DDF-metadata-on-partitions.patch create mode 100644 Grow-fix-problems-with-prematurely-aborting-of-resha.patch create mode 100644 IMSM-don-t-crash-when-creating-an-array-with-missing.patch delete mode 100644 mdadmd create mode 100644 mdmon-.service-remove-over-ride-of-Standard-IO.patch create mode 100644 mdmon-don-t-complain-about-notifying-parent-when-the.patch create mode 100644 mdmonitor create mode 100644 policy-NULL-path-isn-t-really-acceptable-use-the-dev.patch create mode 100644 systemd-mdmon-set-IMSM_NO_PLATFORM-1.patch create mode 100644 udev-rules-try-mdadm-I-on-change-events.patch diff --git a/Assemble-avoid-infinite-loop-when-auto-assembling-pa.patch b/Assemble-avoid-infinite-loop-when-auto-assembling-pa.patch new file mode 100644 index 0000000..648307f --- /dev/null +++ b/Assemble-avoid-infinite-loop-when-auto-assembling-pa.patch @@ -0,0 +1,34 @@ +From 284546ef89168c9003da192a177cae774199f889 Mon Sep 17 00:00:00 2001 +From: NeilBrown +Date: Mon, 20 Jan 2014 15:23:31 +1100 +Subject: [PATCH 07/13] Assemble: avoid infinite loop when auto-assembling + partial container. + +When auto-assembling we loop until we get no successes. + +If a device is found that look like it is part of an already-existing +container, but we subsequently fail to add that device, then the fact +that the container is running looks like a success. This can result +in infinite looping. +So if a container was already partially assemble, and is still only +partially assembled after we try to add devices, then don't treat that +as success. + +Signed-off-by: NeilBrown +--- + Assemble.c | 4 ++++ + 1 file changed, 4 insertions(+) + +--- mdadm-3.3.orig/Assemble.c ++++ mdadm-3.3/Assemble.c +@@ -990,6 +990,10 @@ static int start_array(int mdfd, + } + st->ss->free_super(st); + sysfs_uevent(content, "change"); ++ if (err_ok && okcnt < (unsigned)content->array.raid_disks) ++ /* Was partial, is still partial, so signal an error ++ * to ensure we don't retry */ ++ return 1; + return 0; + } + diff --git a/DDF-fix-detection-of-failed-devices-during-assembly.patch b/DDF-fix-detection-of-failed-devices-during-assembly.patch new file mode 100644 index 0000000..f144435 --- /dev/null +++ b/DDF-fix-detection-of-failed-devices-during-assembly.patch @@ -0,0 +1,79 @@ +From f0e876ce03a63f150bb87b2734c139bc8bb285b2 Mon Sep 17 00:00:00 2001 +From: NeilBrown +Date: Mon, 20 Jan 2014 15:27:29 +1100 +Subject: [PATCH 08/13] DDF: fix detection of failed devices during assembly. + +When we call "getinfo_super", we report the working/failed status +of the particular device, and also (via the 'map') the working/failed +status of every other device that this metadata is aware of. + +It is important that the way we calculate "working or failed" is +consistent. +As it is, getinfo_super_ddf() will report a spare as "working", but +every other device will see it as "failed", which leads to failure to +assemble arrays with spares. + +For getinfo_super_ddf (i.e. for the container), a device is assumed +"working" unless flagged as DDF_Failed. +For getinfo_super_ddf_bvd (for a member array), a device is assumed +"failed" unless DDF_Online is set, and DDF_Failed is not set. + +Reported-by: "David F." +Signed-off-by: NeilBrown +--- + super-ddf.c | 18 ++++++++++++++---- + 1 file changed, 14 insertions(+), 4 deletions(-) + +--- mdadm-3.3.orig/super-ddf.c ++++ mdadm-3.3/super-ddf.c +@@ -1914,6 +1914,7 @@ static void getinfo_super_ddf(struct sup + info->disk.major = 0; + info->disk.minor = 0; + if (ddf->dlist) { ++ struct phys_disk_entry *pde = NULL; + info->disk.number = be32_to_cpu(ddf->dlist->disk.refnum); + info->disk.raid_disk = find_phys(ddf, ddf->dlist->disk.refnum); + +@@ -1921,12 +1922,19 @@ static void getinfo_super_ddf(struct sup + entries[info->disk.raid_disk]. + config_size); + info->component_size = ddf->dlist->size - info->data_offset; ++ if (info->disk.raid_disk >= 0) ++ pde = ddf->phys->entries + info->disk.raid_disk; ++ if (pde && ++ !(be16_to_cpu(pde->state) & DDF_Failed)) ++ info->disk.state = (1 << MD_DISK_SYNC) | (1 << MD_DISK_ACTIVE); ++ else ++ info->disk.state = 1 << MD_DISK_FAULTY; + } else { + info->disk.number = -1; + info->disk.raid_disk = -1; + // info->disk.raid_disk = find refnum in the table and use index; ++ info->disk.state = (1 << MD_DISK_SYNC) | (1 << MD_DISK_ACTIVE); + } +- info->disk.state = (1 << MD_DISK_SYNC) | (1 << MD_DISK_ACTIVE); + + info->recovery_start = MaxSector; + info->reshape_active = 0; +@@ -1944,8 +1952,6 @@ static void getinfo_super_ddf(struct sup + int i; + for (i = 0 ; i < map_disks; i++) { + if (i < info->array.raid_disks && +- (be16_to_cpu(ddf->phys->entries[i].state) +- & DDF_Online) && + !(be16_to_cpu(ddf->phys->entries[i].state) + & DDF_Failed)) + map[i] = 1; +@@ -2018,7 +2024,11 @@ static void getinfo_super_ddf_bvd(struct + info->disk.raid_disk = cd + conf->sec_elmnt_seq + * be16_to_cpu(conf->prim_elmnt_count); + info->disk.number = dl->pdnum; +- info->disk.state = (1<disk.state = 0; ++ if (info->disk.number >= 0 && ++ (be16_to_cpu(ddf->phys->entries[info->disk.number].state) & DDF_Online) && ++ !(be16_to_cpu(ddf->phys->entries[info->disk.number].state) & DDF_Failed)) ++ info->disk.state = (1<container_member = ddf->currentconf->vcnum; diff --git a/DDF-really-ignore-DDF-metadata-on-partitions.patch b/DDF-really-ignore-DDF-metadata-on-partitions.patch new file mode 100644 index 0000000..8eb03ce --- /dev/null +++ b/DDF-really-ignore-DDF-metadata-on-partitions.patch @@ -0,0 +1,25 @@ +From a34fea0eae78fbabb289a5bce6d7a04bf889156d Mon Sep 17 00:00:00 2001 +From: NeilBrown +Date: Mon, 20 Jan 2014 12:25:23 +1100 +Subject: [PATCH 06/13] DDF - really ignore DDF metadata on partitions. + +See commit 357ac1067835d1cdd5f80acc28501db0ffc64957 +which made a similar change for super-intel, and really should have +fixed DDF at the same time. + +Signed-off-by: NeilBrown +--- + super-ddf.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- mdadm-3.3.orig/super-ddf.c ++++ mdadm-3.3/super-ddf.c +@@ -1126,7 +1126,7 @@ static int load_super_ddf(struct superty + if (get_dev_size(fd, devname, &dsize) == 0) + return 1; + +- if (!st->ignore_hw_compat && test_partition(fd)) ++ if (test_partition(fd)) + /* DDF is not allowed on partitions */ + return 1; + diff --git a/Grow-fix-problems-with-prematurely-aborting-of-resha.patch b/Grow-fix-problems-with-prematurely-aborting-of-resha.patch new file mode 100644 index 0000000..8686626 --- /dev/null +++ b/Grow-fix-problems-with-prematurely-aborting-of-resha.patch @@ -0,0 +1,58 @@ +From 5e7be8389446a4afa016351e65d1ead31a978f16 Mon Sep 17 00:00:00 2001 +From: NeilBrown +Date: Mon, 20 Jan 2014 15:31:45 +1100 +Subject: [PATCH 09/13] Grow: fix problems with prematurely aborting of + reshapes. + +1/ when unfreezing, make sure the array is frozen first. + If it isn't we might end up interrupting a reshape. +2/ When the child finishes, don't call abort_reshape() as that + will interrupt the reshape. Just set suspend_* etc + explicitly. + +Signed-off-by: NeilBrown +--- + Grow.c | 16 +++++++++++++--- + 1 file changed, 13 insertions(+), 3 deletions(-) + +--- mdadm-3.3.orig/Grow.c ++++ mdadm-3.3/Grow.c +@@ -612,9 +612,14 @@ static void unfreeze(struct supertype *s + return unfreeze_container(st); + else { + struct mdinfo *sra = sysfs_read(-1, st->devnm, GET_VERSION); ++ char buf[20]; + +- if (sra) ++ if (sra && ++ sysfs_get_str(sra, NULL, "sync_action", buf, 20) > 0 ++ && strcmp(buf, "frozen\n") == 0) { ++ printf("unfreeze\n"); + sysfs_set_str(sra, NULL, "sync_action", "idle"); ++ } + sysfs_free(sra); + } + } +@@ -2666,7 +2671,7 @@ static int impose_level(int fd, int leve + for (d = 0, found = 0; + d < MAX_DISKS && found < array.nr_disks; + d++) { +- mdu_disk_info_t disk; ++ mdu_disk_info_t disk; + disk.number = d; + if (ioctl(fd, GET_DISK_INFO, &disk) < 0) + continue; +@@ -4316,7 +4321,12 @@ int child_monitor(int afd, struct mdinfo + } + + /* FIXME maybe call progress_reshape one more time instead */ +- abort_reshape(sra); /* remove any remaining suspension */ ++ /* remove any remaining suspension */ ++ sysfs_set_num(sra, NULL, "suspend_lo", 0x7FFFFFFFFFFFFFFFULL); ++ sysfs_set_num(sra, NULL, "suspend_hi", 0); ++ sysfs_set_num(sra, NULL, "suspend_lo", 0); ++ sysfs_set_num(sra, NULL, "sync_min", 0); ++ + if (reshape->before.data_disks == reshape->after.data_disks) + sysfs_set_num(sra, NULL, "sync_speed_min", speed); + free(buf); diff --git a/IMSM-don-t-crash-when-creating-an-array-with-missing.patch b/IMSM-don-t-crash-when-creating-an-array-with-missing.patch new file mode 100644 index 0000000..b648c25 --- /dev/null +++ b/IMSM-don-t-crash-when-creating-an-array-with-missing.patch @@ -0,0 +1,25 @@ +From 1ca5c8e0c74946f4fcd74e97c5f48fba482d9596 Mon Sep 17 00:00:00 2001 +From: NeilBrown +Date: Tue, 21 Jan 2014 09:40:02 +1100 +Subject: [PATCH 10/13] IMSM: don't crash when creating an array with missing + devices. + +'missing' devices are in a different list so when collection the +serial numbers of all devices we need to check both lists. + +Signed-off-by: NeilBrown +--- + super-intel.c | 2 ++ + 1 file changed, 2 insertions(+) + +--- mdadm-3.3.orig/super-intel.c ++++ mdadm-3.3/super-intel.c +@@ -5210,6 +5210,8 @@ static int create_array(struct supertype + int idx = get_imsm_disk_idx(dev, i, MAP_X); + + disk = get_imsm_disk(super, idx); ++ if (!disk) ++ disk = get_imsm_missing(super, idx); + serialcpy(inf[i].serial, disk->serial); + } + append_metadata_update(st, u, len); diff --git a/mdadm.changes b/mdadm.changes index 8822dc7..d66a420 100644 --- a/mdadm.changes +++ b/mdadm.changes @@ -1,3 +1,23 @@ +------------------------------------------------------------------- +Wed Jan 22 04:54:22 UTC 2014 - nfbrown@suse.com + +- mdmonitor + run "mdadm --monitor" from systemd instead of init.d + sciprt (bnc#849523) +- remove mdadmd due to above. +- udev-rules-try-mdadm-I-on-change-events.patch + (bnc#851993) +- policy-NULL-path-isn-t-really-acceptable-use-the-dev.patch +- DDF-really-ignore-DDF-metadata-on-partitions.patch +- Assemble-avoid-infinite-loop-when-auto-assembling-pa.patch +- DDF-fix-detection-of-failed-devices-during-assembly.patch +- Grow-fix-problems-with-prematurely-aborting-of-resha.patch +- IMSM-don-t-crash-when-creating-an-array-with-missing.patch +- mdmon-don-t-complain-about-notifying-parent-when-the.patch +- systemd-mdmon-set-IMSM_NO_PLATFORM-1.patch +- mdmon-.service-remove-over-ride-of-Standard-IO.patch + Various upstream bug fixes. + ------------------------------------------------------------------- Wed Dec 4 23:57:16 UTC 2013 - nfbrown@suse.com diff --git a/mdadm.spec b/mdadm.spec index 9489422..7a74899 100644 --- a/mdadm.spec +++ b/mdadm.spec @@ -1,7 +1,7 @@ # # spec file for package mdadm # -# Copyright (c) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2014 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 @@ -37,7 +37,6 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-build Source: https://www.kernel.org/pub/linux/utils/raid/mdadm/%{name}-%{version}.tar.bz2 Source1: Software-RAID.HOWTO.tar.bz2 Source2: sysconfig.mdadm -Source3: mdadmd Source4: boot.md Source5: mkinitrd-setup.sh Source6: mkinitrd-boot.sh @@ -79,6 +78,28 @@ Patch15: udev-rules.degraded Patch16: Incremental-improve-support-for-DEVICE-based-restric.patch # PATCH-FIX-UPSTREAM Assemble-Incremental-don-t-hold-O_EXCL-on-mddev-afte.patch nfbrown@suse.de Patch17: Assemble-Incremental-don-t-hold-O_EXCL-on-mddev-afte.patch +# PATCH-FIX-UPSTREAM mdmonitor bnc#849523 nfbrown@suse.de +Patch18: mdmonitor +# PATCH-FIX-UPSTREAM udev-rules-try-mdadm-I-on-change-events.patch bnc#851993 nfbrown@suse.de +Patch19: udev-rules-try-mdadm-I-on-change-events.patch +# PATCH-FIX-UPSTREAM policy-NULL-path-isn-t-really-acceptable-use-the-dev.patch nfbrown@suse.de +Patch20: policy-NULL-path-isn-t-really-acceptable-use-the-dev.patch +# PATCH-FIX-UPSTREAM DDF-really-ignore-DDF-metadata-on-partitions.patch nfbrown@suse.de +Patch21: DDF-really-ignore-DDF-metadata-on-partitions.patch +# PATCH-FIX-UPSTREAM Assemble-avoid-infinite-loop-when-auto-assembling-pa.patch nfbrown@suse.de +Patch22: Assemble-avoid-infinite-loop-when-auto-assembling-pa.patch +# PATCH-FIX-UPSTREAM DDF-fix-detection-of-failed-devices-during-assembly.patch nfbrown@suse.de +Patch23: DDF-fix-detection-of-failed-devices-during-assembly.patch +# PATCH-FIX-UPSTREAM Grow-fix-problems-with-prematurely-aborting-of-resha.patch nfbrown@suse.de +Patch24: Grow-fix-problems-with-prematurely-aborting-of-resha.patch +# PATCH-FIX-UPSTREAM IMSM-don-t-crash-when-creating-an-array-with-missing.patch nfbrown@suse.de +Patch25: IMSM-don-t-crash-when-creating-an-array-with-missing.patch +# PATCH-FIX-UPSTREAM mdmon-don-t-complain-about-notifying-parent-when-the.patch nfbrown@suse.de +Patch26: mdmon-don-t-complain-about-notifying-parent-when-the.patch +# PATCH-FIX-UPSTREAM systemd-mdmon-set-IMSM_NO_PLATFORM-1.patch nfbrown@suse.de +Patch27: systemd-mdmon-set-IMSM_NO_PLATFORM-1.patch +# PATCH-FIX-UPSTREAM mdmon-.service-remove-over-ride-of-Standard-IO.patch nfbrown@suse.de +Patch28: mdmon-.service-remove-over-ride-of-Standard-IO.patch %define _udevdir %(pkg-config --variable=udevdir udev) %define _systemdshutdowndir %{_unitdir}/../system-shutdown @@ -107,26 +128,36 @@ programs but with a very different interface. %patch15 -p1 %patch16 -p1 %patch17 -p1 +%patch18 -p1 +%patch19 -p1 +%patch20 -p1 +%patch21 -p1 +%patch22 -p1 +%patch23 -p1 +%patch24 -p1 +%patch25 -p1 +%patch26 -p1 +%patch27 -p1 +%patch28 -p1 %build -make %{?_smp_mflags} CC="%__cc" CXFLAGS="$RPM_OPT_FLAGS -Wno-error" +make %{?_smp_mflags} CC="%__cc" CXFLAGS="$RPM_OPT_FLAGS -Wno-error" SUSE=yes cd Software-RAID.HOWTO sgml2html Software-RAID.HOWTO.sgml sgml2txt Software-RAID.HOWTO.sgml %install -make install install-systemd install-udev DESTDIR=%{buildroot} SYSTEMD_DIR=%{_unitdir} UDEVDIR=%{_udevdir} +make install install-systemd install-udev DESTDIR=%{buildroot} SYSTEMD_DIR=%{_unitdir} UDEVDIR=%{_udevdir} SUSE=yes rm -rf %{buildroot}/lib/udev install -d %{buildroot}%{_var}/adm/fillup-templates install -d %{buildroot}{%{_sbindir},%{_sysconfdir}/init.d} -install -m 755 %{S:4} %{S:3} %{buildroot}%{_sysconfdir}/init.d/ +install -m 755 %{S:4} %{buildroot}%{_sysconfdir}/init.d/ install -d %{buildroot}/lib/mkinitrd/scripts install -m 755 %{S:5} %{buildroot}/lib/mkinitrd/scripts/setup-md.sh install -m 755 %{S:6} %{buildroot}/lib/mkinitrd/scripts/boot-md.sh install -d %{buildroot}/etc/cron.daily install -m 755 %{S:7} %{buildroot}/etc/cron.daily/mdadm install -m 644 %{S:2} %{buildroot}%{_var}/adm/fillup-templates/ -ln -sf ../../etc/init.d/mdadmd %{buildroot}/%{_sbindir}/rcmdadmd install -d %{buildroot}%{_systemdshutdowndir} install -m 755 %{S:8} %{buildroot}%{_systemdshutdowndir}/mdadm.shutdown install -m 644 %{S:9} %{buildroot}%{_unitdir}/mdadm-last-resort@.timer @@ -144,7 +175,6 @@ fi %{fillup_and_insserv -y boot.md} %postun -%restart_on_update mdadmd [ -x /sbin/mkinitrd_setup ] && mkinitrd_setup if [ -e /var/lib/no_initrd_recreation_by_suspend ]; then echo "Skipping recreation of existing initial ramdisks, due" @@ -156,7 +186,6 @@ fi %{insserv_cleanup} %preun -%stop_on_removal mdadmd %clean rm -rf %{buildroot} @@ -168,7 +197,6 @@ rm -rf %{buildroot} %doc Software-RAID.HOWTO/Software-RAID.HOWTO*{.txt,.html} %doc %{_mandir}/man?/* /sbin/* -%{_sbindir}/* %{_var}/adm/fillup-templates/sysconfig.mdadm %dir /lib/mkinitrd %dir /lib/mkinitrd/scripts @@ -176,12 +204,14 @@ rm -rf %{buildroot} /lib/mkinitrd/scripts/boot-md.sh %{_udevdir}/rules.d/63-md-raid-arrays.rules %{_udevdir}/rules.d/64-md-raid-assembly.rules -%dir /etc %dir /etc/cron.daily /etc/cron.daily/mdadm %{_systemdshutdowndir}/mdadm.shutdown %{_unitdir}/mdmon@.service +%{_unitdir}/mdmonitor.service %{_unitdir}/mdadm-last-resort@.timer %{_unitdir}/mdadm-last-resort@.service +%dir %{_unitdir}/../scripts +%{_unitdir}/../scripts/mdadm_env.sh %changelog diff --git a/mdadmd b/mdadmd deleted file mode 100644 index 9975b1a..0000000 --- a/mdadmd +++ /dev/null @@ -1,150 +0,0 @@ -#! /bin/sh -# Copyright (c) 1995-2002 SuSE Linux AG, Nuernberg, Germany. -# All rights reserved. -# -# Author: Petr Ostadal, feedback to http://www.suse.de/feedback -# -# /etc/init.d/mdadmd -# -# and its symbolic link -# -# /usr/sbin/rcmdadmd -# -### BEGIN INIT INFO -# Provides: mdadmd -# Required-Start: $local_fs -# Should-Start: $time sendmail -# Required-Stop: $local_fs -# Should-Stop: $time sendmail -# Default-Start: 3 5 -# Default-Stop: 0 1 2 6 -# Short-Description: mdadmd daemon monitoring MD devices -# Description: Start mdadmd to allow monitoring MD devices aka -# Linux Software Raid. This is only meaningful for raid1, raid5 -# or multipath arrays as only these have interesting state. -# raid0 or linear never have missing, spare, or failed drives, -# so there is nothing to monitor. -### END INIT INFO - -mdadmd_BIN=/sbin/mdadm -test -x $mdadmd_BIN || exit 5 - -mdadmd_CONFIG=/etc/sysconfig/mdadm -test -r $mdadmd_CONFIG || exit 6 -. $mdadmd_CONFIG - -if [ x$MDADM_DELAY = x"" ]; then - MDADM_DELAY=60 -fi -MDADM_DELAY="-d "$MDADM_DELAY; - -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_SEND_MAIL_ON_START = x"yes" ]; then - MDADM_SEND_MAIL="-t" -else - MDADM_SEND_MAIL="" -fi - -if [ x$MDADM_CONFIG != x"" ]; then - MDADM_CONFIG="-c \"$MDADM_CONFIG\"" -fi - -. /etc/rc.status - -# Reset status of this service -rc_reset - -# Return values acc. to LSB for all commands but status: -# 0 - success -# 1 - generic or unspecified error -# 2 - invalid or excess argument(s) -# 3 - unimplemented feature (e.g. "reload") -# 4 - user had insufficient privileges -# 5 - program is not installed -# 6 - program is not configured -# 7 - program is not running -# 8--199 - reserved (8--99 LSB, 100--149 distrib, 150--199 appl) -# -# Note that starting an already running service, stopping -# or restarting a not-running service as well as the restart -# with force-reload (in case signaling is not supported) are -# considered a success. - -case "$1" in - start) - echo -n "Starting mdadmd " - ## Start daemon with startproc(8). If this fails - ## the return value is set appropriately by startproc. - eval startproc -q -s $mdadmd_BIN -F $MDADM_RAIDDEVICES $MDADM_DELAY $MDADM_MAIL $MDADM_PROGRAM $MDADM_SCAN $MDADM_SEND_MAIL $MDADM_CONFIG - - # Remember status and be verbose - rc_status -v - ;; - stop) - echo -n "Shutting down mdadmd " - ## Stop daemon with killproc(8) and if this fails - ## killproc sets the return value according to LSB. - - killproc -TERM $mdadmd_BIN - - # Remember status and be verbose - rc_status -v - ;; - try-restart) - ## Do a restart only if the service was active before. - ## Note: try-restart is not (yet) part of LSB (as of 1.2) - $0 status >/dev/null && $0 restart - - # Remember status and be quiet - rc_status - ;; - restart) - ## Stop the service and regardless of whether it was - ## running or not, start it again. - $0 stop - $0 start - - # Remember status and be quiet - rc_status - ;; - reload) - exit 3 - ;; - status) - echo -n "Checking for service mdadmd " - ## Check status with checkproc(8), if process is running - ## checkproc will return with exit status 0. - - # Return value is slightly different for the status command: - # 0 - service up and running - # 1 - service dead, but /var/run/ pid file exists - # 2 - service dead, but /var/lock/ lock file exists - # 3 - service not running (unused) - # 4 - service status unknown :-( - # 5--199 reserved (5--99 LSB, 100--149 distro, 150--199 appl.) - - # NOTE: checkproc returns LSB compliant status values. - checkproc $mdadmd_BIN - # NOTE: rc_status knows that we called this init script with - # "status" option and adapts its messages accordingly. - rc_status -v - ;; - *) - echo "Usage: $0 {start|stop|status|try-restart|restart}" - exit 1 - ;; -esac -rc_exit diff --git a/mdmon-.service-remove-over-ride-of-Standard-IO.patch b/mdmon-.service-remove-over-ride-of-Standard-IO.patch new file mode 100644 index 0000000..881cb04 --- /dev/null +++ b/mdmon-.service-remove-over-ride-of-Standard-IO.patch @@ -0,0 +1,24 @@ +From 1f6b069494c1ecf8014a76fb10e8c8f5f6c27365 Mon Sep 17 00:00:00 2001 +From: NeilBrown +Date: Wed, 22 Jan 2014 12:53:31 +1100 +Subject: [PATCH 13/13] mdmon@.service: remove over-ride of Standard IO. + +Redirecting output to /dev/null is unnecessary and hides any error +messages there might be. So leave as defaults which are none, +journal, inherit. + +Signed-off-by: NeilBrown +--- + systemd/mdmon@.service | 3 --- + 1 file changed, 3 deletions(-) + +--- mdadm-3.3.orig/systemd/mdmon@.service ++++ mdadm-3.3/systemd/mdmon@.service +@@ -15,7 +15,4 @@ Before=initrd-switch-root.target + # that is mdadm's job if at all. + Environment=IMSM_NO_PLATFORM=1 + ExecStart=/sbin/mdmon --foreground %I +-StandardInput=null +-StandardOutput=null +-StandardError=null + KillMode=none diff --git a/mdmon-don-t-complain-about-notifying-parent-when-the.patch b/mdmon-don-t-complain-about-notifying-parent-when-the.patch new file mode 100644 index 0000000..378fa51 --- /dev/null +++ b/mdmon-don-t-complain-about-notifying-parent-when-the.patch @@ -0,0 +1,43 @@ +From 5e57245e3feba65385fc100e0f2c3d1214d79915 Mon Sep 17 00:00:00 2001 +From: NeilBrown +Date: Tue, 21 Jan 2014 09:43:31 +1100 +Subject: [PATCH 11/13] mdmon: don't complain about notifying parent when there + is no need + +When run with --foreground mdmon has no need to notify any +parent, so it shouldn't even try, let alone complain when it fails. + +Also close an end of a pipe which is no longer used. + +Signed-off-by: NeilBrown +--- + mdmon.c | 11 +++++++---- + 1 file changed, 7 insertions(+), 4 deletions(-) + +--- mdadm-3.3.orig/mdmon.c ++++ mdadm-3.3/mdmon.c +@@ -429,6 +429,7 @@ static int mdmon(char *devnm, int must_f + wait(&status); + status = WEXITSTATUS(status); + } ++ close(pfd[0]); + return status; + } + } else +@@ -516,10 +517,12 @@ static int mdmon(char *devnm, int must_f + container->sock = make_control_sock(devnm); + + status = 0; +- if (write(pfd[1], &status, sizeof(status)) < 0) +- pr_err("failed to notify our parent: %d\n", +- getppid()); +- close(pfd[1]); ++ if (pfd[1] >= 0) { ++ if (write(pfd[1], &status, sizeof(status)) < 0) ++ pr_err("failed to notify our parent: %d\n", ++ getppid()); ++ close(pfd[1]); ++ } + + mlockall(MCL_CURRENT | MCL_FUTURE); + diff --git a/mdmonitor b/mdmonitor new file mode 100644 index 0000000..45b7670 --- /dev/null +++ b/mdmonitor @@ -0,0 +1,117 @@ +From 61c094715836e76b66d7a69adcb6769127b5b77d Mon Sep 17 00:00:00 2001 +From: NeilBrown +Date: Wed, 11 Dec 2013 10:47:54 +1100 +Subject: [PATCH] Add mdmonitor.service systemd unit file. +References: bnc#849523 + +This systemd unit file runs mdadm in --monitor mode. +It is started by a SYSTEMD_WANTS signal from udev whenever +an md array is started that would benefit from mdadm --monitor. + +Commandline arguments can be provided by a script + /usr/lib/systemd/scripts/mdadm_env.sh +which should write an + MDADM_MONITOR_ARGS=.... +line to /run/sysconfig/mdadm + +A script to extra args from SUSE's /etc/sysconfig/mdadm file +is provided. +If no mdadm_env.sh is provided, then args are "--scan" which +requires "mail" or "program" to be set in /etc/mdadm.conf. +I believe this is suitable for Fedora. + +Signed-off-by: NeilBrown +--- + Makefile | 2 ++ + systemd/SUSE-mdadm_env.sh | 45 +++++++++++++++++++++++++++++++++++++++++++++ + systemd/mdmonitor.service | 16 ++++++++++++++++ + udev-md-raid-arrays.rules | 2 ++ + 4 files changed, 65 insertions(+) + +--- mdadm-3.3.orig/Makefile ++++ mdadm-3.3/Makefile +@@ -285,6 +285,8 @@ install-udev: udev-md-raid-arrays.rules + + install-systemd: systemd/mdmon@.service + $(INSTALL) -D -m 644 systemd/mdmon@.service $(DESTDIR)$(SYSTEMD_DIR)/mdmon@.service ++ $(INSTALL) -D -m 644 systemd/mdmonitor.service $(DESTDIR)$(SYSTEMD_DIR)/mdmonitor.service ++ [ -f /etc/SuSE-release -o -n "$(SUSE)" ] && $(INSTALL) -D -m 755 systemd/SUSE-mdadm_env.sh $(DESTDIR)$(SYSTEMD_DIR)/../scripts/mdadm_env.sh || true + + uninstall: + rm -f $(DESTDIR)$(MAN8DIR)/mdadm.8 $(DESTDIR)$(MAN8DIR)/mdmon.8 $(DESTDIR)$(MAN4DIR)/md.4 $(DESTDIR)$(MAN5DIR)/mdadm.conf.5 $(DESTDIR)$(BINDIR)/mdadm +--- /dev/null ++++ mdadm-3.3/systemd/SUSE-mdadm_env.sh +@@ -0,0 +1,45 @@ ++#!/bin/sh ++ ++# extract configuration from /etc/sysconfig/mdadm and write ++# environment to /run/sysconfig/mdadm to be used by ++# systemd unit files. ++ ++MDADM_SCAN="yes" ++ ++# Following adapted from /etc/init.d/mdadmd on openSUSE ++ ++mdadmd_CONFIG=/etc/sysconfig/mdadm ++if test -r $mdadmd_CONFIG; then ++ . $mdadmd_CONFIG ++fi ++ ++if [ x$MDADM_DELAY != x"" ]; then ++ MDADM_DELAY="-d "$MDADM_DELAY; ++fi ++ ++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="--scan" ++else ++ MDADM_SCAN="" ++fi ++ ++if [ x$MDADM_SEND_MAIL_ON_START = x"yes" ]; then ++ MDADM_SEND_MAIL="-t" ++else ++ MDADM_SEND_MAIL="" ++fi ++ ++if [ x$MDADM_CONFIG != x"" ]; then ++ MDADM_CONFIG="-c \"$MDADM_CONFIG\"" ++fi ++ ++mkdir -p /run/sysconfig ++echo "MDADM_MONITOR_ARGS=$MDADM_RAIDDEVICES $MDADM_DELAY $MDADM_MAIL $MDADM_PROGRAM $MDADM_SCAN $MDADM_SEND_MAIL $MDADM_CONFIG" > /run/sysconfig/mdadm +--- /dev/null ++++ mdadm-3.3/systemd/mdmonitor.service +@@ -0,0 +1,16 @@ ++# This file is part of mdadm. ++# ++# mdadm is free software; you can redistribute it and/or modify it ++# under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 2 of the License, or ++# (at your option) any later version. ++ ++[Unit] ++Description=MD array monitor ++DefaultDependencies=no ++ ++[Service] ++Environment= MDADM_MONITOR_ARGS=--scan ++EnvironmentFile=-/run/sysconfig/mdadm ++ExecStartPre=-/usr/lib/systemd/scripts/mdadm_env.sh ++ExecStart=/sbin/mdadm --monitor $MDADM_MONITOR_ARGS +--- mdadm-3.3.orig/udev-md-raid-arrays.rules ++++ mdadm-3.3/udev-md-raid-arrays.rules +@@ -32,4 +32,6 @@ OPTIONS+="watch" + ENV{ID_FS_USAGE}=="filesystem|other|crypto", ENV{ID_FS_UUID_ENC}=="?*", SYMLINK+="disk/by-uuid/$env{ID_FS_UUID_ENC}" + ENV{ID_FS_USAGE}=="filesystem|other", ENV{ID_FS_LABEL_ENC}=="?*", SYMLINK+="disk/by-label/$env{ID_FS_LABEL_ENC}" + ++ENV{MD_LEVEL}=="raid[1-9]*", ENV{SYSTEMD_WANTS}+="mdmonitor.service" ++ + LABEL="md_end" diff --git a/policy-NULL-path-isn-t-really-acceptable-use-the-dev.patch b/policy-NULL-path-isn-t-really-acceptable-use-the-dev.patch new file mode 100644 index 0000000..16c7c2e --- /dev/null +++ b/policy-NULL-path-isn-t-really-acceptable-use-the-dev.patch @@ -0,0 +1,64 @@ +From 75a721fd7d5e5ee7e578571fe58755fe07e446fc Mon Sep 17 00:00:00 2001 +From: Lukasz Dorau +Date: Thu, 19 Dec 2013 13:02:12 +0100 +Subject: [PATCH 05/13] policy: NULL path isn't really acceptable - use the + devname + +According to: + commit b451aa4846c5ccca5447a6b6d45e5623b8c8e961 + Fix handling for "auto" line in mdadm.conf + +a NULL path isn't really acceptable and the devname should be used instead. + +Signed-off-by: Lukasz Dorau +Signed-off-by: NeilBrown +--- + policy.c | 35 +++++++++++++++++------------------ + 1 file changed, 17 insertions(+), 18 deletions(-) + +--- mdadm-3.3.orig/policy.c ++++ mdadm-3.3/policy.c +@@ -200,26 +200,25 @@ static char *disk_path(struct mdinfo *di + int rv; + + by_path = opendir(symlink); +- if (!by_path) +- return NULL; +- prefix_len = strlen(symlink); +- +- while ((ent = readdir(by_path)) != NULL) { +- if (ent->d_type != DT_LNK) +- continue; +- strncpy(symlink + prefix_len, +- ent->d_name, +- sizeof(symlink) - prefix_len); +- if (stat(symlink, &stb) < 0) +- continue; +- if ((stb.st_mode & S_IFMT) != S_IFBLK) +- continue; +- if (stb.st_rdev != makedev(disk->disk.major, disk->disk.minor)) +- continue; ++ if (by_path) { ++ prefix_len = strlen(symlink); ++ while ((ent = readdir(by_path)) != NULL) { ++ if (ent->d_type != DT_LNK) ++ continue; ++ strncpy(symlink + prefix_len, ++ ent->d_name, ++ sizeof(symlink) - prefix_len); ++ if (stat(symlink, &stb) < 0) ++ continue; ++ if ((stb.st_mode & S_IFMT) != S_IFBLK) ++ continue; ++ if (stb.st_rdev != makedev(disk->disk.major, disk->disk.minor)) ++ continue; ++ closedir(by_path); ++ return xstrdup(ent->d_name); ++ } + closedir(by_path); +- return xstrdup(ent->d_name); + } +- closedir(by_path); + /* A NULL path isn't really acceptable - use the devname.. */ + sprintf(symlink, "/sys/dev/block/%d:%d", disk->disk.major, disk->disk.minor); + rv = readlink(symlink, nm, sizeof(nm)-1); diff --git a/systemd-mdadm-last-resort@.timer b/systemd-mdadm-last-resort@.timer index 8354dad..735b2b9 100644 --- a/systemd-mdadm-last-resort@.timer +++ b/systemd-mdadm-last-resort@.timer @@ -1,6 +1,7 @@ [Unit] Description=Timer to wait for more drives before activating degraded array. DefaultDependencies=no +Conflicts=sys-devices-virtual-block-%i.device [Timer] OnActiveSec=30 diff --git a/systemd-mdmon-set-IMSM_NO_PLATFORM-1.patch b/systemd-mdmon-set-IMSM_NO_PLATFORM-1.patch new file mode 100644 index 0000000..2f6b784 --- /dev/null +++ b/systemd-mdmon-set-IMSM_NO_PLATFORM-1.patch @@ -0,0 +1,28 @@ +From 67ee238316785481a8ad440e531cae6c4dce36a4 Mon Sep 17 00:00:00 2001 +From: NeilBrown +Date: Tue, 21 Jan 2014 09:46:07 +1100 +Subject: [PATCH 12/13] systemd/mdmon: set IMSM_NO_PLATFORM=1 + +As mdmon doesn't inherit environment from mdadm when it is started +by system, it cannot inherit IMSM_NO_PLATFORM. +But if an imsm array as assembled then mdmon really should handle it +whether there is a platform present or not. +So always set this var. + +Signed-off-by: NeilBrown +--- + systemd/mdmon@.service | 3 +++ + 1 file changed, 3 insertions(+) + +--- mdadm-3.3.orig/systemd/mdmon@.service ++++ mdadm-3.3/systemd/mdmon@.service +@@ -11,6 +11,9 @@ DefaultDependencies=no + Before=initrd-switch-root.target + + [Service] ++# mdmon should never complain due to lack of a platform, ++# that is mdadm's job if at all. ++Environment=IMSM_NO_PLATFORM=1 + ExecStart=/sbin/mdmon --foreground %I + StandardInput=null + StandardOutput=null diff --git a/udev-rules-try-mdadm-I-on-change-events.patch b/udev-rules-try-mdadm-I-on-change-events.patch new file mode 100644 index 0000000..c08cf09 --- /dev/null +++ b/udev-rules-try-mdadm-I-on-change-events.patch @@ -0,0 +1,32 @@ +From 25392f5fc59f96fb766ecb5617d5276f8c87d489 Mon Sep 17 00:00:00 2001 +From: NeilBrown +Date: Wed, 11 Dec 2013 12:29:22 +1100 +Subject: [PATCH 02/13] udev rules: try "mdadm -I" on "change" events. +References: bnc#851993 + +We need to attempt "mdadm -I" on "change" events as well as "add" events, +as the "change" make make a device ready to be part of an array. +This is particularly important for stacked md devices. When the +member devices are "add"ed they don't have any content visible yet. +That doesn't happen until a "change". + +Idea taken from Fedora udev file. + +Signed-off-by: NeilBrown +--- + udev-md-raid-assembly.rules | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +--- mdadm-3.3.orig/udev-md-raid-assembly.rules ++++ mdadm-3.3/udev-md-raid-assembly.rules +@@ -12,8 +12,8 @@ LABEL="md_inc" + + # remember you can limit what gets auto/incrementally assembled by + # mdadm.conf(5)'s 'AUTO' and selectively whitelist using 'ARRAY' +-ACTION=="add", IMPORT{program}="/sbin/mdadm --incremental --export $devnode --offroot ${DEVLINKS}" +-ACTION=="add", ENV{MD_STARTED}=="*unsafe*", ENV{MD_FOREIGN}=="no", ENV{SYSTEMD_WANTS}+="mdadm-last-resort@$env{MD_DEVICE}.timer" ++ACTION=="add|change", IMPORT{program}="/sbin/mdadm --incremental --export $devnode --offroot ${DEVLINKS}" ++ACTION=="add|change", ENV{MD_STARTED}=="*unsafe*", ENV{MD_FOREIGN}=="no", ENV{SYSTEMD_WANTS}+="mdadm-last-resort@$env{MD_DEVICE}.timer" + ACTION=="remove", ENV{ID_PATH}=="?*", RUN+="/sbin/mdadm -If $name --path $env{ID_PATH}" + ACTION=="remove", ENV{ID_PATH}!="?*", RUN+="/sbin/mdadm -If $name" +