201 lines
7.4 KiB
Diff
201 lines
7.4 KiB
Diff
|
From a025cc17f0d8145492ffbb37735deca208e768bd Mon Sep 17 00:00:00 2001
|
||
|
From: Michal Soltys <soltys@ziu.info>
|
||
|
Date: Tue, 6 Sep 2011 00:17:28 +0200
|
||
|
Subject: [PATCH] 90mdraid: fix/adjust 65-md* rules and related scripts
|
||
|
|
||
|
Reworked the flow of the rules file a bit, removed redundant tests, also
|
||
|
should be easier to follow. It's much shorter now as well, a bit more
|
||
|
similar to 90lvm script - both revolve around same concepts after all.
|
||
|
|
||
|
There's no reason to treat conf-assembled arrays differently from
|
||
|
incremental ones. Once we hit timeout in init's udev loop, we can use
|
||
|
common script (mdraid_start.sh) to try force inactive arrays
|
||
|
into degraded mode.
|
||
|
|
||
|
md-finished.sh was kind-of out of place - it didn't really wait for any
|
||
|
particular device(s) to show up, just watched if onetime mdadm scripts
|
||
|
are still in place. Furthermore, after moving mdraid_start to --timeout
|
||
|
initqueue, it didn't really have too much to watch at all, besides
|
||
|
mdadm_auto (and that served no purpose, as we do wait for concrete
|
||
|
devices).
|
||
|
|
||
|
Either way, with stock 64-md fixes, current version of 65-md*.rules does
|
||
|
the following:
|
||
|
|
||
|
- limits assembly to certain uuids, if specified
|
||
|
- watch for no ddf/imsm
|
||
|
- if mdadm.conf => setup onetime -As script, without forced --run option
|
||
|
- if !mdadm.conf => incrementally assemble
|
||
|
- for both cases, setup timeout script, run-forcing arrays as a last resort
|
||
|
|
||
|
Signed-off-by: Michal Soltys <soltys@ziu.info>
|
||
|
---
|
||
|
modules.d/90mdraid/65-md-incremental-imsm.rules | 79 ++++++++---------------
|
||
|
modules.d/90mdraid/md_finished.sh | 9 ---
|
||
|
modules.d/90mdraid/mdadm_auto.sh | 2 +-
|
||
|
modules.d/90mdraid/module-setup.sh | 1 -
|
||
|
modules.d/90mdraid/parse-md.sh | 8 ++-
|
||
|
5 files changed, 34 insertions(+), 65 deletions(-)
|
||
|
delete mode 100755 modules.d/90mdraid/md_finished.sh
|
||
|
|
||
|
diff --git a/modules.d/90mdraid/65-md-incremental-imsm.rules b/modules.d/90mdraid/65-md-incremental-imsm.rules
|
||
|
index bb030cf..209b17b 100644
|
||
|
--- a/modules.d/90mdraid/65-md-incremental-imsm.rules
|
||
|
+++ b/modules.d/90mdraid/65-md-incremental-imsm.rules
|
||
|
@@ -2,68 +2,45 @@
|
||
|
# automatically cause mdadm to be run.
|
||
|
# See udev(8) for syntax
|
||
|
|
||
|
-ACTION!="add|change", GOTO="md_inc_end"
|
||
|
-SUBSYSTEM!="block", GOTO="md_inc_end"
|
||
|
-ENV{ID_FS_TYPE}!="*_raid_member", GOTO="md_inc_end"
|
||
|
-
|
||
|
-ENV{ID_FS_TYPE}=="isw_raid_member", ENV{rd_NO_MDIMSM}=="?*", GOTO="md_inc_end"
|
||
|
-ENV{ID_FS_TYPE}=="ddf_raid_member", ENV{rd_NO_MDDDF}=="?*", GOTO="md_inc_end"
|
||
|
-
|
||
|
-ENV{rd_NO_MD}=="?*", GOTO="md_inc_end"
|
||
|
-
|
||
|
-PROGRAM=="/bin/sh -c 'for i in $sys/$devpath/holders/md[0-9]*; do [ -e $$i ] && exit 0; done; exit 1;' ", \
|
||
|
- GOTO="md_inc_end"
|
||
|
+ACTION!="add|change", GOTO="md_end"
|
||
|
+SUBSYSTEM!="block", GOTO="md_end"
|
||
|
+ENV{rd_NO_MD}=="?*", GOTO="md_end"
|
||
|
+KERNEL=="md*", GOTO="md_end"
|
||
|
+
|
||
|
+ENV{ID_FS_TYPE}!="*_raid_member", GOTO="md_end"
|
||
|
+ENV{ID_FS_TYPE}=="isw_raid_member", ENV{rd_NO_MDIMSM}=="?*", GOTO="md_end"
|
||
|
+ENV{ID_FS_TYPE}=="ddf_raid_member", ENV{rd_NO_MDDDF}=="?*", GOTO="md_end"
|
||
|
+
|
||
|
+# already done ?
|
||
|
+PROGRAM="/bin/sh -c 'for i in $sys/$devpath/holders/md[0-9]*; do [ -e $$i ] && exit 0; done; exit 1;' ", \
|
||
|
+ GOTO="md_end"
|
||
|
+
|
||
|
+# for native arrays - array's uuid has to be specified
|
||
|
+# for containers - container's uuid has to be specified
|
||
|
+# TODO : how to get embedded array's uuid having container's component ?
|
||
|
+#
|
||
|
+# UUID CHECK
|
||
|
|
||
|
ENV{DEVTYPE}!="partition", \
|
||
|
RUN+="/sbin/partx -d --nr 1-1024 $env{DEVNAME}"
|
||
|
|
||
|
-KERNEL!="md*", IMPORT{program}="/sbin/mdadm --examine --export $tempnode"
|
||
|
-
|
||
|
-# UUID CHECK
|
||
|
-
|
||
|
-LABEL="do_md_inc"
|
||
|
+RUN+="/sbin/initqueue --timeout --onetime --unique /sbin/mdraid_start"
|
||
|
|
||
|
+# if rd_MDADMCONF is set, do not assemble incrementally;
|
||
|
+# defer conf-based assembly until the udev queue is settled
|
||
|
#
|
||
|
-# if rd_MDADMCONF do not assemble incrementally
|
||
|
-# defer auto assembly until the udev queue is settled
|
||
|
-#
|
||
|
-ENV{rd_MDADMCONF}!="?*", GOTO="md_auto_end"
|
||
|
+ENV{rd_MDADMCONF}!="?*", GOTO="md_incremental"
|
||
|
|
||
|
-RUN+="/sbin/initqueue --finished --unique --name md_finished /sbin/md_finished.sh"
|
||
|
RUN+="/sbin/initqueue --settled --onetime --unique /sbin/mdadm_auto"
|
||
|
|
||
|
-GOTO="md_inc_end"
|
||
|
-
|
||
|
-LABEL="md_auto_end"
|
||
|
+GOTO="md_end"
|
||
|
|
||
|
#
|
||
|
-# Incrementally build the md array
|
||
|
+# Incrementally build the md array; this will automatically assemble
|
||
|
+# any eventual containers as well (imsm, ddf)
|
||
|
#
|
||
|
-RUN+="/sbin/mdadm -I $env{DEVNAME}"
|
||
|
-
|
||
|
-RUN+="/sbin/initqueue --finished --unique --name md_finished /sbin/md_finished.sh"
|
||
|
-
|
||
|
-LABEL="md_inc_end"
|
||
|
-
|
||
|
-#
|
||
|
-# Handle non-container raid arrays
|
||
|
-#
|
||
|
-ACTION=="add|change", \
|
||
|
- KERNEL=="md[0-9]*|md/*", \
|
||
|
- ENV{MD_LEVEL}!="container", \
|
||
|
- ENV{MD_CONTAINER}!="?*", \
|
||
|
- ENV{rd_MDADMCONF}!="?*", \
|
||
|
- ENV{rd_NO_MD}!="?*", \
|
||
|
- GOTO="do_raidstart"
|
||
|
+LABEL="md_incremental"
|
||
|
|
||
|
-GOTO="end_raidstart"
|
||
|
-
|
||
|
-LABEL="do_raidstart"
|
||
|
-
|
||
|
-# check if array is not inactive anymore
|
||
|
-TEST=="md/array_state", ATTR{md/array_state}!="|inactive", GOTO="end_raidstart"
|
||
|
-
|
||
|
-RUN+="/sbin/initqueue --finished --unique --name md_finished /sbin/md_finished.sh"
|
||
|
-RUN+="/sbin/initqueue --timeout --onetime --unique /sbin/mdraid_start"
|
||
|
+RUN+="/sbin/mdadm -I $env{DEVNAME}"
|
||
|
|
||
|
-LABEL="end_raidstart"
|
||
|
+LABEL="md_end"
|
||
|
diff --git a/modules.d/90mdraid/md_finished.sh b/modules.d/90mdraid/md_finished.sh
|
||
|
deleted file mode 100755
|
||
|
index ce355be..0000000
|
||
|
--- a/modules.d/90mdraid/md_finished.sh
|
||
|
+++ /dev/null
|
||
|
@@ -1,9 +0,0 @@
|
||
|
-#!/bin/sh
|
||
|
-# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
|
||
|
-# ex: ts=8 sw=4 sts=4 et filetype=sh
|
||
|
-for f in $hookdir/initqueue/settled/mdraid_start* $hookdir/initqueue/settled/mdadm_auto*; do
|
||
|
- [ -e $f ] && exit 1
|
||
|
-done
|
||
|
-
|
||
|
-$UDEV_QUEUE_EMPTY >/dev/null 2>&1 || exit 1
|
||
|
-exit 0
|
||
|
diff --git a/modules.d/90mdraid/mdadm_auto.sh b/modules.d/90mdraid/mdadm_auto.sh
|
||
|
index 915fb28..9b61bf5 100755
|
||
|
--- a/modules.d/90mdraid/mdadm_auto.sh
|
||
|
+++ b/modules.d/90mdraid/mdadm_auto.sh
|
||
|
@@ -4,4 +4,4 @@
|
||
|
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
|
||
|
|
||
|
info "Autoassembling MD Raid"
|
||
|
-mdadm -As --auto=yes --run 2>&1 | vinfo
|
||
|
+mdadm -As --auto=yes 2>&1 | vinfo
|
||
|
diff --git a/modules.d/90mdraid/module-setup.sh b/modules.d/90mdraid/module-setup.sh
|
||
|
index 5c526a0..12e6739 100755
|
||
|
--- a/modules.d/90mdraid/module-setup.sh
|
||
|
+++ b/modules.d/90mdraid/module-setup.sh
|
||
|
@@ -82,7 +82,6 @@ install() {
|
||
|
|
||
|
inst "$moddir/mdraid_start.sh" /sbin/mdraid_start
|
||
|
inst "$moddir/mdadm_auto.sh" /sbin/mdadm_auto
|
||
|
- inst "$moddir/md_finished.sh" /sbin/md_finished.sh
|
||
|
inst_hook pre-trigger 30 "$moddir/parse-md.sh"
|
||
|
inst "$moddir/mdraid-cleanup.sh" /sbin/mdraid-cleanup
|
||
|
inst_hook shutdown 30 "$moddir/md-shutdown.sh"
|
||
|
diff --git a/modules.d/90mdraid/parse-md.sh b/modules.d/90mdraid/parse-md.sh
|
||
|
index 33d93dc..b85a3a3 100755
|
||
|
--- a/modules.d/90mdraid/parse-md.sh
|
||
|
+++ b/modules.d/90mdraid/parse-md.sh
|
||
|
@@ -13,12 +13,14 @@ else
|
||
|
[ -e "$f" ] || continue
|
||
|
while read line; do
|
||
|
if [ "${line%%UUID CHECK}" != "$line" ]; then
|
||
|
+ printf 'IMPORT{program}="/sbin/mdadm --examine --export $tempnode"\n'
|
||
|
for uuid in $MD_UUID; do
|
||
|
- printf 'ENV{MD_UUID}=="%s", GOTO="do_md_inc"\n' $uuid
|
||
|
+ printf 'ENV{MD_UUID}=="%s", GOTO="md_uuid_ok"\n' $uuid
|
||
|
done;
|
||
|
- printf 'GOTO="md_inc_end"\n';
|
||
|
+ printf 'GOTO="md_end"\n'
|
||
|
+ printf 'LABEL="md_uuid_ok"\n'
|
||
|
else
|
||
|
- echo $line;
|
||
|
+ echo "$line"
|
||
|
fi
|
||
|
done < "${f}" > "${f}.new"
|
||
|
mv "${f}.new" "$f"
|