core: rework device state logic

System Internals / systemd - Lennart Poettering [poettering.net] - 28 February 2015 10:38 UTC

This change introduces a new state "tentative" for device units. Device units are considered "plugged" when udev announced them, "dead" when they are not available in the kernel, and "tentative" when they are referenced in /proc/self/mountinfo or /proc/swaps but not (yet) announced via udev.

This should fix a race when device nodes (like loop devices) are created and immediately mounted. Previously, systemd might end up seeing the mount unit before the device, and would thus pull down the mount because its BindTo dependency on the device would not be fulfilled.

628c89c core: rework device state logic
src/core/device.c | 368 ++++++++++++++++++++++++++++++++---------------------
src/core/device.h | 14 +-
src/core/mount.c | 46 ++++---
src/core/swap.c | 32 +++--
src/core/swap.h | 4 +-
src/core/unit.c | 1 -
6 files changed, 285 insertions(+), 180 deletions(-)

Upstream: github.com


  • Share