Skip to content

Commit 33a67ca

Browse files
nikita-dubrovskiijlebon
authored andcommitted
rootmap: use full path for 'root=' karg when rootfs is directly on multipath
Issue: coreos/fedora-coreos-tracker#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>
1 parent 582c35b commit 33a67ca

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

docs/release-notes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Internal changes:
1717
- Add initial TMT tests and a new workflow to execute tests on PRs
1818
- Use release profile for smaller binaries in CI testing
1919
- Support cryptsetup-2.8.0's UUIDs naming of dm-integrity devices
20+
- rootmap: Inject `root=/dev/disk/by-uuid/dm-mpath-$UUID` when on multipath
2021

2122
Packaging changes:
2223

src/bin/rdcore/rootmap.rs

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ pub fn rootmap(config: RootmapConfig) -> Result<()> {
4141

4242
// and from that we can collect all the parent backing devices too
4343
let mut backing_devices = get_blkdev_deps_recursing(&device)?;
44+
// check if device's parent (last in the list) is a mpath device
45+
let on_multipath = is_on_multipath(&backing_devices)?;
4446
backing_devices.push(device);
4547

4648
// for each of those, convert them to kargs
@@ -51,13 +53,22 @@ pub fn rootmap(config: RootmapConfig) -> Result<()> {
5153
}
5254
}
5355

56+
// use full path when the rootfs is directly on multipath;
57+
// this prevents race condition between systemd's autogenerated sysroot.mount and multipathd/udev,
58+
// see also: https://github.com/coreos/fedora-coreos-tracker/issues/1980
59+
let root = if on_multipath {
60+
// https://github.com/coreos/fedora-coreos-config/blob/testing-devel/overlay.d/05core/usr/lib/udev/rules.d/90-coreos-device-mapper.rules#L25
61+
format!(
62+
"root=/dev/disk/by-uuid/dm-mpath-{}",
63+
physical_mount.get_filesystem_uuid()?
64+
)
65+
} else {
66+
format!("root=UUID={}", physical_mount.get_filesystem_uuid()?)
67+
};
5468
// we push the root kargs last, this has the nice property that the final order of kargs goes
5569
// from lowest level to highest; see also
5670
// https://github.com/coreos/fedora-coreos-tracker/issues/465
57-
kargs.push(format!(
58-
"root=UUID={}",
59-
physical_mount.get_filesystem_uuid()?
60-
));
71+
kargs.push(root);
6172

6273
// we need this because with root= it's systemd that takes care of mounting via
6374
// 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<()>
307318
std::fs::write(p, format!("set BOOT_UUID=\"{uuid}\"\n"))
308319
.with_context(|| format!("writing {}", p.display()))
309320
}
321+
322+
fn is_on_multipath(backing_devices: &[PathBuf]) -> Result<bool> {
323+
let blkinfo = match backing_devices.last() {
324+
Some(p) => lsblk_single(p)?,
325+
_ => return Ok(false),
326+
};
327+
328+
Ok(blkinfo.get("TYPE").is_some_and(|t| t == "mpath"))
329+
}

0 commit comments

Comments
 (0)