Stop both arrays (first pass) and containers (second pass).
Loop only over /dev/md[0-9]*
Call cleanup script only once, make sure it's after crypt cleanup.

Signed-off-by: Michal Soltys <[email protected]>
---
 modules.d/90mdraid/mdraid-cleanup.sh |   30 +++++++++++++++++-------------
 modules.d/90mdraid/mdraid_start.sh   |    1 -
 2 files changed, 17 insertions(+), 14 deletions(-)

diff --git a/modules.d/90mdraid/mdraid-cleanup.sh 
b/modules.d/90mdraid/mdraid-cleanup.sh
index add02e0..8fc54e2 100755
--- a/modules.d/90mdraid/mdraid-cleanup.sh
+++ b/modules.d/90mdraid/mdraid-cleanup.sh
@@ -2,18 +2,22 @@
 # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
 # ex: ts=8 sw=4 sts=4 et filetype=sh
 
-# stop everything which is not busy
-for i in /dev/md* /dev/md/*; do
-    [ -b $i ] || continue
+type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
 
-    mddetail=$(udevadm info --query=property --name=$i)
-    case "$mddetail" in
-        *MD_LEVEL=container*)
-        ;;
-        *DEVTYPE=partition*)
-        ;;
-        *)
-            mdadm --stop $i >/dev/null 2>&1
-            ;;
-    esac
+containers=""
+for md in /dev/md[0-9]*; do
+    [ -b "$md" ] || continue
+    udevinfo="$(udevadm info --query=env --name=$md)"
+    strstr "$udevinfo" "DEVTYPE=partition" && continue
+    if strstr "$udevinfo" "MD_LEVEL=container"; then
+        containers="$containers $md"
+        continue
+    fi
+    mdadm -S "$md" >/dev/null 2>&1
 done
+
+for md in $containers; do
+    mdadm -S "$md" >/dev/null 2>&1
+done
+
+unset containers udevinfo
diff --git a/modules.d/90mdraid/mdraid_start.sh 
b/modules.d/90mdraid/mdraid_start.sh
index 4aa7f82..4c0255e 100755
--- a/modules.d/90mdraid/mdraid_start.sh
+++ b/modules.d/90mdraid/mdraid_start.sh
@@ -21,6 +21,5 @@ for md in /dev/md[0-9]* /dev/md/*; do
 done
 unset udevinfo
 
-ln -s $(command -v mdraid-cleanup) $hookdir/pre-pivot/30-mdraid-cleanup.sh 
2>/dev/null
 ln -s $(command -v mdraid-cleanup) $hookdir/pre-pivot/31-mdraid-cleanup.sh 
2>/dev/null
 udevadm control --start-exec-queue
-- 
1.7.5.3

--
To unsubscribe from this list: send the line "unsubscribe initramfs" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to