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

blkdeactivate: add support for bind mounts

Recent version of util-linux/umount (v2.23+) provides
umount --all-targets that can unmount all the mount targets of
the same device (the bind mounts). Use this if available when
calling the umount blkdeactivate.

Otherwise, for older versions of util-linux, use findmnt
(that is also a part of the util-linux) to iterate over all
mount targets of the same device - this is the manual way.
This commit is contained in:
Peter Rajnoha 2013-08-13 17:26:36 +02:00
parent a854398764
commit 268b370e24
2 changed files with 26 additions and 5 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.101 -
===================================
Add support for bind mounts in blkdeactivate.
Add blkdeactivate -v/--verbose for debug output from external tools used.
Add blkdeactivate -e/--errors for error messages from external tools used.
Suppress messages from external tools called in blkdeactivate by default.

View File

@ -36,7 +36,13 @@ UMOUNT="/bin/umount"
DMSETUP="@sbindir@/dmsetup"
LVM="@sbindir@/lvm"
UMOUNT_OPTS=""
if $UMOUNT --help | grep -- "--all-targets" >$DEV_DIR/null; then
UMOUNT_OPTS="--all-targets "
else
UMOUNT_OPTS=""
FINDMNT="/bin/findmnt -r --noheadings -u -o TARGET"
FINDMNT_READ="read -r mnt"
fi
DMSETUP_OPTS=""
LVM_OPTS=""
@ -132,10 +138,8 @@ is_top_level_device() {
test -z "$files"
}
device_umount () {
test -z "$mnt" && return 0;
test "$devtype" != "lvm" && test "${kname:0:3}" != "dm-" && return 0
device_umount_one() {
test -z "$mnt" && return 0
if test -z "${SKIP_UMOUNT_LIST["$mnt"]}" -a "$DO_UMOUNT" -eq "1"; then
echo -n " [UMOUNT]: unmounting $name ($kname) mounted on $mnt... "
@ -151,6 +155,22 @@ device_umount () {
fi
}
device_umount() {
test "$devtype" != "lvm" && test "${kname:0:3}" != "dm-" && return 0
# FINDMNT is defined only if umount --all-targets is not available.
# In that case, read the list of multiple mount points of one device
# using FINDMNT and unmount it one by one manually.
if test -z "$FINDMNT"; then
device_umount_one
else
while $FINDMNT_READ; do
device_umount_one || return 1
done <<< "`$FINDMNT $DEV_DIR/$kname`"
fi
}
deactivate_holders () {
local skip=1; $LSBLK_VARS