diff mbox series

[5/6] mdmon: Remove need for KillMode=none

Message ID 167745678753.16565.4556106790376379653.stgit@noble.brown (mailing list archive)
State Superseded, archived
Delegated to: Mariusz Tkaczyk
Headers show
Series Assorted patches relating to mdmon | expand

Commit Message

NeilBrown Feb. 27, 2023, 12:13 a.m. UTC
mdmon needs to keep running during the switchroot out of (at boot) and
then back into (at shutdown) the initrd.  It runs until a new mdmon
takes over.

Killmode=none is used to achieve this, with the help of --offroot which
sets argv[0][0] to '@' which systemd understands.

This is needed because mdmon is currently run in system-mdmon.slice
which conflicts with shutdown.target so without Killmode=none mdmon
would get killed early in shutdown when system.mdmon.slice is removed.

As described in systemd.service(5), this conflict which shutdown can be
resolved by explicitly requesting system.slice, which is a natural
counterpart to DefaultDependencies=no.

So add that, and also add IgnoreOnIsolate=true to avoid another possible
source of an early death.  With these we no longer need KillMode=none
which the systemd developers have marked as "deprecated".

Signed-off-by: NeilBrown <neilb@suse.de>
---
 systemd/mdmon@.service |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

Paul Menzel March 6, 2023, 6:45 a.m. UTC | #1
Dear Neil,


Thank you for your patch. Two minor comments below.

Am 27.02.23 um 01:13 schrieb NeilBrown:
> mdmon needs to keep running during the switchroot out of (at boot) and
> then back into (at shutdown) the initrd.  It runs until a new mdmon
> takes over.
> 
> Killmode=none is used to achieve this, with the help of --offroot which
> sets argv[0][0] to '@' which systemd understands.
> 
> This is needed because mdmon is currently run in system-mdmon.slice
> which conflicts with shutdown.target so without Killmode=none mdmon
> would get killed early in shutdown when system.mdmon.slice is removed.
> 
> As described in systemd.service(5), this conflict which shutdown can be

Small typo: … conflict with shutdown …?

> resolved by explicitly requesting system.slice, which is a natural
> counterpart to DefaultDependencies=no.
> 
> So add that, and also add IgnoreOnIsolate=true to avoid another possible
> source of an early death.  With these we no longer need KillMode=none
> which the systemd developers have marked as "deprecated".
> 
> Signed-off-by: NeilBrown <neilb@suse.de>
> ---
>   systemd/mdmon@.service |    7 ++++++-
>   1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/systemd/mdmon@.service b/systemd/mdmon@.service
> index 3502fadc3fc4..3ab908c45a3b 100644
> --- a/systemd/mdmon@.service
> +++ b/systemd/mdmon@.service
> @@ -10,6 +10,9 @@ Description=MD Metadata Monitor on /dev/%I
>   DefaultDependencies=no
>   Before=initrd-switch-root.target
>   Documentation=man:mdmon(8)
> +# allow this to keep running after switchroot, until a new
> +# instance is started

Below you “format” the comment as a sentence – starting with capital 
letter and using a dot/period at the end.

> +IgnoreOnIsolate=true
>   
>   [Service]
>   # The mdmon starting in the initramfs (with dracut at least)
> @@ -22,4 +25,6 @@ ExecStart=BINDIR/mdmon --foreground --offroot --takeover %I
>   # it out) and systemd will remove it when transitioning from
>   # initramfs to rootfs.
>   #PIDFile=/run/mdadm/%I.pid
> -KillMode=none
> +# The default slice is system-mdmon.slice which Conflicts
> +# with shutdown, causing mdmon to exit early.  So use system.slice.
> +Slice=system.slice


Kind regards,

Paul
diff mbox series

Patch

diff --git a/systemd/mdmon@.service b/systemd/mdmon@.service
index 3502fadc3fc4..3ab908c45a3b 100644
--- a/systemd/mdmon@.service
+++ b/systemd/mdmon@.service
@@ -10,6 +10,9 @@  Description=MD Metadata Monitor on /dev/%I
 DefaultDependencies=no
 Before=initrd-switch-root.target
 Documentation=man:mdmon(8)
+# allow this to keep running after switchroot, until a new
+# instance is started
+IgnoreOnIsolate=true
 
 [Service]
 # The mdmon starting in the initramfs (with dracut at least)
@@ -22,4 +25,6 @@  ExecStart=BINDIR/mdmon --foreground --offroot --takeover %I
 # it out) and systemd will remove it when transitioning from
 # initramfs to rootfs.
 #PIDFile=/run/mdadm/%I.pid
-KillMode=none
+# The default slice is system-mdmon.slice which Conflicts
+# with shutdown, causing mdmon to exit early.  So use system.slice.
+Slice=system.slice