90mdraid: fix/adjust mdraid-cleanup
authorMichal Soltys <soltys@ziu.info>
Mon, 5 Sep 2011 22:17:26 +0000 (00:17 +0200)
committerHarald Hoyer <harald@redhat.com>
Thu, 22 Sep 2011 13:37:25 +0000 (15:37 +0200)
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 <soltys@ziu.info>
modules.d/90mdraid/mdraid-cleanup.sh
modules.d/90mdraid/mdraid_start.sh

index add02e0..8fc54e2 100755 (executable)
@@ -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
index 4aa7f82..4c0255e 100755 (executable)
@@ -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