From: Franck Bui Date: Thu, 5 May 2022 09:11:57 +0000 (+0200) Subject: core: replace m->honor_device_enumeration with MANAGER_IS_SWITCHING_ROOT() X-Git-Tag: v252-rc1~506^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7870de03c52982290f9b8ae11eb4d89db66f4be3;p=thirdparty%2Fsystemd.git core: replace m->honor_device_enumeration with MANAGER_IS_SWITCHING_ROOT() --- diff --git a/src/core/device.c b/src/core/device.c index fcde8a420e6..e3c9ada23f5 100644 --- a/src/core/device.c +++ b/src/core/device.c @@ -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) diff --git a/src/core/manager-serialize.c b/src/core/manager-serialize.c index a91c8268d50..914bd92e36b 100644 --- a/src/core/manager-serialize.c +++ b/src/core/manager-serialize.c @@ -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); } } diff --git a/src/core/manager.c b/src/core/manager.c index 1b59b0624d2..f1536415103 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -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; diff --git a/src/core/manager.h b/src/core/manager.h index 16d108c7ed5..e4603daff29 100644 --- a/src/core/manager.h +++ b/src/core/manager.h @@ -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