]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
90mdraid: fix/adjust 65-md* rules and related scripts
authorMichal Soltys <soltys@ziu.info>
Mon, 5 Sep 2011 22:17:28 +0000 (00:17 +0200)
committerHarald Hoyer <harald@redhat.com>
Thu, 22 Sep 2011 13:37:26 +0000 (15:37 +0200)
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
modules.d/90mdraid/md_finished.sh [deleted file]
modules.d/90mdraid/mdadm_auto.sh
modules.d/90mdraid/module-setup.sh
modules.d/90mdraid/parse-md.sh

index bb030cf7dfedab00cb0bc1863046492530bef812..209b17bba88c4064d4ec86a29c560e22af4ac5c0 100644 (file)
@@ -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 (executable)
index ce355be..0000000
+++ /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
index 915fb285e9772e71396cdee91858e20f172c366d..9b61bf59b117f7b7869a1813c96a0f2b5bf2acea 100755 (executable)
@@ -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
index 5c526a02a6f4efba6578a1d7a2d527869c6dd696..12e6739e59adb1025e886a16f65ee228a7324dad 100755 (executable)
@@ -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"
index 33d93dc76f8ebb4ff61460de0a58a517500ed435..b85a3a3f17f380e6b15e525cbd5cfd49daf16ce4 100755 (executable)
@@ -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"