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

2022-04-16 Thread Chris Hofstaedtler
Hi Gunnar,

* Gunnar Wolf  [220416 19:54]:
> 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 
> NAMESIZELIMIT 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 
> NAMESIZELIMIT 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 
> NAMESIZELIMIT 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

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



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

2018-08-21 Thread Gunnar Wolf
Package: mount
Version: 2.32-0.1
Severity: normal

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 
NAMESIZELIMIT 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 
NAMESIZELIMIT 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 
NAMESIZELIMIT 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!

-- System Information:
Debian Release: buster/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: amd64 (x86_64)

Kernel: Linux 4.15.0-2-amd64 (SMP w/8 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), 
LANGUAGE=en_US:en (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages mount depends on:
ii  libblkid1  2.32-0.1
ii  libc6  2.27-3
ii  libmount1  2.32-0.1
ii  libselinux12.8-1
ii  libsmartcols1  2.32-0.1
ii  util-linux 2.32-0.1

mount recommends no packages.

Versions of packages mount suggests:
pn  nfs-common  

-- no debconf information