Hi Gunnar,

* Gunnar Wolf <gw...@gwolf.org> [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 
>     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

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

Reply via email to