[pkg-cryptsetup-devel] Bug#601886: Bug#601886: cryptsetup: luksformat leaves the Luks device open

Milan Broz mbroz at redhat.com
Tue Feb 22 13:53:21 UTC 2011


On 02/22/2011 02:22 PM, Jonas Meurer wrote:

> now the bad news: i'm still able to reproduce the bug with recent
> versions of lvm2 and device-mapper. I even replaced the debian udev
> rules by the upstream ones (LVM2.2.02.84/udev) restarted udev, and
> unfortunately still was able to reproduce the bugreport. It seems like
> now the luksClose error "device is busy" occurs less often than before,
> but i'm still able to reproduce it something like 3 out of 10 tries.

I probably misinterpreted the bug.

So, luksformat cals:

cryptsetup luksFormat
cryptsetup luksOpen <x>
mkfs <x>
cryptsetup luksClose

And the last luksClose fails with device busy?

If so:

Are there some WATCH rules? (I see this one in Debian)

# watch for future changes
KERNEL!="sr*", OPTIONS+="watch"

So, after mkfs id finished, it closes device and watch rule triggers udev scan
(it uses inotify on read-write close).

This scan is not related to lvm udev, it is asynchronout device scan
(to create various uuid links etc).

Unfortunately it locks device for some time, so if it is not quick enough,
following luksClose fails.

You can verify it by commenting this watch rules out - then it should work
without any sleep.

I am afraid that in this case you must use "udevadm settle" before luksClose,
this is just wonderful world of udev watch...

(I think that mkfs should generate change event to fix uuid links and do not
rely on these asynchronous hacks but I know that udev/udisks upstream disagrees here:-)

Milan





More information about the pkg-cryptsetup-devel mailing list