Skip to content

unit: drop initrd-udevadm-cleanup-db.service - #12148

Closed
yuwata wants to merge 2 commits into
systemd:masterfrom
yuwata:drop-udevadm-cleanup-db-for-issue-11997
Closed

yuwata wants to merge 2 commits into
systemd:masterfrom
yuwata:drop-udevadm-cleanup-db-for-issue-11997

Conversation

@yuwata

@yuwata yuwata commented Mar 29, 2019

Copy link
Copy Markdown
Member

Closes #11997.

yuwata added 2 commits March 30, 2019 04:30
After 1fb70e6, device enumeration
on switching root triggers devices state change plugged -> dead.
This is caused by the udevd database is cleared just before switching
root.

Let's preserve all udev database during switching root.

Fixes systemd#11997.
@keszybz

keszybz commented Apr 2, 2019

Copy link
Copy Markdown
Member

Of the three PRs, this one seems the most attractive to me. I think if we're going to do significant changes to how this subsystem operates, we might as well go for the clean option, instead of partial fixups like in the other PRs. I'm installing it on my laptop now, to test with LVM...

@keszybz

keszybz commented Apr 2, 2019

Copy link
Copy Markdown
Member

... it turns out that this breaks LVM. On my machine, the LVM volumes which are necessary for local-fs.target, but are not used in the initramfs are never brought up. I didn't figure out the precise details, but udevadm info shows that they have [email protected], but this is not executed after switching root. Either calling systemctl start lvm2-pvscan2... or vgchange -ay allows local-fs.target to be reached.

@poettering also said:

yeah, i figure dropping that won't work, the differences in the rule sets in the initrd and the host are too big
and i figure this is even worse on systems that do not share the host OS with the initrd

Let's look at the different solutions.

@keszybz keszybz closed this Apr 2, 2019
@yuwata
yuwata deleted the drop-udevadm-cleanup-db-for-issue-11997 branch April 2, 2019 15:31
@mwilck

mwilck commented Jan 30, 2020

Copy link
Copy Markdown
Contributor

As @fbuihuu asked me about this, has anyone figured out why [email protected] wouldn't be started? It'd also be interesting to figure out whether this has been tested with lvm 2.02 or 2.03, as PV scanning is done differently since the demise of lvmetad.

@fbuihuu

fbuihuu commented Jan 31, 2020

Copy link
Copy Markdown
Contributor

@mwilck so I did look at it and the problem with LVM is the following.

The PV (sda2 in my case) is detected by udev in initrd. PID1 is notified and creates the relevant device unit (dev-sda2.device). Due to 69-dm-lvm-metad.rules, SYSTEMD_WANTS="lvm2-pvscan@253:2.service property is added to the device unit. However [email protected] is missing in initrd therefore this dependency is ignored.

Now there are 2 cases:

  1. When initrd-udevadm-cleanup-db.service is used:

    Udev DB is cleared, then PID1 switches to the new root.

    When reexecuting in the host, PID1 enumerates all devices by reading directly into udev DB but since it's now empty all deserialized device units lost their properties. Nevertheless their previous state is restored during the coldplug phase.

    Hence at this point dev-sda2.device is still in plugged state but it lost SYSTEMD_WANTS="lvm2-pvscan@253:2.service property.

    You might ask why the device is not set back to the dead state since it's not been detected during the device enumeration phase. This is to prevent the fake "plugged->dead->plugged" transition from happening. In fact this PR was a tentative to fix that but it broke LVM as you now know so a workaround was added instead, see commit c6e892b but it's still broken, see Devices transition plugged -> dead -> plugged is still not completely fixed #12953

    Now all uevents are retriggered. udevd sent an event for sda2 to PID1. Since udev DB is fully repopulated (using the host's new rules BTW), dev-sda2.device gains SYSTEMD_WANTS="lvm2-pvscan@253:2.service property again.

    Due to a 'special hack' (Lennart's wording, see commit 8811690). PID1 notices this new property and fulfill it immediately and lvm2-pvscan@253:2.service is started as it should.

  2. When inird-udevadm-cleanup-db.service is not used:

    The difference here is that the DB is not cleared therefore when PID1 enumerates all devices, the SYSTEMD_WANTS property is reattached. But at that early time, the device unit is still in dead state, therefore the dep is not started.

    Then PID1 deserializes all units and dev-sda2.device is set in plugged state again. But still too early to retroactively start the device unit dependencies since PID1 is still in "reloading" state.

    Since the deserialized state (plugged) matches the DB contents, nothing more is done.

    Now all uevents are retriggered but SYSTEMD_WANTS="lvm2-pvscan@253:2.service property is not seen as a new dependency since it was already present. Therefore it's ignored by PID1 which considers that it was already fulfill, hence the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

During switchroot, devices transition plugged -> dead -> plugged

4 participants