* [RFC] adding --sync option to udevsettle
@ 2007-05-16 14:59 Thierry Vignaud
2007-05-16 23:44 ` Kay Sievers
0 siblings, 1 reply; 2+ messages in thread
From: Thierry Vignaud @ 2007-05-16 14:59 UTC (permalink / raw)
To: linux-hotplug
[-- Attachment #1: Type: text/plain, Size: 993 bytes --]
(First, note that I'm *NOT* subscribe to this ml, so please keep in
Cc: when answering)
Hi,
While using diskdrake on a system with udev, I found out that when
resizing a partition, when we rewrite it and tell the kernel about the
new partitions sizes, there's a race window with udev which then
delete and recreate the nodes.
I think this can happen with quite a lot of tools that have to deal
with /dev/ nodes and happens to make one being indectly created by
doing sg with the kernel (creating a network interface, loading a mass
storage driver, ...).
OK, there's the udevsettle solution.
But it's not complete.
Eg: here we want to wait that device nodes were created in /dev (aka
really a sync in the command queue by analogy with disks controlling),
we do not want to wait for further commands.
The following patch add the --sync option that enables to alter
udevsettle behavior not to wait for further events to be processed (in
case somebody is hapilly feeding udev with events):
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: udevsettle.diff --]
[-- Type: text/x-patch, Size: 1092 bytes --]
--- ./udevsettle.c.tv 2007-05-16 16:33:34.000000000 +0200
+++ ./udevsettle.c 2007-05-16 16:39:04.000000000 +0200
@@ -62,6 +62,8 @@
int loop;
int i;
int rc = 1;
+ int sync_mode = 0;
+ int read_done = 0;
logging_init("udevsettle");
udev_config_init();
@@ -84,6 +86,8 @@
} else if (strcmp(arg, "--help") == 0 || strcmp(arg, "-h") == 0) {
printf("Usage: udevsettle [--help] [--timeout=<seconds>]\n");
goto exit;
+ } else if (strncmp(arg, "--sync", 6) == 0) {
+ sync_mode = 1;
} else {
fprintf(stderr, "unrecognized option '%s'\n", arg);
err("unrecognized option '%s'\n", arg);
@@ -111,6 +115,8 @@
}
/* read current udev seqnum */
+ if (sync_mode && !read_done) {
+ read_done = 1;
strlcpy(filename, udev_root, sizeof(filename));
strlcat(filename, "/" EVENT_SEQNUM, sizeof(filename));
fd = open(filename, O_RDONLY);
@@ -123,6 +128,7 @@
seqnum[len] = '\0';
seq_udev = strtoull(seqnum, NULL, 10);
info("udev seqnum = %llu", seq_udev);
+ }
/* read current kernel seqnum */
strlcpy(filename, sysfs_path, sizeof(filename));
[-- Attachment #3: Type: text/plain, Size: 208 bytes --]
What do you think?
Will you include it?
Note that I'ven't reindented the code in the new "if { ... }" block
for readibility but I can send another patch to bring indent in sync
with logical flow.
See you
[-- Attachment #4: Type: text/plain, Size: 286 bytes --]
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
[-- Attachment #5: Type: text/plain, Size: 226 bytes --]
_______________________________________________
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] 2+ messages in thread
* Re: [RFC] adding --sync option to udevsettle
2007-05-16 14:59 [RFC] adding --sync option to udevsettle Thierry Vignaud
@ 2007-05-16 23:44 ` Kay Sievers
0 siblings, 0 replies; 2+ messages in thread
From: Kay Sievers @ 2007-05-16 23:44 UTC (permalink / raw)
To: linux-hotplug
On 5/16/07, Thierry Vignaud <tvignaud@mandriva.com> wrote:
> (First, note that I'm *NOT* subscribe to this ml, so please keep in
> Cc: when answering)
>
> Hi,
>
> While using diskdrake on a system with udev, I found out that when
> resizing a partition, when we rewrite it and tell the kernel about the
> new partitions sizes, there's a race window with udev which then
> delete and recreate the nodes.
>
> I think this can happen with quite a lot of tools that have to deal
> with /dev/ nodes and happens to make one being indectly created by
> doing sg with the kernel (creating a network interface, loading a mass
> storage driver, ...).
>
> OK, there's the udevsettle solution.
>
> But it's not complete.
>
> Eg: here we want to wait that device nodes were created in /dev (aka
> really a sync in the command queue by analogy with disks controlling),
> we do not want to wait for further commands.
>
> The following patch add the --sync option that enables to alter
> udevsettle behavior not to wait for further events to be processed (in
> case somebody is hapilly feeding udev with events):
If I understand that --sync option correctly, it does only prevent
another round of "wait for the queue to be empty" in the unlikely
situation, that events are generated, but have not arrived at udev.
If something is creating a constant stream of events (that's what you
want to work around here, right?), the queue will just not become
empty and the --sync option will do nothing until the timeout.
Isn't what you are looking for a "check if the queue contains events
for devices with the name 'sda*'" option?
Kay
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
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] 2+ messages in thread
end of thread, other threads:[~2007-05-16 23:44 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-05-16 14:59 [RFC] adding --sync option to udevsettle Thierry Vignaud
2007-05-16 23: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).