From 408459f9af84add0c0e5ab0db1657c8bc7d0a6a5 Mon Sep 17 00:00:00 2001 From: Nikita Dubrovskii Date: Wed, 9 Jul 2025 09:02:07 +0200 Subject: [PATCH] rootmap: use full path for 'root=' karg when rootfs is directly on multipath Issue: https://github.com/coreos/fedora-coreos-tracker/issues/1980 This was first observed on s390x builders under high system load, where `ext.config.multipath.resilient` would intermittently fail during subsequent boot: ``` [ 2.781559] multipathd[321]: sdd [8:48]: path added to devmap 0xcadf6fadb3ee446d [ 2.853163] multipathd[321]: sdb [8:16]: path added to devmap 0x000000000000000b [ 3.012431] systemd[1]: Reached target coreos-multipath-wait.target - CoreOS Wait For Multipathed Boot. [ 3.139605] systemd[1]: Mounting sysroot.mount - /sysroot... [ 3.450666] mount[806]: mount: /sysroot: fsconfig system call failed: /dev/sdd4: Can't open blockdev. ``` It looks like a race condition between multipathd taking ownership of the root device and systemd trying to mount /sysroot. This might happen because the udev database isn't ready in time. Signed-off-by: Nikita Dubrovskii (cherry picked from commit 33a67caa6fd7291c69c1b502d986707bd0d55e23) --- docs/release-notes.md | 5 +++++ src/bin/rdcore/rootmap.rs | 28 ++++++++++++++++++++++++---- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/docs/release-notes.md b/docs/release-notes.md index 32ee5b8..19e89f3 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -14,6 +14,11 @@ Minor changes: Internal changes: +- Add initial TMT tests and a new workflow to execute tests on PRs +- Use release profile for smaller binaries in CI testing +- Support cryptsetup-2.8.0's UUIDs naming of dm-integrity devices +- rootmap: Inject `root=/dev/disk/by-uuid/dm-mpath-$UUID` when on multipath + Packaging changes: diff --git a/src/bin/rdcore/rootmap.rs b/src/bin/rdcore/rootmap.rs index 43b466c..7aff0bd 100644 --- a/src/bin/rdcore/rootmap.rs +++ b/src/bin/rdcore/rootmap.rs @@ -41,6 +41,8 @@ pub fn rootmap(config: RootmapConfig) -> Result<()> { // and from that we can collect all the parent backing devices too let mut backing_devices = get_blkdev_deps_recursing(&device)?; + // check if device's parent (last in the list) is a mpath device + let on_multipath = is_on_multipath(&backing_devices)?; backing_devices.push(device); // for each of those, convert them to kargs @@ -51,13 +53,22 @@ pub fn rootmap(config: RootmapConfig) -> Result<()> { } } + // use full path when the rootfs is directly on multipath; + // this prevents race condition between systemd's autogenerated sysroot.mount and multipathd/udev, + // see also: https://github.com/coreos/fedora-coreos-tracker/issues/1980 + let root = if on_multipath { + // https://github.com/coreos/fedora-coreos-config/blob/testing-devel/overlay.d/05core/usr/lib/udev/rules.d/90-coreos-device-mapper.rules#L25 + format!( + "root=/dev/disk/by-uuid/dm-mpath-{}", + physical_mount.get_filesystem_uuid()? + ) + } else { + format!("root=UUID={}", physical_mount.get_filesystem_uuid()?) + }; // we push the root kargs last, this has the nice property that the final order of kargs goes // from lowest level to highest; see also // https://github.com/coreos/fedora-coreos-tracker/issues/465 - kargs.push(format!( - "root=UUID={}", - physical_mount.get_filesystem_uuid()? - )); + kargs.push(root); // we need this because with root= it's systemd that takes care of mounting via // systemd-fstab-generator, and it defaults to read-only otherwise @@ -307,3 +318,12 @@ fn write_boot_uuid_grub2_dropin>(uuid: &str, p: P) -> Result<()> std::fs::write(p, format!("set BOOT_UUID=\"{uuid}\"\n")) .with_context(|| format!("writing {}", p.display())) } + +fn is_on_multipath(backing_devices: &[PathBuf]) -> Result { + let blkinfo = match backing_devices.last() { + Some(p) => lsblk_single(p)?, + _ => return Ok(false), + }; + + Ok(blkinfo.get("TYPE").is_some_and(|t| t == "mpath")) +} -- 2.47.1