* [PATCH] udevsettle should read udev not kernel seqnum first
@ 2007-03-23 14:46 Pozsar Balazs
2007-03-23 16:26 ` Kay Sievers
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Pozsar Balazs @ 2007-03-23 14:46 UTC (permalink / raw)
To: linux-hotplug
Hi all,
I think that the order of reading the kernel and udev seqnum files
should be: first udev, then kernel, because with the current code
there's a chance of exiting too early, for example in the following
scenario:
1. kernel seqnum is X, udevsettle reads it
2. udev finishes processing the event X, which generates new events
(for example a modprobe), udev seqnum becomes X
3. udevsettle reads the udev seqnum which is X now, so it exits
4. at least another event comes which should have been waited for
Attached patch changes the order to first read the udev seqnum.
diff -Naurd a/udevsettle.c b/udevsettle.c
--- a/udevsettle.c 2006-04-15 19:32:38.000000000 +0200
+++ b/udevsettle.c 2006-04-25 21:40:57.000000000 +0200
@@ -111,9 +111,9 @@
goto exit;
}
- /* read current kernel seqnum */
- strlcpy(filename, sysfs_path, sizeof(filename));
- strlcat(filename, "/kernel/uevent_seqnum", sizeof(filename));
+ /* read current udev seqnum */
+ strlcpy(filename, udev_root, sizeof(filename));
+ strlcat(filename, "/" EVENT_SEQNUM, sizeof(filename));
fd = open(filename, O_RDONLY);
if (fd < 0)
goto exit;
@@ -122,12 +122,12 @@
if (len <= 0)
goto exit;
seqnum[len] = '\0';
- seq_kernel = strtoull(seqnum, NULL, 10);
- info("kernel seqnum = %llu", seq_kernel);
+ seq_udev = strtoull(seqnum, NULL, 10);
+ info("udev seqnum = %llu", seq_udev);
- /* read current udev seqnum */
- strlcpy(filename, udev_root, sizeof(filename));
- strlcat(filename, "/" EVENT_SEQNUM, sizeof(filename));
+ /* read current kernel seqnum */
+ strlcpy(filename, sysfs_path, sizeof(filename));
+ strlcat(filename, "/kernel/uevent_seqnum", sizeof(filename));
fd = open(filename, O_RDONLY);
if (fd < 0)
goto exit;
@@ -136,8 +136,8 @@
if (len <= 0)
goto exit;
seqnum[len] = '\0';
- seq_udev = strtoull(seqnum, NULL, 10);
- info("udev seqnum = %llu", seq_udev);
+ seq_kernel = strtoull(seqnum, NULL, 10);
+ info("kernel seqnum = %llu", seq_kernel);
/* make sure all kernel events have arrived in the queue */
if (seq_udev >= seq_kernel) {
--
pozsy
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CIDÞVDEV
_______________________________________________
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] 4+ messages in thread
* Re: [PATCH] udevsettle should read udev not kernel seqnum first
2007-03-23 14:46 [PATCH] udevsettle should read udev not kernel seqnum first Pozsar Balazs
@ 2007-03-23 16:26 ` Kay Sievers
2007-03-23 16:36 ` Pozsar Balazs
2007-03-23 16:53 ` Kay Sievers
2 siblings, 0 replies; 4+ messages in thread
From: Kay Sievers @ 2007-03-23 16:26 UTC (permalink / raw)
To: linux-hotplug
On 3/23/07, Pozsar Balazs <pozsy@uhulinux.hu> wrote:
> I think that the order of reading the kernel and udev seqnum files
> should be: first udev, then kernel, because with the current code
> there's a chance of exiting too early, for example in the following
> scenario:
> 1. kernel seqnum is X, udevsettle reads it
> 2. udev finishes processing the event X, which generates new events
> (for example a modprobe), udev seqnum becomes X
> 3. udevsettle reads the udev seqnum which is X now, so it exits
> 4. at least another event comes which should have been waited for
Makes sense. I've applied this.
Note, that the kernel interaction is async, and the device creation in
the kernel is threaded, it can always happen that there is currently
no pending uevent in the kernel, even when udev has triggered a device
creation, an it just happens shortly after udevsettle "thinks", that
there is nothing left to wait for.
Thanks,
Kay
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CIDÞVDEV
_______________________________________________
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] 4+ messages in thread
* Re: [PATCH] udevsettle should read udev not kernel seqnum first
2007-03-23 14:46 [PATCH] udevsettle should read udev not kernel seqnum first Pozsar Balazs
2007-03-23 16:26 ` Kay Sievers
@ 2007-03-23 16:36 ` Pozsar Balazs
2007-03-23 16:53 ` Kay Sievers
2 siblings, 0 replies; 4+ messages in thread
From: Pozsar Balazs @ 2007-03-23 16:36 UTC (permalink / raw)
To: linux-hotplug
On Fri, Mar 23, 2007 at 05:26:48PM +0100, Kay Sievers wrote:
> On 3/23/07, Pozsar Balazs <pozsy@uhulinux.hu> wrote:
> >I think that the order of reading the kernel and udev seqnum files
> >should be: first udev, then kernel, because with the current code
> >there's a chance of exiting too early, for example in the following
> >scenario:
> > 1. kernel seqnum is X, udevsettle reads it
> > 2. udev finishes processing the event X, which generates new events
> > (for example a modprobe), udev seqnum becomes X
> > 3. udevsettle reads the udev seqnum which is X now, so it exits
> > 4. at least another event comes which should have been waited for
>
> Makes sense. I've applied this.
>
> Note, that the kernel interaction is async, and the device creation in
> the kernel is threaded, it can always happen that there is currently
> no pending uevent in the kernel, even when udev has triggered a device
> creation, an it just happens shortly after udevsettle "thinks", that
> there is nothing left to wait for.
And in this case, how case one wait until the kernel and udev really
settles down?
--
pozsy
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CIDÞVDEV
_______________________________________________
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] 4+ messages in thread
* Re: [PATCH] udevsettle should read udev not kernel seqnum first
2007-03-23 14:46 [PATCH] udevsettle should read udev not kernel seqnum first Pozsar Balazs
2007-03-23 16:26 ` Kay Sievers
2007-03-23 16:36 ` Pozsar Balazs
@ 2007-03-23 16:53 ` Kay Sievers
2 siblings, 0 replies; 4+ messages in thread
From: Kay Sievers @ 2007-03-23 16:53 UTC (permalink / raw)
To: linux-hotplug
On Fri, 2007-03-23 at 17:36 +0100, Pozsar Balazs wrote:
> On Fri, Mar 23, 2007 at 05:26:48PM +0100, Kay Sievers wrote:
> > On 3/23/07, Pozsar Balazs <pozsy@uhulinux.hu> wrote:
> > >I think that the order of reading the kernel and udev seqnum files
> > >should be: first udev, then kernel, because with the current code
> > >there's a chance of exiting too early, for example in the following
> > >scenario:
> > > 1. kernel seqnum is X, udevsettle reads it
> > > 2. udev finishes processing the event X, which generates new events
> > > (for example a modprobe), udev seqnum becomes X
> > > 3. udevsettle reads the udev seqnum which is X now, so it exits
> > > 4. at least another event comes which should have been waited for
> >
> > Makes sense. I've applied this.
> >
> > Note, that the kernel interaction is async, and the device creation in
> > the kernel is threaded, it can always happen that there is currently
> > no pending uevent in the kernel, even when udev has triggered a device
> > creation, an it just happens shortly after udevsettle "thinks", that
> > there is nothing left to wait for.
>
> And in this case, how case one wait until the kernel and udev really
> settles down?
You can't. In some cases it's possible to watch for kernel-treads, like
the usb-storage device probing, but in a lot of cases it's just
impossible. And there is absolutely no guarantee, that these threads
will always have the same name, because that can change with every
kernel release.
In cases like boot-up, you better wait for the device that you expect to
show up, instead of "all" devices. If your kernel command line
specifies:
root=/dev/disk/by-id/scsi-SATA_ST910021AS_3MH0Y3KF-part1
you just wait until that device is created. In the real root, you may
want to way for all mandatory devices listed in fstab, instead of
assuming that there is a constant event flow of events you can wait for.
Kay
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CIDÞVDEV
_______________________________________________
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] 4+ messages in thread
end of thread, other threads:[~2007-03-23 16:53 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-23 14:46 [PATCH] udevsettle should read udev not kernel seqnum first Pozsar Balazs
2007-03-23 16:26 ` Kay Sievers
2007-03-23 16:36 ` Pozsar Balazs
2007-03-23 16:53 ` Kay Sievers
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox