From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kay Sievers Date: Wed, 08 Dec 2004 23:13:35 +0000 Subject: udevd: serialize device chain event sequence Message-Id: <20041208231335.GA6402@vrfy.org> MIME-Version: 1 Content-Type: multipart/mixed; boundary="FCuugMFkClbJLl1L" List-Id: To: linux-hotplug@vger.kernel.org --FCuugMFkClbJLl1L Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 --FCuugMFkClbJLl1L Content-Type: text/plain; charset=us-ascii Content-Disposition: inline; filename="udevd-serialize-event-sequence-01.patch" ===== 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); } } } --FCuugMFkClbJLl1L-- ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://productguide.itmanagersjournal.com/ _______________________________________________ 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