Re: udev problem with udevsettle

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jul 03, 2008 at 03:11:38PM +0200, Farkas Levente wrote:
> it's seems there is a deadlock between udev and cryptsetup.

Not exactly, see below.

> so now cryptsetup call udevsettle and as i call "cryptsetup luksOpen" 
> from udev it seems there are some kind of deadlock.

You shouldn't call cryptsetup from the udev RUN key.  From the udev(7)
manpage:

> RUN
>   <...> This can only be used for very short running tasks. Running an
>   event process for a long period of time may block all further events
>   for this or a dependent device. Long running tasks need to be
>   immediately detached from the event process itself.

When your RUN rule is executed, udev is in the middle of processing the
uevent for the USB storage device.  So while your script is running,
udev has not settled (the test that udevsettle uses to decide this will
never succeed, because the RUN rule that called udevsettle is not
finished).  To get the rule to finish processing, the program that RUN
ran needs to exit.  *Then* udevsettle will finish.

Yes, it's a deadlock, but the only way around it is to either (a) skip
calling udevsettle, or (b) don't call cryptsetup from a RUN key.  It
looks like the reason for calling udevsettle might be sound; if so, then
you'll need to either use something other than RUN, or detach.

It probably makes the most sense to just make your script run most of
its logic in the background, instead of the foreground.  I'm not sure
exactly what logic udevd uses, but I think it will work to write a
wrapper script that just runs your current script in the background:

#!/bin/bash
/path/to/current/script "$@" &

and then exits.

(Also, it's no longer "udevsettle" anymore.  It's "udevadm settle" now:
somebody should probably ask the cryptsetup people to change their
program to work with both names.  The udevsettle symlink is still
installed for now, but it wouldn't surprise me if it eventually goes
away.  It's in the "scheduled for removal" section of the udev TODO
file.)

Attachment: pgpnTMaD2lVXv.pgp
Description: PGP signature


[Index of Archives]     [Linux Kernel]     [Linux DVB]     [Asterisk Internet PBX]     [DCCP]     [Netdev]     [X.org]     [Util Linux NG]     [Fedora Women]     [ALSA Devel]     [Linux USB]

  Powered by Linux