]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: replace m->honor_device_enumeration with MANAGER_IS_SWITCHING_ROOT()
authorFranck Bui <fbui@suse.com>
Thu, 5 May 2022 09:11:57 +0000 (11:11 +0200)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 5 Aug 2022 13:13:47 +0000 (22:13 +0900)
src/core/device.c
src/core/manager-serialize.c
src/core/manager.c
src/core/manager.h

index fcde8a420e6de05e34199f42a1733e104c23c7de..e3c9ada23f5022c13aa177f658ce0d8d67baa093 100644 (file)
@@ -191,9 +191,8 @@ static int device_coldplug(Unit *u) {
          *   OPTIONS="db_persist". Hence, almost no devices are enumerated in the step 2. However, in general,
          *   we have several serialized devices. So, DEVICE_FOUND_UDEV bit in the deserialized_found must be
          *   ignored, as udev rules in initramfs and the main system are often different. If the deserialized
-         *   state is DEVICE_PLUGGED, we need to downgrade it to DEVICE_TENTATIVE (or DEVICE_DEAD if nobody
-         *   sees the device). Unlike the other starting mode, Manager.honor_device_enumeration == false
-         *   (maybe, it is better to rename the flag) when device_coldplug() and device_catchup() are called.
+         *   state is DEVICE_PLUGGED, we need to downgrade it to DEVICE_TENTATIVE. Unlike the other starting
+         *   mode, MANAGER_IS_SWITCHING_ROOT() is true when device_coldplug() and device_catchup() are called.
          *   Hence, let's conditionalize the operations by using the flag. After switch-root, systemd-udevd
          *   will (re-)process all devices, and the Device.found and Device.state will be adjusted.
          *
@@ -201,7 +200,7 @@ static int device_coldplug(Unit *u) {
          *   Of course, deserialized parameters may be outdated, but the unit state can be adjusted later by
          *   device_catchup() or uevents. */
 
-        if (!m->honor_device_enumeration && !MANAGER_IS_USER(m) &&
+        if (MANAGER_IS_SWITCHING_ROOT(m) &&
             !FLAGS_SET(d->enumerated_found, DEVICE_FOUND_UDEV)) {
                 found &= ~DEVICE_FOUND_UDEV; /* ignore DEVICE_FOUND_UDEV bit */
                 if (state == DEVICE_PLUGGED)
index a91c8268d5024cf6068ccef9f1ef2fccaaf4952e..914bd92e36bab564cb794dd4a6a63fbba81b78a2 100644 (file)
@@ -103,9 +103,6 @@ int manager_serialize(
         (void) serialize_bool(f, "taint-logged", m->taint_logged);
         (void) serialize_bool(f, "service-watchdogs", m->service_watchdogs);
 
-        /* After switching root, udevd has not been started yet. So, enumeration results should not be emitted. */
-        (void) serialize_bool(f, "honor-device-enumeration", !switching_root);
-
         if (m->show_status_overridden != _SHOW_STATUS_INVALID)
                 (void) serialize_item(f, "show-status-overridden",
                                       show_status_to_string(m->show_status_overridden));
@@ -399,15 +396,6 @@ int manager_deserialize(Manager *m, FILE *f, FDSet *fds) {
                         else
                                 m->service_watchdogs = b;
 
-                } else if ((val = startswith(l, "honor-device-enumeration="))) {
-                        int b;
-
-                        b = parse_boolean(val);
-                        if (b < 0)
-                                log_notice("Failed to parse honor-device-enumeration flag '%s', ignoring.", val);
-                        else
-                                m->honor_device_enumeration = b;
-
                 } else if ((val = startswith(l, "show-status-overridden="))) {
                         ShowStatus s;
 
@@ -544,7 +532,7 @@ int manager_deserialize(Manager *m, FILE *f, FDSet *fds) {
 
                         if (q < _MANAGER_TIMESTAMP_MAX) /* found it */
                                 (void) deserialize_dual_timestamp(val, m->timestamps + q);
-                        else if (!startswith(l, "kdbus-fd=")) /* ignore kdbus */
+                        else if (!STARTSWITH_SET(l, "kdbus-fd=", "honor-device-enumeration=")) /* ignore deprecated values */
                                 log_notice("Unknown serialization item '%s', ignoring.", l);
                 }
         }
index 1b59b0624d2dadf5af3c338e22f0f7b3d7d18dc8..f1536415103c78995b8e0a95810b334a365989e4 100644 (file)
@@ -1764,8 +1764,6 @@ static void manager_ready(Manager *m) {
                 (void) touch_file("/run/systemd/systemd-units-load", false,
                         m->timestamps[MANAGER_TIMESTAMP_UNITS_LOAD].realtime ?: now(CLOCK_REALTIME),
                         UID_INVALID, GID_INVALID, 0444);
-
-        m->honor_device_enumeration = true;
 }
 
 Manager* manager_reloading_start(Manager *m) {
@@ -3424,11 +3422,6 @@ int manager_reload(Manager *m) {
         assert(m->n_reloading > 0);
         m->n_reloading--;
 
-        /* On manager reloading, device tag data should exists, thus, we should honor the results of device
-         * enumeration. The flag should be always set correctly by the serialized data, but it may fail. So,
-         * let's always set the flag here for safety. */
-        m->honor_device_enumeration = true;
-
         manager_ready(m);
 
         m->send_reloading_done = true;
index 16d108c7ed50b463f641fd067c115e2b5b966516..e4603daff29eb6d3c087279477bb9b1889fb3ea1 100644 (file)
@@ -449,8 +449,6 @@ struct Manager {
         unsigned sigchldgen;
         unsigned notifygen;
 
-        bool honor_device_enumeration;
-
         VarlinkServer *varlink_server;
         /* When we're a system manager, this object manages the subscription from systemd-oomd to PID1 that's
          * used to report changes in ManagedOOM settings (systemd server - oomd client). When