All of lore.kernel.org
 help / color / mirror / Atom feed
* udevd: serialize device chain event sequence
@ 2004-12-08 23:13 Kay Sievers
  2004-12-09  3:07 ` David Brownell
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Kay Sievers @ 2004-12-08 23:13 UTC (permalink / raw)
  To: linux-hotplug

[-- 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);
 		}
 	}
 }

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

end of thread, other threads:[~2004-12-09 10:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-12-08 23:13 udevd: serialize device chain event sequence Kay Sievers
2004-12-09  3:07 ` David Brownell
2004-12-09  8:18 ` Kay Sievers
2004-12-09 10:06 ` Kay Sievers

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.