diff -Nru mdadm-3.3/debian/changelog mdadm-3.3/debian/changelog --- mdadm-3.3/debian/changelog 2016-04-11 18:40:45.000000000 +0000 +++ mdadm-3.3/debian/changelog 2017-03-16 13:33:18.000000000 +0000 @@ -1,3 +1,47 @@ +mdadm (3.3-2ubuntu7.3) xenial; urgency=medium + + * Cherrypick 0001-mdmon-honour-offroot-again.patch from v3.4, such that + --offroot option to mdmon sets argv[0][0]='@' and thus regain ability + to start mdmon from the root filesystem with --offroot option and + dodge systemd-shutdown's killall on shutdowns. + * Use --offroot flag in mdadm init.d script when taking over mdmon, such + that mdmon stays alive during shutdown under either systemd or + sysvinit. + * Add systemd shutdown script to wait for all arrays to be clean on + shutdown. + * This should resolve unclean shutdown of IMSM raid device, and thus not + result in dirty/resyncing arrays on every reboot. LP: #1608495 + + + -- Dimitri John Ledkov Thu, 16 Mar 2017 13:05:14 +0000 + +mdadm (3.3-2ubuntu7.2) xenial; urgency=medium + + * Backport initramfs changes from 3.4-4, to improve reliability of + booting with degraded arrays. LP: #1635049 + + * debian/initramfs/hook: + - Fix UUID= grep for configured RAIDs to be case insensitive. + - Drop CREATE stanzas from mkconf and don't include them in the + initramfs. The generated defaults, are the compiled-in defaults. And + the current one generates warnings when running mdadm in the + initramfs, as there is no passwd|group files to resolve root/disk + uid/gid. + * debian/initrmafs/script.local-block|script.local-bottom: + - Use local-block integration scrips, in favor of root-fail hooks to + activate incomplete arrays. + * debian/initramfs/init-premount|mdadm-functions: + - Drop, no longer in use. + + -- Dimitri John Ledkov Mon, 20 Feb 2017 10:57:43 +0000 + +mdadm (3.3-2ubuntu7.1) xenial-proposed; urgency=medium + + * debian/source_mdadm.py: fix bytes versus strings mismatch that + caused the apport hook to fail (LP: #1583279) + + -- Steve Beattie Wed, 18 May 2016 15:24:48 -0700 + mdadm (3.3-2ubuntu7) xenial; urgency=medium * Do not start when inside a container (LP: #1568993) diff -Nru mdadm-3.3/debian/initramfs/hook mdadm-3.3/debian/initramfs/hook --- mdadm-3.3/debian/initramfs/hook 2014-07-16 15:52:38.000000000 +0000 +++ mdadm-3.3/debian/initramfs/hook 2017-02-20 10:50:29.000000000 +0000 @@ -83,6 +83,7 @@ fi else cp -p $CONFIG ${DESTDIR}/etc/mdadm + sed -i '/^CREATE/s/^/#/' $DESTMDADMCONF if ! grep -q '^ARRAY' $CONFIG; then tmpfile="${DESTMDADMCONF}.tmp" warn "$CONFIG defines no arrays." @@ -95,7 +96,7 @@ # make sure the configuration file knows about all running devices /sbin/mdadm --detail --scan | while read array device params; do uuid=${params#*UUID=}; uuid=${uuid%% *} - if ! grep -q "UUID=$uuid" $DESTMDADMCONF; then + if ! grep -qi "UUID=$uuid" $DESTMDADMCONF; then warn "the array $device with UUID $uuid" warn "is currently active, but it is not listed in mdadm.conf. if" warn "it is needed for boot, then YOUR SYSTEM IS NOW UNBOOTABLE!" diff -Nru mdadm-3.3/debian/initramfs/init-premount mdadm-3.3/debian/initramfs/init-premount --- mdadm-3.3/debian/initramfs/init-premount 2014-07-16 15:02:56.000000000 +0000 +++ mdadm-3.3/debian/initramfs/init-premount 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -#!/bin/sh - -# init-premount script for mdadm. - -PREREQS="udev" - -prereqs() -{ - echo $PREREQS -} - -[ "$1" = "prereqs" ] || . /scripts/mdadm-functions - -case $1 in -# get pre-requisites -prereqs) - prereqs - exit 0 - ;; -mountfail) - mountroot_fail - exit $? - ;; -esac - -. /scripts/functions - -add_mountroot_fail_hook "10-mdadm" - -exit 0 - diff -Nru mdadm-3.3/debian/initramfs/mdadm-functions mdadm-3.3/debian/initramfs/mdadm-functions --- mdadm-3.3/debian/initramfs/mdadm-functions 2014-07-16 15:29:30.000000000 +0000 +++ mdadm-3.3/debian/initramfs/mdadm-functions 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -#!/bin/sh - -. /scripts/functions - -txt_message () -{ - if [ -x /bin/plymouth ] && plymouth --ping; then - return 0 - else - echo "$@" >&2 - fi - return 0 -} - -message() -{ - if [ -x /bin/plymouth ] && plymouth --ping; then - plymouth message --text="$@" - else - echo "$@" >&2 - fi - return 0 -} - - -mountroot_fail() -{ - wait_for_udev 10 - message "Incrementally starting RAID arrays..." - if mdadm --incremental --run --scan; then - message "Incrementally started RAID arrays." - return 0 - else - if mdadm --assemble --scan --run; then - message "Assembled and started RAID arrays." - return 0 - else - message "Could not start RAID arrays in degraded mode." - fi - fi - return 1 -} diff -Nru mdadm-3.3/debian/initramfs/script.local-block mdadm-3.3/debian/initramfs/script.local-block --- mdadm-3.3/debian/initramfs/script.local-block 1970-01-01 00:00:00.000000000 +0000 +++ mdadm-3.3/debian/initramfs/script.local-block 2017-02-20 10:53:06.000000000 +0000 @@ -0,0 +1,61 @@ +#!/bin/sh + +PREREQ="multipath" + +prereqs() +{ + echo "$PREREQ" +} + +case $1 in +# get pre-requisites +prereqs) + prereqs + exit 0 + ;; +esac + +. /scripts/functions + +# Poor man's mdadm-last-resort@.timer +# That kicks in 2/3rds into the ROOTDELAY + +if [ ! -f /run/count.mdadm.initrd ] +then + COUNT=0 + + # Unfortunately raid personalities can be registered _after_ block + # devices have already been added, and their rules processed, try + # triggering again. See #830770 + udevadm trigger --action=add -s block || true + wait_for_udev 10 +else + COUNT=$(cat /run/count.mdadm.initrd) +fi +COUNT=$((COUNT + 1)) + +echo $COUNT > /run/count.mdadm.initrd + +# Run pure assemble command, even though we default to incremental +# assembly it is supported for users to export variables via +# param.conf such as IMSM_NO_PLATFORM. See #830300 +mdadm -q --assemble --scan --no-degraded || true + +MAX=30 +if [ ${ROOTDELAY:-0} -gt $MAX ]; then + MAX=$ROOTDELAY +fi +MAX=$((MAX*2/3)) + +if [ "$COUNT" = "$MAX" ] +then + # Poor man's mdadm-last-resort@.service for incremental devices + mdadm -q --run /dev/md?* + + # And last try for all others + mdadm -q --assemble --scan --run + + rm -f /run/count.mdadm.initrd +fi + +exit 0 diff -Nru mdadm-3.3/debian/initramfs/script.local-bottom mdadm-3.3/debian/initramfs/script.local-bottom --- mdadm-3.3/debian/initramfs/script.local-bottom 1970-01-01 00:00:00.000000000 +0000 +++ mdadm-3.3/debian/initramfs/script.local-bottom 2017-02-20 11:14:00.000000000 +0000 @@ -0,0 +1,3 @@ +#!/bin/sh +rm -f /run/count.mdadm.initrd +exit 0 diff -Nru mdadm-3.3/debian/mdadm.dirs mdadm-3.3/debian/mdadm.dirs --- mdadm-3.3/debian/mdadm.dirs 2014-07-16 15:02:56.000000000 +0000 +++ mdadm-3.3/debian/mdadm.dirs 2017-02-20 11:13:51.000000000 +0000 @@ -3,8 +3,6 @@ etc/default/grub.d usr/share/mdadm /usr/share/apport/package-hooks -usr/share/initramfs-tools/hooks -usr/share/initramfs-tools/scripts/init-premount usr/share/bug/mdadm usr/share/lintian/overrides var/lib/mdadm diff -Nru mdadm-3.3/debian/mdadm.init mdadm-3.3/debian/mdadm.init --- mdadm-3.3/debian/mdadm.init 2016-04-11 18:40:45.000000000 +0000 +++ mdadm-3.3/debian/mdadm.init 2017-03-16 12:57:58.000000000 +0000 @@ -62,9 +62,9 @@ set -e fi if [ "$(echo $RUNDIR/md[0-9]*.pid)" != "$RUNDIR/md[0-9]*.pid" ]; then - log_daemon_msg "Restarting MD external metadata monitor" "mdmon --takeover --all" + log_daemon_msg "Restarting MD external metadata monitor" "mdmon --takeover --all --offroot" set +e - $MDMON --takeover --all + $MDMON --takeover --all --offroot log_end_msg $? set -e fi diff -Nru mdadm-3.3/debian/mdadm.install mdadm-3.3/debian/mdadm.install --- mdadm-3.3/debian/mdadm.install 1970-01-01 00:00:00.000000000 +0000 +++ mdadm-3.3/debian/mdadm.install 2017-03-16 13:35:54.000000000 +0000 @@ -0,0 +1 @@ +debian/mdadm.shutdown lib/systemd/system-shutdown/ diff -Nru mdadm-3.3/debian/mdadm.shutdown mdadm-3.3/debian/mdadm.shutdown --- mdadm-3.3/debian/mdadm.shutdown 1970-01-01 00:00:00.000000000 +0000 +++ mdadm-3.3/debian/mdadm.shutdown 2017-03-16 13:32:31.000000000 +0000 @@ -0,0 +1,4 @@ +#!/bin/sh +# We need to ensure all md arrays with external metadata +# (e.g. IMSM, DDF) are clean before completing the shutdown. +/sbin/mdadm --wait-clean --scan diff -Nru mdadm-3.3/debian/patches/0001-mdmon-honour-offroot-again.patch mdadm-3.3/debian/patches/0001-mdmon-honour-offroot-again.patch --- mdadm-3.3/debian/patches/0001-mdmon-honour-offroot-again.patch 1970-01-01 00:00:00.000000000 +0000 +++ mdadm-3.3/debian/patches/0001-mdmon-honour-offroot-again.patch 2017-03-16 12:54:17.000000000 +0000 @@ -0,0 +1,40 @@ +From 5d79c72e16b32d7d6d0f535348286a7f2a966092 Mon Sep 17 00:00:00 2001 +From: "mwilck@arcor.de" +Date: Wed, 11 Sep 2013 22:15:19 +0200 +Subject: [PATCH] mdmon: honour --offroot, again + +commit 3e32ba9d removed support for --offroot, and a9c15847 made +mdmon use @ in argv[0] only when started from initrd. + +This breaks mdadm in OpenSUSE 12.3, which starts mdmon from the +root file system and relies on --offroot to work as documented earlier. + +Reintroducing --offroot as an undocumented option, as its use is going to +go away soon anyway. + +If this can't be applied, it should probably be included as distro-specific +patch if mdadm 3.3 is built for OpenSUSE 12.3. I haven't checked if the +patch is necesary for OpenSUSE Factory, too. + +Signed-off-by: Martin Wilck +Signed-off-by: NeilBrown +--- + mdmon.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/mdmon.c b/mdmon.c +index f0b0623..8cd53d8 100644 +--- a/mdmon.c ++++ b/mdmon.c +@@ -320,7 +320,7 @@ int main(int argc, char *argv[]) + dofork = 0; + break; + case OffRootOpt: +- /* silently ignore old option */ ++ argv[0][0] = '@'; + break; + case 'h': + default: +-- +2.7.4 + diff -Nru mdadm-3.3/debian/patches/series mdadm-3.3/debian/patches/series --- mdadm-3.3/debian/patches/series 2014-07-16 15:54:32.000000000 +0000 +++ mdadm-3.3/debian/patches/series 2017-03-16 12:54:17.000000000 +0000 @@ -5,3 +5,4 @@ remove-bashism-from-makefile.patch #disable use-external-blkid.diff in ubuntu dmraid-fallback.patch +0001-mdmon-honour-offroot-again.patch diff -Nru mdadm-3.3/debian/rules mdadm-3.3/debian/rules --- mdadm-3.3/debian/rules 2016-02-19 17:26:09.000000000 +0000 +++ mdadm-3.3/debian/rules 2017-02-20 10:57:21.000000000 +0000 @@ -65,14 +65,14 @@ $(MAKE) install DESTDIR=$(DESTDIR) - install -m0755 debian/initramfs/hook \ + install -Dm0755 debian/initramfs/hook \ $(DESTDIR)/usr/share/initramfs-tools/hooks/mdadm - install -m0755 debian/initramfs/init-premount \ - $(DESTDIR)/usr/share/initramfs-tools/scripts/init-premount/mdadm + install -Dm0755 debian/initramfs/script.local-block \ + $(DESTDIR)/usr/share/initramfs-tools/scripts/local-block/mdadm - install -m0755 debian/initramfs/mdadm-functions \ - $(DESTDIR)/usr/share/initramfs-tools/scripts/mdadm-functions + install -Dm0755 debian/initramfs/script.local-bottom \ + $(DESTDIR)/usr/share/initramfs-tools/scripts/local-bottom/mdadm install -m0755 debian/mkconf $(DESTDIR)/usr/share/mdadm install -m0755 debian/checkarray $(DESTDIR)/usr/share/mdadm diff -Nru mdadm-3.3/debian/source_mdadm.py mdadm-3.3/debian/source_mdadm.py --- mdadm-3.3/debian/source_mdadm.py 2014-07-16 15:02:56.000000000 +0000 +++ mdadm-3.3/debian/source_mdadm.py 2016-05-18 22:24:30.000000000 +0000 @@ -1,17 +1,18 @@ '''apport package hook for mdadm -(c) 2009-2012 Canonical Ltd. +(c) 2009-2016 Canonical Ltd. Author: Steve Beattie Based on the ideas in debian's /usr/share/bug/mdadm/script ''' from apport.hookutils import * -from os import path +import os import re import glob import gzip import subprocess +import sys def get_initrd_files(pattern): '''Extract listing of files from the current initrd which match a regex. @@ -21,13 +22,16 @@ (_, _, release, _, _) = os.uname() try: fd = gzip.GzipFile('/boot/initrd.img-' + release, 'rb') + # universal_newlines needs to be False here as we're passing + # binary data from gzip into cpio, which means we'll need to + # decode the bytes into strings later when reading the output cpio = subprocess.Popen(['cpio', '-t'], close_fds=True, stderr=subprocess.STDOUT, stdin=subprocess.PIPE, stdout=subprocess.PIPE, - universal_newlines=True) + universal_newlines=False) except OSError as e: return 'Error: ' + str(e) - out = cpio.communicate(fd.read())[0] + out = cpio.communicate(fd.read())[0].decode(sys.stdout.encoding, errors='replace') if cpio.returncode != 0: return 'Error: command %s failed with exit code %i %' % ( 'cpio', cpio.returncode, out)