1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

tests: aux clean DM on top of MD

Before cleaning MD, try to remove any DM on top such MD.
Check is made through DM table check.
Maybe parse /proc/mdstat for this???
This commit is contained in:
Zdenek Kabelac 2021-03-23 21:28:28 +01:00
parent 93f2d194ac
commit dd1f5f9a24

View File

@ -783,11 +783,21 @@ cleanup_md_dev() {
mddev=$(< MD_DEV) mddev=$(< MD_DEV)
base=$(basename "$mddev") base=$(basename "$mddev")
# try to find and remove any DM device on top of cleaned MD
# assume /dev/mdXXX is 9:MINOR
local minor=${mddev##/dev/md}
for i in $(dmsetup table | grep 9:$minor | cut -d: -f1) ; do
dmsetup remove $i || {
dmsetup --force remove $i || true
}
done
for i in {0..10} ; do for i in {0..10} ; do
grep -q "$base" /proc/mdstat || break grep -q "$base" /proc/mdstat || break
test "$i" = 0 || { test "$i" = 0 || {
sleep .1 sleep .1
echo "$mddev is still present, stopping again" echo "$mddev is still present, stopping again"
cat /proc/mdstat
} }
mdadm --stop "$mddev" || true mdadm --stop "$mddev" || true
udev_wait # wait till events are process, not zeroing to early udev_wait # wait till events are process, not zeroing to early