Commit 5e861051 authored by Iustin Pop's avatar Iustin Pop
Browse files

lvmstrap: add an explicit test for mounted devices



Recent kernels/userland report a mounted filesystem as follows:

    root@node4:~# fuser -avm /dev/sda5
                         USER        PID ACCESS COMMAND
    /dev/sda5:           root     kernel mount /srv/ganeti

But old ones do not:

    node1# fuser -avm /dev/sda5
                         USER        PID ACCESS COMMAND
    /dev/sda5:

So in order to cover both, we add an explicit test for this. We
already compute the device numbers of all mounted filesystems, so it
is a trivial addition (GetMountInfo() is cheap, so we don't need to
cache it).
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent 6714256c
......@@ -625,11 +625,24 @@ def CheckReread(name):
return result.failed
def CheckMounted(name):
"""Check to see if a block device is a mountpoint.
In recent distros/kernels, this is reported directly via fuser, but
on older ones not, so we do an additional check here (manually).
"""
minfo = GetMountInfo()
dev = ReadDev("/sys/block/%s" % name)
return dev not in minfo
def InUse(name):
"""Returns if a disk is in use or not.
"""
return not (CheckSysfsHolders(name) and CheckReread(name))
return not (CheckSysfsHolders(name) and CheckReread(name) and
CheckMounted(name))
def WipeDisk(name):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment