All of lore.kernel.org
 help / color / mirror / Atom feed
* asynchronous calls an the lack of --wait-for-completion options (e.g. modprobe, losetup, cryptsetup)
@ 2009-06-17 13:39 Alexander Holler
  2009-06-19  0:52 ` Robert Hancock
  0 siblings, 1 reply; 6+ messages in thread
From: Alexander Holler @ 2009-06-17 13:39 UTC (permalink / raw)
  To: linux-kernel

Hello,

during the last kernel versions I've got more and more problems with
scripts which are calling modprobe, losetup or e.g. cryptsetup.

The problem is that when I'm e.g. calling modprobe loop, loop might not
has finished it's initialization, when modprobe returns.

This leads me to such ugly scripts like
-----------------------------
if [ ! -b /dev/loop0 ]; then
   modprobe loop
   for i in $(seq 1 10) ; do
     if [ -b /dev/loop0 ]; then
       break;
     fi
     sleep 1
   done
fi
do something with /dev/loop0
-----------------------------

which leaves me in doubt if /dev/loop0 really is usable (or if the
module really has finished it's initialization) if /dev/loop0 appeared
(besides the unecessary seconds spended to sleep).

So I'm awaiting the time, when cp in "mkdir foo; cp bar foo" will fail,
because mkdir hasn't completed it's operation (but just started it).

My suggestion would be that all those tools should either offer an
option like --wait-for-completion, or, my prefered solution (which I
naively assume as how those userland-tools should behave), they should
by default wait for completion and could offer an option like
--asynchronous for the rare moments one really doesn't care if the
operation has completed when the appropriate userland-tool returns.

Another question could be, how to be sure if, e.g., modprobe loop
succeeded, if it returns while the operation hasn't finished.

Kind regards,

Alexander Holler


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: asynchronous calls an the lack of --wait-for-completion options (e.g.   modprobe, losetup, cryptsetup)
  2009-06-17 13:39 asynchronous calls an the lack of --wait-for-completion options (e.g. modprobe, losetup, cryptsetup) Alexander Holler
@ 2009-06-19  0:52 ` Robert Hancock
  2009-06-20 19:20   ` Kay Sievers
  0 siblings, 1 reply; 6+ messages in thread
From: Robert Hancock @ 2009-06-19  0:52 UTC (permalink / raw)
  To: Alexander Holler; +Cc: linux-kernel

On 06/17/2009 07:39 AM, Alexander Holler wrote:
> Hello,
>
> during the last kernel versions I've got more and more problems with
> scripts which are calling modprobe, losetup or e.g. cryptsetup.
>
> The problem is that when I'm e.g. calling modprobe loop, loop might not
> has finished it's initialization, when modprobe returns.

It will have. Just that udev won't have received the events and created 
the device node yet. So the solution would likely be on the udev side..

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: asynchronous calls an the lack of --wait-for-completion options  (e.g. modprobe, losetup, cryptsetup)
  2009-06-19  0:52 ` Robert Hancock
@ 2009-06-20 19:20   ` Kay Sievers
  2009-06-22 12:08     ` Alexander Holler
  0 siblings, 1 reply; 6+ messages in thread
From: Kay Sievers @ 2009-06-20 19:20 UTC (permalink / raw)
  To: Robert Hancock; +Cc: Alexander Holler, linux-kernel

On Fri, Jun 19, 2009 at 02:52, Robert Hancock<hancockrwd@gmail.com> wrote:
> On 06/17/2009 07:39 AM, Alexander Holler wrote:

>> The problem is that when I'm e.g. calling modprobe loop, loop might not
>> has finished it's initialization, when modprobe returns.
>
> It will have. Just that udev won't have received the events and created the
> device node yet. So the solution would likely be on the udev side..

The brutal method to do this is to call:
  udevadm settle
after loading the module. It will block until all currently pending
events for udev are fully handled.

Recent udevadm versions also have a:
  --exit-if-exists=<filename>
option, which will make "settle" stop waiting if a given file exists.

Kay

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: asynchronous calls an the lack of --wait-for-completion options (e.g. modprobe, losetup, cryptsetup)
  2009-06-20 19:20   ` Kay Sievers
@ 2009-06-22 12:08     ` Alexander Holler
  2009-06-23 11:35       ` Kay Sievers
  0 siblings, 1 reply; 6+ messages in thread
From: Alexander Holler @ 2009-06-22 12:08 UTC (permalink / raw)
  To: Kay Sievers; +Cc: Robert Hancock, linux-kernel

On 20.06.2009 21:20, Kay Sievers wrote:
> On Fri, Jun 19, 2009 at 02:52, Robert Hancock<hancockrwd@gmail.com>  wrote:
>> On 06/17/2009 07:39 AM, Alexander Holler wrote:
>
>>> The problem is that when I'm e.g. calling modprobe loop, loop might not
>>> has finished it's initialization, when modprobe returns.
>>
>> It will have. Just that udev won't have received the events and created the
>> device node yet. So the solution would likely be on the udev side..
>
> The brutal method to do this is to call:
>    udevadm settle
> after loading the module. It will block until all currently pending
> events for udev are fully handled.
>
> Recent udevadm versions also have a:
>    --exit-if-exists=<filename>
> option, which will make "settle" stop waiting if a given file exists.

Thanks a lot, I already thought it might be udev, but I haven't known 
about udevadm.

Anyway, I still think, that the creation of the device-node is (seen 
from a user-point) part of the module-initialization or part of the 
operation of the userland-tool (like modprobe, losetup or cryptsetup). 
So in my point of view, they should at least offer an option to wait 
until udev finished that operation and should not rely on the user to 
call udevadm.

But I don't want to extend that discussion. I know this is a complex 
subject where many parts are involved and many people are having 
different views (e.g. at boot time such asynchronous completion is often 
wanted).

It would be nice, if at least the userland-tools would document (e.g. in 
there examples-section), that a call to udevadm is necessary before 
going on and using the (should already created) device-node (at least if 
a stable operation on all systems is needed). The problem is, that it 
heavily depends on the system how long udev needs and it might often 
work without a call to udevadm so many people could miss the need to 
call udevadm.

Kind regards,

Alexander Holler

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: asynchronous calls an the lack of --wait-for-completion options  (e.g. modprobe, losetup, cryptsetup)
  2009-06-22 12:08     ` Alexander Holler
@ 2009-06-23 11:35       ` Kay Sievers
  2009-06-23 16:01         ` Alan Cox
  0 siblings, 1 reply; 6+ messages in thread
From: Kay Sievers @ 2009-06-23 11:35 UTC (permalink / raw)
  To: Alexander Holler; +Cc: Robert Hancock, linux-kernel, Greg Kroah-Hartmann

On Mon, Jun 22, 2009 at 14:08, Alexander Holler<holler@ahsoftware.de> wrote:
> On 20.06.2009 21:20, Kay Sievers wrote:

> Anyway, I still think, that the creation of the device-node is (seen from a
> user-point) part of the module-initialization or part of the operation of
> the userland-tool (like modprobe, losetup or cryptsetup). So in my point of
> view, they should at least offer an option to wait until udev finished that
> operation and should not rely on the user to call udevadm.

That would be all solved properly by "devtmpfs":
   http://lkml.org/lkml/2009/4/30/182

You might want to talk to the people who are delaying its adoption.

Thanks,
Kay

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: asynchronous calls an the lack of --wait-for-completion options (e.g. modprobe, losetup, cryptsetup)
  2009-06-23 11:35       ` Kay Sievers
@ 2009-06-23 16:01         ` Alan Cox
  0 siblings, 0 replies; 6+ messages in thread
From: Alan Cox @ 2009-06-23 16:01 UTC (permalink / raw)
  To: Kay Sievers
  Cc: Alexander Holler, Robert Hancock, linux-kernel, Greg Kroah-Hartmann

On Tue, 23 Jun 2009 13:35:07 +0200
Kay Sievers <kay.sievers@vrfy.org> wrote:

> On Mon, Jun 22, 2009 at 14:08, Alexander Holler<holler@ahsoftware.de> wrote:
> > On 20.06.2009 21:20, Kay Sievers wrote:
> 
> > Anyway, I still think, that the creation of the device-node is (seen from a
> > user-point) part of the module-initialization or part of the operation of
> > the userland-tool (like modprobe, losetup or cryptsetup). So in my point of
> > view, they should at least offer an option to wait until udev finished that
> > operation and should not rely on the user to call udevadm.
> 
> That would be all solved properly by "devtmpfs":
>    http://lkml.org/lkml/2009/4/30/182

which unsolves lots of other problems and has good reasons why people
object to it.

Sorting out waiting behaviour and fixing udev to do jobs once is a user
space problem and while it might benefit from some tiny bits of kernel
help re-implementing devfs (which we've been through before thank you) is
not the cure but replacing a minor ailment with a nasty disease

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-06-23 16:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-17 13:39 asynchronous calls an the lack of --wait-for-completion options (e.g. modprobe, losetup, cryptsetup) Alexander Holler
2009-06-19  0:52 ` Robert Hancock
2009-06-20 19:20   ` Kay Sievers
2009-06-22 12:08     ` Alexander Holler
2009-06-23 11:35       ` Kay Sievers
2009-06-23 16:01         ` Alan Cox

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.