linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* fast creation and deletion of loop devices
@ 2021-07-08 12:18 Simon Richter
  0 siblings, 0 replies; only message in thread
From: Simon Richter @ 2021-07-08 12:18 UTC (permalink / raw)
  To: linux-block

Hi,

I have just used a crude loop to search for a partition on a block
device:

    for i in `seq 1 4096`
    do
        losetup -r -o ${i}k /dev/loop0 /dev/sda
        mount /dev/loop0 /mnt && break
        losetup -d /dev/loop0
    done

Creating the loop device fails sometimes, with

    losetup: /dev/sda: failed to set up loop device: Device or resource busy

and the kernel log contains a few instances of

    loop_set_status: loop0 () has still dirty pages (nrpages=5)

My machine is now in a state where I can call

    until losetup -d /dev/loop0; do :; done

and the loop just keeps running.

I'm slightly confused why a read-only loop device would have dirty pages
in the first place, and I suspect that there is a kernel bug here that
allows me to enter an inconsistent state through a race condition if I
just attach and detach loop devices fast enough.

   Simon

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-07-08 12:24 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-08 12:18 fast creation and deletion of loop devices Simon Richter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).