You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
PR#23218 introduced a regression for devices with db_persist option #23429
Devices with OPTIONS+="db_persist" are not supposed to create dead->plugged transition right after switching root, at least that wasn't the case before and the udev man page describes the option to actually prevent it from happening.
However pr #23218 changed this behavior. I don't know currently whether it will cause any real regression in practice but I think it deserves a discussion before releasing v251.
Hi Martin, it's pretty hard to say for sure that it won't have any negative impact but the facts are that this transition never happened before and the doc clearly describes the use of "db_persist" as way to make sure that the device unit state remains always plugged.
It's not clear to me whether it will cause issue in practice (maybe @mwilck knows ?) but this dead->plugged transition for devices with db_persist doen't look correct and wasn't present before. And udev man page seems to indicate that this transition should not occur.
Why would this even be mentioned in an the udev man page? It's genuine systemd functionality.
I have observed these transitions (I see them all the time actually because I work with multipath-tools, but I didn't bother about it), but definitely no negative impact.
I have a test case here where root FS (btrfs) is on top of LVM on top of MD RAID on top of multipath. Thus the multipath devices (which have db_persist set) are in use once root is mounted, but from the PoV of systemd, they have neither DEVICE_FOUND_MOUNT nor DEVICE_FOUND_SWAP set. Thus they start out "dead" after switching root, just like in @fbuihuu's example. I can see these dead→plugged transitions with loglevel debug, but everything works just fine during boot.
+ if (found == DEVICE_NOT_FOUND)
+ state = DEVICE_DEAD; /* If nobody sees the device, downgrade more */
from 75d7b59, we'd still see transition messages but only "tentative→plugged", not the confusing "dead→plugged". I don't think this can be completely avoided. We apply the result from enumeration after the result from deserialization on purpose.
Yeah, the condition seems slightly offensive, I will fix it after dinner. But, the basic idea of the block is that setting DEVICE_TENTATIVE with DEVICE_NOT_FOUND is super strange.
But, the basic idea of the block is that setting DEVICE_TENTATIVE with DEVICE_NOT_FOUND is super strange.
Not if you consider complex storage stacks. If a device has been "plugged" but not mounted (instead, member of an MD RAID, or an LVM PV or what not), and you mask out DEVICE_FOUND_UDEV, you get this combination. You can of course try to build a model of complex storage stacks in systemd, but I wouldn't recommend it, at least not short term.
DEVICE_TENTATIVE makes a lot of sense for me in this case. At the given point in time (before device_catchup(), systemd has no confirmation from udev whether the device exists, but it existed before, which makes "tentative" a reasonable guess.
Hi Martin, it's pretty hard to say for sure that it won't have any negative impact but the facts are that this transition never happened before and the doc clearly describes the use of "db_persist" as way to make sure that the device unit state remains always plugged.
Correct me if I'm wrong: the issue in #12953 was that we observed plugged→dead transitions. These transitions are fatal, as are dead→plugged transitions based on "guessing" (rather than actual udev device detection). Both these types of wrong transitions are fixed by @yuwata's patch set.
What you've been observing is that db_persist devices undergo dead→plugged transitions repeatedly. The first transition is "real", while the others are just caused by the fact that the devices start out "dead" after re-execution unless they're mounted. I am quite positive that this is harmless, and I am not sure if it can be avoided. We would need to start out with DEVICE_PLUGGED, DEVICE_FOUND_UDEV if enumerated_state == DEVICE_PLUGGED, enumerated_found == DEVICE_FOUND_UDEV after device_enumerate(). While that would fix your issue, my gut feeling is that it might cause problems in other cases like the "systemd reloads while booting" case that we've discussed elsewhere.
@mwilck I'd like to recall that it is dangerous to set DEVICE_TENTATIVE with DEVICE_NOT_FOUND. If we do so in device_coldplug(), then the device will not enter the dead state even if enumerated_found == DEVICE_NOT_FOUND, and it is stuck in the tentative state, and no corresponding unit will be stopped.
If a device has persistent database, then the Device.enumerated_found can be 'reliable' in some sense, and if it has DEVICE_FOUND_UDEV flag, it is not necessary to downgrade the flag and state, as device_catchup() will fix the state soon later. If we adjust the found and state in device_coldplug(), it generates unnecessary state transition, as reported in this issue.
Here, important point is the devices in What= and Requires= are different.
If the block device corresponds to sys-devices-WithPersistentDatabase.device is not mounted, then its Device.enumerated_found == DEVICE_NOT_FOUND on switching root and it enters DEVICE_DEAD, hence even if the device unit corresponds to /dev/BlockWithoutPersistentDatabase is in the tentative state, the mount unit is stopped during the switching root.
@mwilck I'd like to recall that it is dangerous to set DEVICE_TENTATIVE with DEVICE_NOT_FOUND. If we do so in device_coldplug(), then the device will not enter the dead state even if enumerated_found == DEVICE_NOT_FOUND, and it is stuck in the tentative state, and no corresponding unit will be stopped.
IIUC "tentative" corresponds to "activating", and thus will be subject to systemd's general timeout handling for unit activation. IOW if a device was actually "plugged" before switching root, but not found any more in the root FS, it would switch to "dead" state when the timeout expires. Am I missing something?
As noted before, the combination DEVICE_PLUGGED, DEVICE_FOUND_UDEV frequently occurs with multipath, MD, LVM etc. If we mask out DEVICE_FOUND_UDEV after switching root, we end up with found = DEVICE_NOT_FOUND. Resetting state from DEVICE_PLUGGED to DEVICE_DEAD in this case sounds counter-intuitive to me; calling device_set_state(DEVICE_DEAD) would be outright dangerous because it would stop dependent units.
Here, important point is the devices in What= and Requires= are different. If the block device corresponds to sys-devices-WithPersistentDatabase.device is not mounted, then its Device.enumerated_found == DEVICE_NOT_FOUND on switching root and it enters DEVICE_DEAD
But nothing bad would happen with DEVICE_TENTATIVE.
Activity
mwilck commentedon May 18, 2022
I wouldn't call this a regression. No actual negative impact is known except the debug messages.
See also #23218 (comment)
core: forget (almost) all devices during initrd transition
fbuihuu commentedon May 19, 2022
Hi Martin, it's pretty hard to say for sure that it won't have any negative impact but the facts are that this transition never happened before and the doc clearly describes the use of "db_persist" as way to make sure that the device unit state remains always plugged.
yuwata commentedon May 19, 2022
@mwilck
#23218 (comment)
#23218 (comment)
Yeah, the condition seems slightly offensive, I will fix it after dinner. But, the basic idea of the block is that setting DEVICE_TENTATIVE with DEVICE_NOT_FOUND is super strange.
mwilck commentedon May 19, 2022
Not if you consider complex storage stacks. If a device has been "plugged" but not mounted (instead, member of an MD RAID, or an LVM PV or what not), and you mask out
DEVICE_FOUND_UDEV, you get this combination. You can of course try to build a model of complex storage stacks in systemd, but I wouldn't recommend it, at least not short term.DEVICE_TENTATIVEmakes a lot of sense for me in this case. At the given point in time (beforedevice_catchup(), systemd has no confirmation from udev whether the device exists, but it existed before, which makes "tentative" a reasonable guess.mwilck commentedon May 19, 2022
Correct me if I'm wrong: the issue in #12953 was that we observed plugged→dead transitions. These transitions are fatal, as are dead→plugged transitions based on "guessing" (rather than actual udev device detection). Both these types of wrong transitions are fixed by @yuwata's patch set.
What you've been observing is that
db_persistdevices undergo dead→plugged transitions repeatedly. The first transition is "real", while the others are just caused by the fact that the devices start out "dead" after re-execution unless they're mounted. I am quite positive that this is harmless, and I am not sure if it can be avoided. We would need to start out withDEVICE_PLUGGED, DEVICE_FOUND_UDEVifenumerated_state == DEVICE_PLUGGED, enumerated_found == DEVICE_FOUND_UDEVafterdevice_enumerate(). While that would fix your issue, my gut feeling is that it might cause problems in other cases like the "systemd reloads while booting" case that we've discussed elsewhere.core/device: do not downgrade device state if it is already enumerated
yuwata commentedon May 19, 2022
@mwilck I'd like to recall that it is dangerous to set DEVICE_TENTATIVE with DEVICE_NOT_FOUND. If we do so in device_coldplug(), then the device will not enter the dead state even if
enumerated_found == DEVICE_NOT_FOUND, and it is stuck in the tentative state, and no corresponding unit will be stopped.yuwata commentedon May 19, 2022
If a device has persistent database, then the
Device.enumerated_foundcan be 'reliable' in some sense, and if it has DEVICE_FOUND_UDEV flag, it is not necessary to downgrade the flag and state, as device_catchup() will fix the state soon later. If we adjust the found and state in device_coldplug(), it generates unnecessary state transition, as reported in this issue.yuwata commentedon May 19, 2022
I guess the unnecessary state transition reported in this issue triggers the following mount unit being stopped:
Here, important point is the devices in What= and Requires= are different.
If the block device corresponds to sys-devices-WithPersistentDatabase.device is not mounted, then its
Device.enumerated_found == DEVICE_NOT_FOUNDon switching root and it entersDEVICE_DEAD, hence even if the device unit corresponds to /dev/BlockWithoutPersistentDatabase is in the tentative state, the mount unit is stopped during the switching root.mwilck commentedon May 19, 2022
IIUC "tentative" corresponds to "activating", and thus will be subject to systemd's general timeout handling for unit activation. IOW if a device was actually "plugged" before switching root, but not found any more in the root FS, it would switch to "dead" state when the timeout expires. Am I missing something?
As noted before, the combination
DEVICE_PLUGGED, DEVICE_FOUND_UDEVfrequently occurs with multipath, MD, LVM etc. If we mask outDEVICE_FOUND_UDEVafter switching root, we end up withfound = DEVICE_NOT_FOUND. Resetting state fromDEVICE_PLUGGEDtoDEVICE_DEADin this case sounds counter-intuitive to me; callingdevice_set_state(DEVICE_DEAD)would be outright dangerous because it would stop dependent units.But nothing bad would happen with
DEVICE_TENTATIVE.core/device: do not downgrade device state if it is already enumerated
34 remaining items
core/device: device_coldplug(): don't set DEVICE_DEAD
core/device: do not downgrade device state if it is already enumerated
core/device: device_coldplug(): don't set DEVICE_DEAD
core/device: do not downgrade device state if it is already enumerated
core/device: do not downgrade device state if it is already enumerated
test: cover initrd->sysroot transition in TEST-24
test: cover initrd->sysroot transition in TEST-24
core/device: device_coldplug(): don't set DEVICE_DEAD
core/device: do not downgrade device state if it is already enumerated
core/device: do not downgrade device state if it is already enumerated
core/device: device_coldplug(): don't set DEVICE_DEAD
core/device: do not downgrade device state if it is already enumerated
core/device: device_coldplug(): don't set DEVICE_DEAD