From: Yu Watanabe Date: Fri, 20 May 2022 08:25:12 +0000 (+0200) Subject: core/device: do not downgrade device state if it is already enumerated X-Git-Tag: v252-rc1~924^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F23517%2Fhead;p=thirdparty%2Fsystemd.git core/device: do not downgrade device state if it is already enumerated On switching root, a device may have a persistent databse. In that case, Device.enumerated_found may have DEVICE_FOUND_UDEV flag, and it is not necessary to downgrade the Device.deserialized_found and Device.deserialized_state. Otherwise, the state of the device unit may be changed plugged -> dead -> plugged, if the device has not been mounted. Fixes #23429. [mwilck: cherry-picked from #23437] --- diff --git a/src/core/device.c b/src/core/device.c index 87286305234..fcde8a420e6 100644 --- a/src/core/device.c +++ b/src/core/device.c @@ -201,7 +201,8 @@ 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 (!m->honor_device_enumeration && !MANAGER_IS_USER(m) && + !FLAGS_SET(d->enumerated_found, DEVICE_FOUND_UDEV)) { found &= ~DEVICE_FOUND_UDEV; /* ignore DEVICE_FOUND_UDEV bit */ if (state == DEVICE_PLUGGED) state = DEVICE_TENTATIVE; /* downgrade state */