From 723d1df4946eb40337bf494f9b2549500c1399b2 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Mon, 13 Mar 2023 14:42:58 +1100 Subject: 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 Signed-off-by: Jes Sorensen --- Grow.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Grow.c') diff --git a/Grow.c b/Grow.c index bb5fe45..06001f2 100644 --- a/Grow.c +++ b/Grow.c @@ -3516,7 +3516,7 @@ started: if (!forked) if (continue_via_systemd(container ?: sra->sys_name, - GROW_SERVICE)) { + GROW_SERVICE, NULL)) { free(fdlist); free(offsets); sysfs_free(sra); @@ -3714,7 +3714,7 @@ int reshape_container(char *container, char *devname, ping_monitor(container); if (!forked && !freeze_reshape) - if (continue_via_systemd(container, GROW_SERVICE)) + if (continue_via_systemd(container, GROW_SERVICE, NULL)) return 0; switch (forked ? 0 : fork()) { -- cgit v1.2.1