From: Thierry Vignaud <tvignaud@mandriva.com>
To: linux-hotplug@vger.kernel.org
Subject: [RFC] adding --sync option to udevsettle
Date: Wed, 16 May 2007 14:59:20 +0000 [thread overview]
Message-ID: <m24pmc4xx3.fsf@vador.mandriva.com> (raw)
[-- 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
next reply other threads:[~2007-05-16 14:59 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-16 14:59 Thierry Vignaud [this message]
2007-05-16 23:44 ` [RFC] adding --sync option to udevsettle Kay Sievers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m24pmc4xx3.fsf@vador.mandriva.com \
--to=tvignaud@mandriva.com \
--cc=linux-hotplug@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).