]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
90dm/dm-shutdown.sh: dmsetup remove_all -> dmsetup remove
authorLukas Wunner <lukas@wunner.de>
Tue, 3 Feb 2015 18:32:55 +0000 (19:32 +0100)
committerHarald Hoyer <harald@redhat.com>
Thu, 19 Feb 2015 09:57:08 +0000 (10:57 +0100)
The function 99shutdown/shutdown.sh:_check_shutdown() assumes that
shutdown scripts report success or failure via their return value.
However, "dmsetup remove_all" always reports success, even if some
of the device mappings could not be removed.

I submitted a patch for dmsetup but the lvm2 folks rejected it,
asserting that its behaviour is correct, that "remove_all" should
only be used by developers and that the proper solution would be
to invoke "dmsetup remove" on each device. This does report success
or failure via the return value.

Apart from fixing that issue, this commit also adds the dmsetup
option "--noudevsync". Without it, dmsetup would hang after removal
of a device while trying to communicate with systemd-udevd, which
is no longer running at this shutdown stage.

[harald: replaces backticks with $() ]

modules.d/90dm/dm-shutdown.sh

index dfdb48b86d89ba3a77c9fac8c87bb60ce9484781..04c89be9c64df4c39da4bdb09df2480e6e51644b 100755 (executable)
@@ -1,11 +1,12 @@
 #!/bin/sh
 
 _do_dm_shutdown() {
-    local ret
+    local ret=0
     local final=$1
     info "Disassembling device-mapper devices"
-    dmsetup -v remove_all
-    ret=$?
+    for dev in $(dmsetup info -c --noheadings -o name) ; do
+        dmsetup -v --noudevsync remove "$dev" || ret=$?
+    done
     if [ "x$final" != "x" ]; then
         info "dmsetup ls --tree"
         dmsetup ls --tree 2>&1 | vinfo