linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* waiting for an unknown set of udev /dev entries to complete
@ 2005-11-18 22:30 Patrick Mansfield
  2005-11-20  6:03 ` Kay Sievers
                   ` (19 more replies)
  0 siblings, 20 replies; 21+ messages in thread
From: Patrick Mansfield @ 2005-11-18 22:30 UTC (permalink / raw)
  To: linux-hotplug

Any ideas on the best way to wait for udev to finish handling a set of
hotplug events?

That is, if I load a module or otherwise generate an unknown number of
hotplug events for a single action or event - like a modprobe of a scsi
HBA or even modprobe sd_mod - how can I tell when all hotplug events have
been handled and /dev entries created?

I'm not asking how to wait for a specific /dev entry or a single hotplug
event for a particular device.

I was thinking of:

1) (I'm looking for scsi block devices) Waiting for an equal number of
/dev/sd* nodes to show up as is found under /sys/block/sd* and
/sys/block/sd*/sd*. Is specific, and failure modes are kind of ugly (a
timeout could be used, but if hotplug is really slow and is making
progress you don't want to stop waiting).

2) Waiting for all hotplug processes to finish.  This is more general
purpose (not scsi or block specific, but doesn't handle children of
kernel.hotplug that are not named the same (at least my script below has
this problem).

I can't think of a way to handle this in a udev rule, since those are too
general (i.e. they don't know what the last event should be).

For 1), a shell script like this works:

-------------------------------------------
#! /bin/bash

# load modules, iscsi login, etc. here (does NOT have to be run in the
# background)
#
# I am using:
# ~patman/iscsi/open-iscsi/usr/iscsiadm  -m node --record 22698c --login

count=$(ls -d /sys/block/sd* /sys/block/sd*/sd* | wc -l)
devsd=$(ls /dev/sd* | wc -l)
while [[ ${devsd} -lt ${count} ]]
do
	echo $(date) waiting count ${count} devsd ${devsd}
	sleep 1
	devsd=$(ls /dev/sd* | wc -l)
done

-------------------------------------------

And for 2): Again, could fail if the hotplug handler forks and returns,
leaving its child running. Shell script like:

-------------------------------------------

#! /bin/bash

# load modules, iscsi login etc here
# ~patman/iscsi/open-iscsi/usr/iscsiadm  -m node --record 22698c --login

hotplug=$(sysctl kernel.hotplug)
while /sbin/pidof -s ${hotplug} > /dev/null 2>&1
do
	echo waiting $(date) ...
	sleep 1
done

-------------------------------------------

More background:

Module loads should check this during boot and install, but I haven't
found such checks (so far, I see some stuff in suse network code but that
is for networks). Most cases will just work for a small number of disks
and a sufficient interval between module load and mounting (for boot) or
use (for an install) of the intended device.

With current FC rawhide/devel, I am working on iscsi install, and had udev
"error" logging enabled on a medium speed dual processor system. So the
scripts are very slow, and the partition setup code is being run right
after iscsi scan (really discovery/login and then scan) and it does not
see all the devices (and I probably have some bugs still). 

It takes over a second per scsi sd, and I have about 60 of them.

I actually have to write this in python ... maybe an
os.system("everything") call.

-- Patrick Mansfield


-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.  Get Certified Today
Register for a JBoss Training Course.  Free Certification Exam
for All Training Attendees Through End of 2005. For more info visit:
http://ads.osdn.com/?ad_idv28&alloc_id\x16845&op=click
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

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

end of thread, other threads:[~2005-11-29 10:44 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-11-18 22:30 waiting for an unknown set of udev /dev entries to complete Patrick Mansfield
2005-11-20  6:03 ` Kay Sievers
2005-11-20 17:25 ` Patrick Mansfield
2005-11-20 18:23 ` Kay Sievers
2005-11-20 20:10 ` Pozsar Balazs
2005-11-20 20:23 ` Marco d'Itri
2005-11-20 23:32 ` Kay Sievers
2005-11-20 23:53 ` Kay Sievers
2005-11-21  0:01 ` Marco d'Itri
2005-11-22 23:13 ` Kay Sievers
2005-11-23  8:26 ` Scott James Remnant
2005-11-23 10:54 ` Pozsar Balazs
2005-11-23 16:27 ` Harald Hoyer
2005-11-23 16:50 ` Kay Sievers
2005-11-23 17:25 ` Pozsar Balazs
2005-11-23 17:46 ` Kay Sievers
2005-11-23 18:16 ` Pozsar Balazs
2005-11-23 18:39 ` Kay Sievers
2005-11-23 21:33 ` Patrick Mansfield
2005-11-28 22:09 ` Pozsar Balazs
2005-11-29 10:44 ` Kay Sievers

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).