Full path for root kernel arg when rootfs on mpath

It's a backport of [1].

[1] https://github.com/coreos/coreos-installer/pull/1677
This commit is contained in:
Joel Capitao 2025-07-23 10:16:22 +02:00
parent c7846a2c64
commit 4a47051043
No known key found for this signature in database
GPG Key ID: BA202511DDC0AAC4
2 changed files with 107 additions and 1 deletions

View File

@ -0,0 +1,100 @@
From 408459f9af84add0c0e5ab0db1657c8bc7d0a6a5 Mon Sep 17 00:00:00 2001
From: Nikita Dubrovskii <nikita@linux.ibm.com>
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 <nikita@linux.ibm.com>
(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<P: AsRef<Path>>(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<bool> {
+ 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

View File

@ -12,7 +12,7 @@
Name: rust-%{crate}
Version: 0.24.0
Release: 2%{?dist}
Release: 3%{?dist}
Summary: Installer for Fedora CoreOS and RHEL CoreOS
# Upstream license specification: Apache-2.0
@ -25,6 +25,8 @@ Source2: https://github.com/coreos/coreos-installer-dracut/archive/%{drac
# https://github.com/coreos/coreos-installer/pull/1654
Patch0: 0001-download-format-byte-unit-with-1-decimal-place-preci.patch
# https://github.com/coreos/coreos-installer/pull/1677
Patch1: 0002-rootmap-use-full-path-for-root-karg-when-rootfs-is-d.patch
ExclusiveArch: %{rust_arches}
%if 0%{?rhel} && !0%{?eln}
@ -176,6 +178,10 @@ from the initramfs.
%endif
%changelog
* Wed Jul 23 2025 Joel Capitao <jcapitao@redhat.com> - 0.24.0-3
- Use the full path for the 'root=' kernel arg when rootfs on mpath
Backport https://github.com/coreos/coreos-installer/pull/1677
* Fri Jul 18 2025 Aashish Radhakrishnan <aaradhak@redhat.com> - 0.24.0-2
- Restore single-decimal precision to stream output
Backport https://github.com/coreos/coreos-installer/pull/1654