dcavalca / rpms / systemd

Forked from rpms/systemd 4 months ago
Clone
8d86bd
From 207f51115c18c668982ef8bdb8a024fccaeb87f0 Mon Sep 17 00:00:00 2001
8d86bd
From: David Tardon <dtardon@redhat.com>
8d86bd
Date: Sat, 16 Jul 2022 09:49:12 +0200
8d86bd
Subject: [PATCH] core: allow to set default timeout for devices
8d86bd
8d86bd
Fixes: #19879
8d86bd
(cherry picked from commit a0fe19f9f791c05af236265954b1d73e8fcf5468)
8d86bd
8d86bd
Resolves: #1967245
8d86bd
---
8d86bd
 src/core/dbus-manager.c | 1 +
8d86bd
 src/core/device.c       | 2 +-
8d86bd
 src/core/main.c         | 4 ++++
8d86bd
 src/core/manager.c      | 1 +
8d86bd
 src/core/manager.h      | 1 +
8d86bd
 src/core/system.conf.in | 1 +
8d86bd
 6 files changed, 9 insertions(+), 1 deletion(-)
8d86bd
8d86bd
diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c
8d86bd
index 7488f22116..5b1ed3646e 100644
8d86bd
--- a/src/core/dbus-manager.c
8d86bd
+++ b/src/core/dbus-manager.c
8d86bd
@@ -2509,6 +2509,7 @@ const sd_bus_vtable bus_manager_vtable[] = {
8d86bd
         SD_BUS_PROPERTY("DefaultTimerAccuracyUSec", "t", bus_property_get_usec, offsetof(Manager, default_timer_accuracy_usec), SD_BUS_VTABLE_PROPERTY_CONST),
8d86bd
         SD_BUS_PROPERTY("DefaultTimeoutStartUSec", "t", bus_property_get_usec, offsetof(Manager, default_timeout_start_usec), SD_BUS_VTABLE_PROPERTY_CONST),
8d86bd
         SD_BUS_PROPERTY("DefaultTimeoutStopUSec", "t", bus_property_get_usec, offsetof(Manager, default_timeout_stop_usec), SD_BUS_VTABLE_PROPERTY_CONST),
8d86bd
+        SD_BUS_PROPERTY("DefaultDeviceTimeoutUSec", "t", bus_property_get_usec, offsetof(Manager, default_device_timeout_usec), SD_BUS_VTABLE_PROPERTY_CONST),
8d86bd
         SD_BUS_PROPERTY("DefaultRestartUSec", "t", bus_property_get_usec, offsetof(Manager, default_restart_usec), SD_BUS_VTABLE_PROPERTY_CONST),
8d86bd
         SD_BUS_PROPERTY("DefaultStartLimitIntervalUSec", "t", bus_property_get_usec, offsetof(Manager, default_start_limit_interval), SD_BUS_VTABLE_PROPERTY_CONST),
8d86bd
         /* The following two items are obsolete alias */
8d86bd
diff --git a/src/core/device.c b/src/core/device.c
8d86bd
index cb8b66dfc5..71b7c1ef81 100644
8d86bd
--- a/src/core/device.c
8d86bd
+++ b/src/core/device.c
8d86bd
@@ -97,7 +97,7 @@ static void device_init(Unit *u) {
8d86bd
          * indefinitely for plugged in devices, something which cannot
8d86bd
          * happen for the other units since their operations time out
8d86bd
          * anyway. */
8d86bd
-        u->job_running_timeout = u->manager->default_timeout_start_usec;
8d86bd
+        u->job_running_timeout = u->manager->default_device_timeout_usec;
8d86bd
 
8d86bd
         u->ignore_on_isolate = true;
8d86bd
 
8d86bd
diff --git a/src/core/main.c b/src/core/main.c
8d86bd
index 08a4df3c97..bfd4c531a7 100644
8d86bd
--- a/src/core/main.c
8d86bd
+++ b/src/core/main.c
8d86bd
@@ -109,6 +109,7 @@ static usec_t arg_default_restart_usec;
8d86bd
 static usec_t arg_default_timeout_start_usec;
8d86bd
 static usec_t arg_default_timeout_stop_usec;
8d86bd
 static usec_t arg_default_timeout_abort_usec;
8d86bd
+static usec_t arg_default_device_timeout_usec;
8d86bd
 static bool arg_default_timeout_abort_set;
8d86bd
 static usec_t arg_default_start_limit_interval;
8d86bd
 static unsigned arg_default_start_limit_burst;
8d86bd
@@ -687,6 +688,7 @@ static int parse_config_file(void) {
8d86bd
                 { "Manager", "DefaultStandardError",      config_parse_output_restricted,0, &arg_default_std_error                 },
8d86bd
                 { "Manager", "DefaultTimeoutStartSec",    config_parse_sec,              0, &arg_default_timeout_start_usec        },
8d86bd
                 { "Manager", "DefaultTimeoutStopSec",     config_parse_sec,              0, &arg_default_timeout_stop_usec         },
8d86bd
+                { "Manager", "DefaultDeviceTimeoutSec",   config_parse_sec,              0, &arg_default_device_timeout_usec       },
8d86bd
                 { "Manager", "DefaultRestartSec",         config_parse_sec,              0, &arg_default_restart_usec              },
8d86bd
                 { "Manager", "DefaultStartLimitInterval", config_parse_sec,              0, &arg_default_start_limit_interval      }, /* obsolete alias */
8d86bd
                 { "Manager", "DefaultStartLimitIntervalSec",config_parse_sec,            0, &arg_default_start_limit_interval      },
8d86bd
@@ -754,6 +756,7 @@ static void set_manager_defaults(Manager *m) {
8d86bd
         m->default_std_error = arg_default_std_error;
8d86bd
         m->default_timeout_start_usec = arg_default_timeout_start_usec;
8d86bd
         m->default_timeout_stop_usec = arg_default_timeout_stop_usec;
8d86bd
+        m->default_device_timeout_usec = arg_default_device_timeout_usec;
8d86bd
         m->default_restart_usec = arg_default_restart_usec;
8d86bd
         m->default_start_limit_interval = arg_default_start_limit_interval;
8d86bd
         m->default_start_limit_burst = arg_default_start_limit_burst;
8d86bd
@@ -2077,6 +2080,7 @@ static void reset_arguments(void) {
8d86bd
         arg_default_timeout_stop_usec = DEFAULT_TIMEOUT_USEC;
8d86bd
         arg_default_timeout_abort_usec = DEFAULT_TIMEOUT_USEC;
8d86bd
         arg_default_timeout_abort_set = false;
8d86bd
+        arg_default_device_timeout_usec = DEFAULT_TIMEOUT_USEC;
8d86bd
         arg_default_start_limit_interval = DEFAULT_START_LIMIT_INTERVAL;
8d86bd
         arg_default_start_limit_burst = DEFAULT_START_LIMIT_BURST;
8d86bd
         arg_runtime_watchdog = 0;
8d86bd
diff --git a/src/core/manager.c b/src/core/manager.c
8d86bd
index 5873e5b6d7..f4611e6f8f 100644
8d86bd
--- a/src/core/manager.c
8d86bd
+++ b/src/core/manager.c
8d86bd
@@ -731,6 +731,7 @@ int manager_new(UnitFileScope scope, unsigned test_run_flags, Manager **_m) {
8d86bd
         m->default_tasks_max = UINT64_MAX;
8d86bd
         m->default_timeout_start_usec = DEFAULT_TIMEOUT_USEC;
8d86bd
         m->default_timeout_stop_usec = DEFAULT_TIMEOUT_USEC;
8d86bd
+        m->default_device_timeout_usec = DEFAULT_TIMEOUT_USEC,
8d86bd
         m->default_restart_usec = DEFAULT_RESTART_USEC;
8d86bd
         m->original_log_level = -1;
8d86bd
         m->original_log_target = _LOG_TARGET_INVALID;
8d86bd
diff --git a/src/core/manager.h b/src/core/manager.h
8d86bd
index 7b572c8dfd..3f2cfc5e2e 100644
8d86bd
--- a/src/core/manager.h
8d86bd
+++ b/src/core/manager.h
8d86bd
@@ -285,6 +285,7 @@ struct Manager {
8d86bd
         ExecOutput default_std_output, default_std_error;
8d86bd
 
8d86bd
         usec_t default_restart_usec, default_timeout_start_usec, default_timeout_stop_usec;
8d86bd
+        usec_t default_device_timeout_usec;
8d86bd
 
8d86bd
         usec_t default_start_limit_interval;
8d86bd
         unsigned default_start_limit_burst;
8d86bd
diff --git a/src/core/system.conf.in b/src/core/system.conf.in
8d86bd
index 84246c0e36..2f6852a89f 100644
8d86bd
--- a/src/core/system.conf.in
8d86bd
+++ b/src/core/system.conf.in
8d86bd
@@ -37,6 +37,7 @@
8d86bd
 #DefaultStandardError=inherit
8d86bd
 #DefaultTimeoutStartSec=90s
8d86bd
 #DefaultTimeoutStopSec=90s
8d86bd
+#DefaultDeviceTimeoutSec=90s
8d86bd
 #DefaultRestartSec=100ms
8d86bd
 #DefaultStartLimitIntervalSec=10s
8d86bd
 #DefaultStartLimitBurst=5