Skip to content

Commit

Permalink
core/device: do not downgrade device state if it is already enumerated
Browse files Browse the repository at this point in the history
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]
  • Loading branch information
yuwata authored and mrc0mmand committed May 26, 2022
1 parent cf1ac0c commit 4fc69e8
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/core/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down

0 comments on commit 4fc69e8

Please sign in to comment.