core: replace m->honor_device_enumeration with MANAGER_IS_SWITCHING_ROOT()
This commit is contained in:
+3
-4
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user