2004-10-05 19:49:56

by Andreas Jellinghaus

[permalink] [raw]
Subject: block till hotplug is done?

Hi,

is there any way to block till all hotplug events are handled/
the hotplug processes terminated?

For example
fdisk
mkfs
fails, because after fdisk create a partition, and the kernel
reread the partition table, called hotplug, hotplug called udev
and udev created the matching /dev file, all of that might be
too slow and mkfs might fail in the mean time.

even
fdisk
sleep 2
mkfs
sometimes failes with machines I'm installing.

so I can either randomly increase the delay everytime the installation
fails because the device isn't created in time, or I can create the
devices myself with mkdev, which defeats the whole purpose of hotplug
and udev. Or - preferable - I would want to wait till something
tells me the device is there. some way to sleep till not kernel
triggered hotlug process is running any more, that would be nice.
does the kernel keep track of it's hotplug processes? is there such
a way to wait till they are all done?

(and would that work, if hotplug spawned some child process/daemon, i.e.
not wait for the daemon to end?)

Regards, Andreas


2004-10-05 20:15:02

by Harald Dunkel

[permalink] [raw]
Subject: Re: block till hotplug is done?

Andreas Jellinghaus wrote:
> Hi,
>
> is there any way to block till all hotplug events are handled/
> the hotplug processes terminated?
>

while [ "`ps | grep /sbin/hotplug | grep -v grep`" ]; do sleep 1; done

?


Regards

Harri

2004-10-05 20:40:50

by Valdis Klētnieks

[permalink] [raw]
Subject: Re: block till hotplug is done?

On Tue, 05 Oct 2004 22:13:15 +0200, Harald Dunkel said:
> Andreas Jellinghaus wrote:
> > Hi,
> >
> > is there any way to block till all hotplug events are handled/
> > the hotplug processes terminated?
> >
>
> while [ "`ps | grep /sbin/hotplug | grep -v grep`" ]; do sleep 1; done

Save a process:

while [ "`ps | grep '/sbin/[h]otplug'`" ]; do sleep 1; done

Depending on what exactly you're waiting on, you might also try:

while [ ! -b /dev/hdc1 ]; do sleep 1; done

(Assuming you know what device name you're expecting - this may depend on
the exact list of things that you want to do - there *might* be a race
condition where fdisk has created hd?1 but it's not the *right* one because
the media was previously partitioned and fdisk hasn't told the kernel to
read the new one yet. YMMV and all that...)


Attachments:
(No filename) (226.00 B)

2004-10-05 22:16:50

by Jon Masters

[permalink] [raw]
Subject: Re: block till hotplug is done?

On Tue, 05 Oct 2004 16:38:08 -0400, [email protected]
<[email protected]> wrote:
> On Tue, 05 Oct 2004 22:13:15 +0200, Harald Dunkel said:
> > Andreas Jellinghaus wrote:
> > > Hi,
> > >
> > > is there any way to block till all hotplug events are handled/
> > > the hotplug processes terminated?
> > >
> >
> > while [ "`ps | grep /sbin/hotplug | grep -v grep`" ]; do sleep 1; done
>
> Save a process:
>
> while [ "`ps | grep '/sbin/[h]otplug'`" ]; do sleep 1; done

Why not sit a script in /etc/dev.d and have that wake up your fsck
script by signalling a flag file somewhere or somesuch - I think this
is the preferable to do stuff with udev, Greg?

Jon.

2004-10-06 06:49:10

by Andreas Jellinghaus

[permalink] [raw]
Subject: Re: block till hotplug is done?

On Tue, 05 Oct 2004 20:19:59 +0000, Harald Dunkel wrote:
> while [ "`ps | grep /sbin/hotplug | grep -v grep`" ]; do sleep 1; done

wouldn't work in case the hotplug bug uses exec(), right?

Andreas

2004-10-06 14:19:40

by Alexander E. Patrakov

[permalink] [raw]
Subject: Re: block till hotplug is done?

Andreas Jellinghaus wrote:
> Hi,
>
> is there any way to block till all hotplug events are handled/
> the hotplug processes terminated?
>
> For example
> fdisk
> mkfs
> fails, because after fdisk create a partition, and the kernel
> reread the partition table, called hotplug, hotplug called udev
> and udev created the matching /dev file, all of that might be
> too slow and mkfs might fail in the mean time.

You can't wait gracefully (i.e. without sleeping), but you can duplicate
udev's work synchronously:

fdisk
udevstart
mkfs

I don't know if this is supposed to work (Greg KH: please comment on
this). It _will_ work if sysfs entries are guaranteed to be created
before the BLKRRPART ioctl returns.

--
Alexander E. Patrakov

2004-10-08 14:53:44

by Greg KH

[permalink] [raw]
Subject: Re: block till hotplug is done?

On Tue, Oct 05, 2004 at 09:52:07PM +0200, Andreas Jellinghaus wrote:
> Hi,
>
> is there any way to block till all hotplug events are handled/
> the hotplug processes terminated?

No. We've been over this many times before. Please read the mailing
list archives and look at the /etc/dev.d/ interface for the solution to
this.

thanks,

greg k-h