summaryrefslogtreecommitdiff
path: root/debian
diff options
context:
space:
mode:
authorMichael Tokarev <mjt@tls.msk.ru>2012-10-28 21:11:09 +0400
committerMichael Tokarev <mjt@tls.msk.ru>2012-10-28 21:11:09 +0400
commit80f857c527846749601e6b3aac1f995b619ac9f3 (patch)
tree3e3853b9c1428670518e8bf6b0d181fa5337fdae /debian
parentdf370a533916769caf91083b683485652970db2e (diff)
add support for mdmon based on changed by Miquel van Smoorenburg (#684708)
Diffstat (limited to 'debian')
-rw-r--r--debian/changelog15
-rw-r--r--debian/initramfs/hook2
-rw-r--r--debian/mdadm-waitidle54
-rw-r--r--debian/mdadm.init14
-rwxr-xr-xdebian/rules7
5 files changed, 89 insertions, 3 deletions
diff --git a/debian/changelog b/debian/changelog
index fe0eb2df..6f3e3fe5 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -18,6 +18,21 @@ mdadm (3.2.5-4) UNRELEASED; urgency=low
- allow --takeover when original was started with --offroot
- fix arg parsing.
- fix arg processing for -a
+ * Changes based on a patch by Miquel van Smoorenburg (Closes: #684708):
+ - install mdmon in udeb and initramfs, so imsm arrays can work.
+ mdadm runs mdmon automatically when needed (currently for imsm
+ arrays), and mdmon is required to make such arrays read-write
+ (they're read-only by default) so merely presence of mdmon is
+ enough to be able to use imsm arrays.
+ - /etc/init.d/mdadm start: if a mdmon pidfile is found in /run/mdadm,
+ restart mdmon (--takeover --all)
+ - /etc/init.d/mdadm stop: link pidfiles of mdmon processes into
+ /run/sendsigs.omit.d, and make sure that happens before sendsigs runs.
+ - stop mdadm before sendsigs, so that the above code works
+ - add script mdadm-waitidle that runs just before reboot/halt.
+ For each array that is still running, it sets sync_action to idle,
+ and uses mdadm --wait-clean to wait for all arrays to go idle
+ (it has a short timeout).
-- Michael Tokarev <mjt@tls.msk.ru> Sat, 20 Oct 2012 19:20:12 +0400
diff --git a/debian/initramfs/hook b/debian/initramfs/hook
index 42fa9d48..a2e5cc85 100644
--- a/debian/initramfs/hook
+++ b/debian/initramfs/hook
@@ -50,6 +50,7 @@ err()
}
MDADM=/sbin/mdadm
+MDMON=/sbin/mdmon
[ -x "$MDADM" ] || exit 0
[ -r /usr/share/initramfs-tools/hook-functions ] || exit 0
@@ -57,6 +58,7 @@ MDADM=/sbin/mdadm
# copy the binary as early as possible
copy_exec $MDADM /sbin
+copy_exec $MDMON /sbin
# copy all modules into the initramfs, just for safety.
# we copy raid456 / raid5+raid6 because the hook script just won't do
diff --git a/debian/mdadm-waitidle b/debian/mdadm-waitidle
new file mode 100644
index 00000000..5fd79aa5
--- /dev/null
+++ b/debian/mdadm-waitidle
@@ -0,0 +1,54 @@
+#!/bin/sh
+### BEGIN INIT INFO
+# Provides: mdadm-waitidle
+# Required-Start:
+# Required-Stop:
+# Should-Stop: halt reboot kexec
+# X-Stop-After: umountroot
+# Default-Start:
+# Default-Stop: 0 6
+# Short-Description: Wait for MD arrays to become idle
+# Description: Waits until all MD arrays are in idle and synced state
+# before halt/reboot.
+### END INIT INFO
+#
+set -eu
+
+MDADM=/sbin/mdadm
+test -x "$MDADM" || exit 0
+test -f /proc/mdstat || exit 0
+
+. /lib/lsb/init-functions
+
+case "${1:-}" in
+
+ start)
+ ;;
+
+ stop)
+ sync
+ wait=
+ for md in /sys/block/md*/md ; do
+ [ -d "$md" ] || continue
+ [ "$wait" ] || log_action_begin_msg "Waiting for MD arrays to become idle"
+ wait=y
+ [ -w $md/sync_action ] && echo idle > $md/sync_action
+ done
+ if [ "$wait" ]; then
+ # mdadm --wait-clean has a short internal timeout
+ if $MDADM --wait-clean --scan; then
+ log_action_end_msg 0
+ else
+ log_action_end_msg 1
+ sleep 1
+ fi
+ fi
+ ;;
+
+ *)
+ echo "Usage: ${0:-} stop" >&2
+ exit 1;;
+
+esac
+
+exit 0
diff --git a/debian/mdadm.init b/debian/mdadm.init
index 64e6d720..d8855f61 100644
--- a/debian/mdadm.init
+++ b/debian/mdadm.init
@@ -9,7 +9,7 @@
### BEGIN INIT INFO
# Provides: mdadm
# Required-Start: $local_fs $syslog mdadm-raid
-# Required-Stop: $local_fs $syslog mdadm-raid
+# Required-Stop: $local_fs $syslog sendsigs mdadm-raid
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: MD monitoring daemon
@@ -22,6 +22,7 @@
set -eu
MDADM=/sbin/mdadm
+MDMON=/sbin/mdmon
RUNDIR=/run/mdadm
PIDFILE=$RUNDIR/monitor.pid
DEBIANCONFIG=/etc/default/mdadm
@@ -54,6 +55,13 @@ case "${1:-}" in
log_end_msg $?
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"
+ set +e
+ $MDMON --takeover --all
+ log_end_msg $?
+ set -e
+ fi
;;
stop)
if [ -f $PIDFILE ] ; then
@@ -64,6 +72,10 @@ case "${1:-}" in
log_end_msg $?
set -e
fi
+ for file in $RUNDIR/md[0-9]*.pid ; do
+ [ ! -f "$file" ] && continue
+ ln -sf $file /run/sendsigs.omit.d/mdmon-${file##*/}
+ done
;;
status)
status_of_proc -p $PIDFILE "$MDADM" "mdadm" && exit 0 || exit $?
diff --git a/debian/rules b/debian/rules
index b6f99bb7..2c017896 100755
--- a/debian/rules
+++ b/debian/rules
@@ -35,7 +35,8 @@ mdadm.udeb: configure
dh_testdir
$(MAKE) $(FLAGS) all
mv mdadm mdadm.udeb
-.PHONY: mdadm.udeb
+ mv mdmon mdmon.udeb
+.PHONY: mdadm.udeb mdmon.udeb
mdadm: FLAGS = CXFLAGS="$(CXFLAGS)" CONFFILE=/etc/mdadm/mdadm.conf CONFFILE2=/etc/mdadm.conf
mdadm: configure
@@ -50,7 +51,7 @@ clean:
rm -f $(INTERPOLATED_FILES)
rm -f build-stamp
[ ! -f Makefile ] || $(MAKE) clean
- rm -f mdadm.udeb mdadm debian/mdadm-startall.8
+ rm -f mdadm.udeb mdmon.udeb mdadm debian/mdadm-startall.8
dh_clean
debconf-updatepo
@@ -80,6 +81,7 @@ install: build $(INTERPOLATED_FILES)
install -m0755 debian/mdadm-startall $(DESTDIR)/sbin
install -m0755 mdadm.udeb $(DESTDIR_UDEB)/sbin/mdadm
+ install -m0755 mdmon.udeb $(DESTDIR_UDEB)/sbin/mdmon
install -m0644 udev-md-raid.rules $(DESTDIR_UDEB)/lib/udev/rules.d/64-md-raid.rules
binary-indep: build install
@@ -92,6 +94,7 @@ binary-arch: build install
dh_installdocs
dh_installexamples debian/mdadd.sh
dh_installinit --init-script=mdadm-raid --no-restart-on-upgrade -- start 25 S . start 60 0 6 .
+ dh_installinit --init-script=mdadm-waitidle --no-start -- stop 98 0 6 .
dh_installinit -- defaults 25
dh_installman
dh_installcron