From 9383421c1cfc5fe1bc94cf3d3194bd96ee503628 Mon Sep 17 00:00:00 2001 From: Michal Soltys Date: Tue, 6 Sep 2011 00:17:26 +0200 Subject: [PATCH] 90mdraid: fix/adjust mdraid-cleanup 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 --- 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