#906846 mount: Fails to notice that a loopdevice cannot be removed

Package:
mount
Source:
util-linux
Description:
tools for mounting and manipulating filesystems
Submitter:
Gunnar Wolf
Date:
2022-04-16 20:09:03 UTC
Severity:
normal
#906846#5
Date:
2018-08-21 17:10:42 UTC
From:
To:
If I request losetup to detach from a loop device and it cannot be
detached, I would expect it to notify me accordingly. However:

    # losetup --list
    NAME        SIZELIMIT OFFSET AUTOCLEAR RO BACK-FILE                                              DIO LOG-SEC
    /dev/loop1          0      0         1  0 /home/gwolf/vcs/raspi3-image-spec/raspi3.img (deleted)   0     512
    # if losetup --detach /dev/loop1 ; then echo SUCCESS; else echo FAIL; fi
    SUCCESS
    # losetup --list
    NAME        SIZELIMIT OFFSET AUTOCLEAR RO BACK-FILE                                              DIO LOG-SEC
    /dev/loop1          0      0         1  0 /home/gwolf/vcs/raspi3-image-spec/raspi3.img (deleted)   0     512

When requesting debug information, it seems losetup actually believes
the loopback was dropped - but it is false:

    # LOOPDEV_DEBUG=all losetup --detach /dev/loop1
    9932: loopdev:      CXT: [0x7ffeaa764d60]: initialize context
    9932: loopdev:      CXT: [0x7ffeaa764d60]: init: ignore ioctls
    9932: loopdev:      CXT: [0x7ffeaa764d60]: init: loop-control detected
    9932: loopdev:      CXT: [0x7ffeaa764d60]: /dev/loop1 name assigned
    9932: loopdev:      CXT: [0x7ffeaa764d60]: open /dev/loop1 [ro]: Success
    9932: loopdev:      CXT: [0x7ffeaa764d60]: device removed
    9932: loopdev:      CXT: [0x7ffeaa764d60]: de-initialize
    9932: loopdev:      CXT: [0x7ffeaa764d60]: closing old open fd
    9932: loopdev:     ITER: [0x7ffeaa764f18]: de-initialize
    # losetup --list
    NAME        SIZELIMIT OFFSET AUTOCLEAR RO BACK-FILE                                              DIO LOG-SEC
    /dev/loop1          0      0         1  0 /home/gwolf/vcs/raspi3-image-spec/raspi3.img (deleted)   0     512

Thank you very much for looking into this!

#906846#10
Date:
2022-04-16 19:57:35 UTC
From:
To:
Hi Gunnar,

* Gunnar Wolf <gwolf@gwolf.org> [220416 19:54]:

Sorry for the long time with no reply to your bug.

I took a closer look today; I can reproduce this -if- I have a
filesystem mounted using that loop device. This comment from
upstream explains whats going on:
https://github.com/util-linux/util-linux/issues/484#issuecomment-321506607

Apparently losetup cannot (really) know that the kernel ignores the
detach ioctl. I would say there is no bug in util-linux. Maybe you
want to talk to the kernel folks?

Best,
Chris