systemd: share whole-disk locking with filesystem checks - #18695
Draft
Pawel Winogrodzki (PawelWMS) wants to merge 2 commits into
Draft
systemd: share whole-disk locking with filesystem checks#18695Pawel Winogrodzki (PawelWMS) wants to merge 2 commits into
Pawel Winogrodzki (PawelWMS) wants to merge 2 commits into
Conversation
Route udev and systemd-fsck through shared block-device locking while keeping their distinct lock modes and wait behavior. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: bb0e6716-4886-4e95-9efe-71dcde8687d6
Keep downstream compatibility guidance in the patch description. Do not add it to the patched source. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: bb0e6716-4886-4e95-9efe-71dcde8687d6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Alternative implementation
This draft is an alternative to #18653, not a stacked change. Both proposals add systemd-owned whole-disk serialization around filesystem checks; this version addresses review feedback by sharing the lock mechanics with the udev worker. Do not merge both implementations.
What
lock_whole_block_device()helper to operate on the caller'ssd_deviceobject.systemd-makefscaller.LOCK_SH|LOCK_NBlock and retry behavior.systemd-fsckthrough the same helper with a blockingLOCK_EXlock.systemdandsystemd-boot-signedreleases synchronized at 255-35.Why
The root filesystem check can update ext4 metadata while
systemd-udevdprobes the same disk. If udev observes an inconsistent superblock write, filesystem identification can temporarily fail and boot can lose the device link required by the generated root mount.The udev worker already coordinates probing with a nonblocking shared whole-disk lock. Using one shared helper for both udev and
systemd-fsckkeeps device resolution, open, identity revalidation, close-on-exec, and BSD lock acquisition consistent while preserving each caller's distinct lock mode.Relationship to #18653
#18653 implements the same serialization with a private helper in
systemd-fsck. This alternative moves common lock mechanics intoblockdev-utiland uses them from both call sites. It also closes the parent lock descriptor immediately after the fsck child exits rather than at the end of status handling.Both systemd-owned variants are mutually exclusive with native e2fsprogs whole-disk locking. A child that independently opens and waits for an exclusive lock already retained by its parent would deadlock.
Risk
sd_deviceobject and revalidating its identity.Verification
c5f5f713e9ddec176b741e3cd1b181cbb83109e3(signed).patch --dry-run -p1without fuzz or offsets.daselon both architectures; it fails identically to systemd: lock disks while running filesystem checks #18653 while systemd builds and tests pass.systemd-rpm-macros, at 255-35 in one RPM transaction on a fresh Azure Linux 3 VM running kernel 6.6.143.1-1.azl3.systemd-fsckSHA-256:950eec9a899282ac646efcf3d7320df5ae9b238a456ca4f9cece43402fe3819d.running, no units failed, andemergency.targetremained inactive.multi-user.target.