linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kay Sievers <kay.sievers@vrfy.org>
To: linux-hotplug@vger.kernel.org
Subject: udevd: serialize device chain event sequence
Date: Wed, 08 Dec 2004 23:13:35 +0000	[thread overview]
Message-ID: <20041208231335.GA6402@vrfy.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 939 bytes --]

Any objections against the serialization of the event sequence of a
chain of devices. Currently udevd delays only events for the same
DEVPATH.

Example of an "add" event sequence:
  /block/sda
  /block/sda/sda1

With this change, we make sure, that the udev process handling /block/sda
has finished its work (waited for all attributes, created the node) before
we fork the udev event for /block/sda/sda1. This way the event for sda1 can
be sure, that the node for the main device is already created (may be
useful for disk labels).

The main motivation to do this is the program execution of the dev.d/
and hotplug.d/ directory. If we don't wait for the parent event to exit,
we can't be sure that the executed scripts are run in the right order.

It will not affect any parallel device handling, only the sequence of the
devices directory chain is serialized. The 10.000 disks plugged in will still
run as parallel events :)

Thanks,
Kay

[-- Attachment #2: udevd-serialize-event-sequence-01.patch --]
[-- Type: text/plain, Size: 1248 bytes --]

===== udevd.c 1.53 vs edited =====
--- 1.53/udevd.c	2004-11-28 05:56:22 +01:00
+++ edited/udevd.c	2004-12-09 00:04:57 +01:00
@@ -151,16 +151,24 @@
 	}
 }
 
-/* returns already running task with devpath */
+/* returns still running task for the same event sequence */
 static struct hotplug_msg *running_with_devpath(struct hotplug_msg *msg)
 {
 	struct hotplug_msg *loop_msg;
+	int i;
+
 	list_for_each_entry(loop_msg, &running_list, list) {
 		if (loop_msg->devpath == NULL || msg->devpath == NULL)
 			continue;
 
-		if (strcmp(loop_msg->devpath, msg->devpath) == 0)
-			return loop_msg;
+		/* is one DEVPATH a complete part of the other? */
+		for (i = 0; i < DEVPATH_SIZE; i++) {
+			if (loop_msg->devpath[i] == '\0' || msg->devpath[i] == '\0')
+				return loop_msg;
+
+			if (loop_msg->devpath[i] != msg->devpath[i])
+				break;
+		}
 	}
 
 	return NULL;
@@ -181,8 +189,8 @@
 			udev_run(loop_msg);
 			dbg("moved seq %llu to running list", loop_msg->seqnum);
 		} else {
-			dbg("delay seq %llu, cause seq %llu already working on '%s'",
-				loop_msg->seqnum, msg->seqnum, msg->devpath);
+			dbg("delay seq %llu (%s), cause seq %llu (%s) is still running",
+			    loop_msg->seqnum, loop_msg->devpath, msg->seqnum, msg->devpath);
 		}
 	}
 }

             reply	other threads:[~2004-12-08 23:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-12-08 23:13 Kay Sievers [this message]
2004-12-09  3:07 ` udevd: serialize device chain event sequence David Brownell
2004-12-09  8:18 ` Kay Sievers
2004-12-09 10:06 ` 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=20041208231335.GA6402@vrfy.org \
    --to=kay.sievers@vrfy.org \
    --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).