Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 948846 - sys-fs/mdadm mdraid rc script susceptible to race condition because it doesn't depend on udev-settle
Summary: sys-fs/mdadm mdraid rc script susceptible to race condition because it doesn'...
Status: UNCONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-01-26 07:37 UTC by Michael Yagliyan
Modified: 2025-01-28 20:43 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Yagliyan 2025-01-26 07:37:28 UTC
The /etc/init.d/mdraid rc script suffers from a race condition whereby the stable-named /dev/disk/... device symlinks setup by udev may not be setup by the time mdraid is running, at which point the mdadm command it runs will fail, and the init system continues on to other scripts which may suffer the same fate.

For example, /etc/init.d/fsck.  mdraid's depends cause the fsck init script to run after mdraid.  But if mdraid exits without having assembled the arrays (or without having ensured they're assembled), fsck may attempt (and fail) to run checks on a not-yet-existent (or not yet fully assembled) md device (assuming you have such a device in fstab and it's enabled for checks).  For me, this resulted in my /home RAID array not being mounted after bootup.

If mdraid declares `need udev-settle` in its `depend()` function, then this won't be a problem anymore.  One could certainly add this themselves via a rc_need="udev-settle" line in /etc/conf.d/mdraid, but for everyone's benefit I think it should be in there by default.  This took me several hours to debug, and I'm sure there are others who have been bit by it.  There is also no official Gentoo guide for mdadm setup, otherwise I'd edit it to suggest this workaround.

FWIW I don't think it is appropriate or necessary for the fsck init script to depend on udev-settle, because these stable-named symlinks are all derived from device properties that can be referred to explicitly in fstab entries, without having to resort to /dev/disk/... symlinks.

Reproducible: Always
Comment 1 Mike Gilbert gentoo-dev 2025-01-28 20:43:31 UTC
udev-settle itself is quite racy; devices may appear at any time.