[systemd-devel] [PATCH] udevd: add --event-timeout commandline option

Hannes Reinecke hare at suse.de
Mon Jun 2 07:47:45 PDT 2014


On large configurations some events take longer than the
default 30 seconds. Killing those events will leave the
machine halfway configured.
So add a commandline option '--event-timeout' to handle these cases.

Signed-off-by: Hannes Reinecke <hare at suse.de>
---
 man/systemd-udevd.service.xml | 19 +++++++++++++++++++
 src/udev/udevd.c              | 14 ++++++++++++--
 2 files changed, 31 insertions(+), 2 deletions(-)

diff --git a/man/systemd-udevd.service.xml b/man/systemd-udevd.service.xml
index f44b7a0..8de43b1 100644
--- a/man/systemd-udevd.service.xml
+++ b/man/systemd-udevd.service.xml
@@ -44,6 +44,7 @@
       <arg><option>--debug</option></arg>
       <arg><option>--children-max=</option></arg>
       <arg><option>--exec-delay=</option></arg>
+      <arg><option>--event-timeout=</option></arg>
       <arg><option>--resolve-names=early|late|never</option></arg>
       <arg><option>--version</option></arg>
       <arg><option>--help</option></arg>
@@ -96,6 +97,15 @@
       </varlistentry>
 
       <varlistentry>
+        <term><option>--event-timeout=</option></term>
+        <listitem>
+          <para>Wait for the event to finish up to the given
+          number of seconds. After this time the event will
+          be terminated. Default is 30.</para>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
         <term><option>--resolve-names=</option></term>
         <listitem>
           <para>Specify when systemd-udevd should resolve names of users and groups.
@@ -156,6 +166,15 @@
         </listitem>
       </varlistentry>
       <varlistentry>
+        <term><varname>udev.event-timeout=</varname></term>
+        <term><varname>rd.udev.event-timeout=</varname></term>
+        <listitem>
+          <para>Wait for events to finish up to the given number
+          of seconds. This option might be useful if events are
+          terminated due to a timeout in large configurations.</para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
         <term><varname>net.ifnames=</varname></term>
         <listitem>
           <para>Network interfaces are renamed to give them predictable names
diff --git a/src/udev/udevd.c b/src/udev/udevd.c
index 1c9488e..9221fad 100644
--- a/src/udev/udevd.c
+++ b/src/udev/udevd.c
@@ -72,6 +72,7 @@ static bool reload;
 static int children;
 static int children_max;
 static int exec_delay;
+static int event_timeout = 30;
 static sigset_t sigmask_orig;
 static UDEV_LIST(event_list);
 static UDEV_LIST(worker_list);
@@ -306,6 +307,9 @@ static void worker_new(struct event *event)
                                 }
                         }
 
+                        if (event_timeout != 30)
+                                udev_event->timeout_usec = event_timeout * 1000 * 1000;
+
                         /* apply rules, create node, symlinks */
                         udev_event_execute_rules(udev_event, rules, &sigmask_orig);
 
@@ -912,6 +916,8 @@ static void kernel_cmdline_options(struct udev *udev)
                         children_max = strtoul(opt + 18, NULL, 0);
                 } else if (startswith(opt, "udev.exec-delay=")) {
                         exec_delay = strtoul(opt + 16, NULL, 0);
+                } else if (startswith(opt, "udev.event-timeout=")) {
+                        event_timeout = strtoul(opt + 16, NULL, 0);
                 }
 
                 free(s);
@@ -929,6 +935,7 @@ int main(int argc, char *argv[])
                 { "debug", no_argument, NULL, 'D' },
                 { "children-max", required_argument, NULL, 'c' },
                 { "exec-delay", required_argument, NULL, 'e' },
+                { "event-timeout", required_argument, NULL, 't' },
                 { "resolve-names", required_argument, NULL, 'N' },
                 { "help", no_argument, NULL, 'h' },
                 { "version", no_argument, NULL, 'V' },
@@ -972,6 +979,9 @@ int main(int argc, char *argv[])
                 case 'e':
                         exec_delay = strtoul(optarg, NULL, 0);
                         break;
+                case 't':
+                        event_timeout = strtoul(optarg, NULL, 0);
+                        break;
                 case 'D':
                         debug = true;
                         log_set_max_level(LOG_DEBUG);
@@ -1259,7 +1269,7 @@ int main(int argc, char *argv[])
                                 break;
 
                         /* timeout at exit for workers to finish */
-                        timeout = 30 * MSEC_PER_SEC;
+                        timeout = event_timeout * MSEC_PER_SEC;
                 } else if (udev_list_node_is_empty(&event_list) && children == 0) {
                         /* we are idle */
                         timeout = -1;
@@ -1309,7 +1319,7 @@ int main(int argc, char *argv[])
                                 if (worker->state != WORKER_RUNNING)
                                         continue;
 
-                                if ((now(CLOCK_MONOTONIC) - worker->event_start_usec) > 30 * USEC_PER_SEC) {
+                                if ((now(CLOCK_MONOTONIC) - worker->event_start_usec) > event_timeout * USEC_PER_SEC) {
                                         log_error("worker [%u] %s timeout; kill it", worker->pid,
                                             worker->event ? worker->event->devpath : "<idle>");
                                         kill(worker->pid, SIGKILL);
-- 
1.8.4.5



More information about the systemd-devel mailing list