]> git.ipfire.org Git - thirdparty/mdadm.git/commit - mdadm.h
mdmon: Improve switchroot interactions.
authorNeilBrown <neilb@suse.de>
Mon, 13 Mar 2023 03:42:58 +0000 (14:42 +1100)
committerJes Sorensen <jes@trained-monkey.org>
Sun, 19 Mar 2023 16:33:25 +0000 (12:33 -0400)
commit723d1df4946eb40337bf494f9b2549500c1399b2
treec28a33058108fecc8c14f6f75c7bc820f8970d32
parent0f9a4b3e11fbe4f8631d20b1f89cf43e9219db55
mdmon: Improve switchroot interactions.

We need a new mdmon@mdfoo instance to run in the root filesystem after
switch root, as /sys and /dev are removed from the initrd.

systemd will not start a new unit with the same name running while the
old unit is still active, and we want the two mdmon processes to overlap
in time to avoid any risk of deadlock, which can happen when a write is
attempted with no mdmon running.

So we need a different unit name in the initrd than in the root.  Apart
from the name, everything else should be the same.

This is easily achieved using a different instance name as the
mdmon@.service unit file already supports multiple instances (for
different arrays).

So start "mdmon@mdfoo.service" from root, but
"mdmon@initrd-mdfoo.service" from the initrd.  udev can tell which
circumstance is the case by looking for /etc/initrd-release.
continue_from_systemd() is enhanced so that the "initrd-" prefix can be
requested.

Teach mdmon that a container name like "initrd/foo" should be treated
just like "foo".  Note that systemd passes the instance name
"initrd-foo" as "initrd/foo".

We don't need a similar mechanism at shutdown because dracut runs
"mdmon --takeover --all" when appropriate.

Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
Grow.c
mdadm.h
mdmon.c
systemd/mdmon@.service
udev-md-raid-arrays.rules
util.c