Re: loopback devices are not freeed on umount

Guest section DW (dwguest@win.tue.nl)
Mon, 8 Mar 1999 15:25:54 +0100 (MET)


From: Hans de Goede <j.w.r.degoede@et.tudelft.nl>

If I mount a floppy image or an iso image trough loopback for example:

mount boot.img t -o loop=/dev/loop0

and then umount it with:
umount t
or:
umount /dev/loop0

The loopback module usage count stays 1 in /proc/modules
also I cannot mount another image thorugh /dev/loop0 cause it's still in
use acording to
the kernel.

Note that a loopback mount is a two-stage thing: first
losetup to connect /dev/loop0 to some file, and then mount.

If you never mention any loop device explicitly, all will work well:

mount boot.img /t -o loop
umount /t

Here mount will take the `-o loop' option and invent a free loop device
for you, do the losetup and the mount. The umount will unmount the device
and free the loop device again.

You can also handle the losetup part yourself, perhaps to do things
other than mounting to this image. Freeing the loop device works with

losetup -d /dev/loop0

Conclusion: If you say that `umount /dev/loop0' does not free the loop
device then I am happy because that is intended behaviour: if you handle
the loop devices explicitly, you are responsible for them and should
call losetup yourself.

On the other hand, if you say that `umount t' does not free the loop
device then something is wrong. I just checked, but here all is OK.
Maybe you were mistaken? I do not think this has ever been wrong.

Andries

[PS - I only talk about the `losetup -d' being done or not. Have not
checked module usage counts.]

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/