linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrey Borzenkov <arvidjaar@mail.ru>
To: Lennart Poettering <lennart@poettering.net>
Cc: linux-raid@vger.kernel.org, systemd-devel@lists.freedesktop.org
Subject: Re: systemd kills mdmon if it was started manually by user
Date: Fri, 4 Feb 2011 22:55:06 +0300	[thread overview]
Message-ID: <AANLkTik7dd5SHkuBVrS6LLDR9v57GsFjjxDKQKPp-YVL@mail.gmail.com> (raw)
In-Reply-To: <20110125042814.GA9727@tango.0pointer.de>

On Tue, Jan 25, 2011 at 7:28 AM, Lennart Poettering
<lennart@poettering.net> wrote:
> On Tue, 25.01.11 06:58, Andrey Borzenkov (arvidjaar@mail.ru) wrote:
>
>> > systemd supports instantiated services, for example to deal with the
>> > gettys (e.g. "getty@tty5.service"). It should be trivial to use the same
>> > for mdmon (e.g. "mdmon@md3.service").
>> >
>> That's right, but the names are not known in advance and can change
>> between reboots. This means such units have to be generated
>> dynamically, exist until reboot (ramfs?) and be removed when array is
>> destroyed. Not sure it is really manageable.
>
> Hmm? It should be sufficient to just write the service template properly
> ("mdmon@.service") and then instantiate it when needed with "systemctl
> start mdmon@xyz.service" or something equivalent. itMs a matter of
> issuing a single dbus call.
>
>> And which instance should generate them? mdadm?
>
> i think it is much nicer to spawn the necessary mdadm service instance
> from a udev rule,

Yes, this can be done relatively easily; as proof of concept:

SUBSYSTEM!="block", GOTO="systemd_md_end"
ACTION!="change", GOTO="systemd_md_end"
KERNEL!="md*", GOTO="systemd_md_end"
ATTR{md/metadata_version}=="external:[A-Za-z]*", RUN+="/bin/systemctl
start mdmon@%k.service"
LABEL="systemd_md_end"

where mdon@.service is


[Unit]
Description=mdmon service
BindTo=dev-%i.device
After=dev-%i.device

[Service]
Type=forking
PIDFile=/dev/.mdadm/%i.pid
ExecStart=/sbin/mdmon --takeover %i


With the result

[root@localhost ~]# systemctl status mdmon@md127.service
mdmon@md127.service - mdmon service
          Loaded: loaded (/etc/systemd/system/mdmon@.service)
          Active: active (running) since Tue, 08 Feb 2011 09:43:30
-0500; 5min ago
         Process: 1467 ExecStart=/sbin/mdmon --takeover %i
(code=exited, status=0/SUCCESS)
        Main PID: 1468 (mdmon)
          CGroup: name=systemd:/system/mdmon@.service/md127
                  └ 1468 /sbin/mdmon --takeover md127

Setting SYSTEMD_WANTS would be more elegant solution, but it does not
work with current systemd implementation. It is capable of starting
requested units only on "add" event (effectively the very first time
device becomes plugged), while mdmon must be started on "change"
event, as only then we know whether mdmon is required at all.

Running mdmon via systemd in this way opens up interesting
possibility. E.g. service could be declared "immortal" and be exempt
from usual shutdown sequence ... or is it possible to do already?

Actually it can be implemented even without mdadm patches; apparently
it is possible to suppress normal starting of mdmon by setting
MDADM_NO_MDMON=1

>                           but you could even run it from mdadm by invoking one
> dbus call from it.
>

It may turn out to be necessary still. If container needs mdmon,
arrays it contains won't become read-write until mdmon is started. If
mdmon is started asynchronously by udev, there is window where someone
may try to use array before it is rw. As trivial example, mount unit
which depends on md device unit.

I do not think mdadm maintainer will be happy to add D-Bus dependency
to something that is likely to be included in initrd though :) But may
be we could simply try execl("/bin/systemctl", "start", ...) before
current execl("/sbin/mdmon",... )?
_______________________________________________
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel

  parent reply	other threads:[~2011-02-04 19:55 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-04  8:41 systemd kills mdmon if it was started manually by user Andrey Borzenkov
2010-12-04  9:12 ` Christian Parpart
2010-12-04 12:08   ` Andrey Borzenkov
2010-12-12 13:20     ` [systemd-devel] " Luca Berra
2011-01-07  0:40     ` Lennart Poettering
     [not found]     ` <20101204121413.GC11336@mother.pipebreaker.pl>
     [not found]       ` <AANLkTi=nTSdHc55f08G9sdEK6u8eXp276VOTHHr0jmXT@mail.gmail.com>
     [not found]         ` <20110125034434.GC7046@tango.0pointer.de>
     [not found]           ` <AANLkTik189VTXYpzLFqP=MNBg=Nx-Yq6BOKURtiby++B@mail.gmail.com>
     [not found]             ` <20110125042814.GA9727@tango.0pointer.de>
2011-02-04 19:55               ` Andrey Borzenkov [this message]
2011-02-08  9:48                 ` [systemd-devel] " Lennart Poettering
2011-02-08 10:52                   ` Andrey Borzenkov
2011-02-08 11:07                     ` Lennart Poettering
2011-02-08 13:54                       ` Andrey Borzenkov
2011-02-08 17:28                         ` [systemd-devel] " Lennart Poettering
2011-10-23  8:00                           ` Dan Williams
2011-10-24  8:04                             ` Thomas Jarosch
2011-10-25  1:40                             ` NeilBrown
2011-10-31 11:06                             ` Lennart Poettering
2011-10-31 11:15                               ` [systemd-devel] " Lennart Poettering
2011-11-02  0:44                               ` NeilBrown
2011-11-02  1:16                                 ` Lennart Poettering
2011-11-02  2:03                                   ` NeilBrown
2011-11-02 13:32                                     ` Lennart Poettering
2011-11-02 14:33                                       ` Kay Sievers
2011-11-02 15:17                                         ` Lennart Poettering
2011-11-02 15:21                                           ` Kay Sievers
2011-11-02 15:29                                             ` [systemd-devel] " Lennart Poettering
2011-11-02 22:18                                               ` Williams, Dan J
2011-11-02 23:39                                                 ` Lennart Poettering
2011-11-03  0:28                                                   ` Williams, Dan J
2011-11-02 17:21                                           ` Williams, Dan J
2011-11-02 23:35                                             ` Lennart Poettering
2011-11-02 18:16                                         ` Williams, Dan J
2011-11-02 18:49                                           ` Kay Sievers
2011-11-02 19:31                                             ` Williams, Dan J
2011-11-02 19:51                                               ` Kay Sievers
2011-11-07  2:52                                       ` NeilBrown
2011-11-07  3:42                                         ` Kay Sievers
2011-11-07  4:30                                           ` NeilBrown
2011-11-07 12:00                                         ` Lennart Poettering
2011-11-07 19:09                                           ` Williams, Dan J
2011-11-08 14:43                                             ` Lennart Poettering
2011-11-08 23:27                                               ` Williams, Dan J
2011-11-08  0:11                                       ` Michal Soltys
2011-11-08 16:46                                         ` Michal Soltys
2011-11-08 20:32                                           ` Michal Soltys
2011-11-08 22:29                                             ` Williams, Dan J
2011-02-09 14:01                       ` Lennart Poettering
2011-01-07  0:38 ` Lennart Poettering
2011-01-07  1:09   ` [systemd-devel] " Michael Biebl
2011-01-07  1:17     ` Roman Mamedov
2011-01-07  1:16   ` NeilBrown
2011-01-07  1:42     ` Lennart Poettering

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AANLkTik7dd5SHkuBVrS6LLDR9v57GsFjjxDKQKPp-YVL@mail.gmail.com \
    --to=arvidjaar@mail.ru \
    --cc=lennart@poettering.net \
    --cc=linux-raid@vger.kernel.org \
    --cc=systemd-devel@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).