9eca190d93
array assembled- particularly at boot (bnc#793954) - boot.md: make sure systemd-udev-trigger runs before boot.md to avoid races: bnc#793954 - mdmon@.service - new file plus patches to allow mdmon to be started by systemd, so it doesn't kill it (bnc#321366) OBS-URL: https://build.opensuse.org/package/show/Base:System/mdadm?expand=0&rev=85
100 lines
3.1 KiB
Diff
100 lines
3.1 KiB
Diff
References: bnc#821366
|
|
Git-commit: 0f7bdf8946316548500858303549e396655450c5
|
|
From: Jes Sorensen <Jes.Sorensen@redhat.com>
|
|
Date: Fri, 1 Feb 2013 16:15:18 +0100
|
|
Subject: [PATCH] Add support for launching mdmon via systemctl instead of
|
|
fork/exec
|
|
|
|
If launching mdmon via systemctl fails, we fall back to the old method
|
|
of fork/exec. This allows for having mdmon launched via systemctl
|
|
which avoids problems with it getting killed by systemd due to it
|
|
ending up in the parent's cgroup (udev).
|
|
|
|
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
|
|
Signed-off-by: NeilBrown <neilb@suse.de>
|
|
---
|
|
Makefile | 4 ++++
|
|
systemd/mdmon@.service | 18 ++++++++++++++++++
|
|
util.c | 28 ++++++++++++++++++++++++++++
|
|
3 files changed, 50 insertions(+)
|
|
create mode 100644 systemd/mdmon@.service
|
|
|
|
--- mdadm-3.2.6.orig/Makefile
|
|
+++ mdadm-3.2.6/Makefile
|
|
@@ -73,6 +73,7 @@ MAP_PATH = $(MAP_DIR)/$(MAP_FILE)
|
|
MDMON_DIR = $(MAP_DIR)
|
|
# place for autoreplace cookies
|
|
FAILED_SLOTS_DIR = /run/mdadm/failed-slots
|
|
+SYSTEMD_DIR=/lib/systemd/system
|
|
DIRFLAGS = -DMAP_DIR=\"$(MAP_DIR)\" -DMAP_FILE=\"$(MAP_FILE)\"
|
|
DIRFLAGS += -DMDMON_DIR=\"$(MDMON_DIR)\"
|
|
DIRFLAGS += -DFAILED_SLOTS_DIR=\"$(FAILED_SLOTS_DIR)\"
|
|
@@ -256,6 +257,9 @@ install-man: mdadm.8 md.4 mdadm.conf.5 m
|
|
install-udev: udev-md-raid.rules
|
|
$(INSTALL) -D -m 644 udev-md-raid.rules $(DESTDIR)/lib/udev/rules.d/64-md-raid.rules
|
|
|
|
+install-systemd: systemd/mdmon@.service
|
|
+ $(INSTALL) -D -m 644 systemd/mdmon@.service $(DESTDIR)$(SYSTEMD_DIR)/mdmon@.service
|
|
+
|
|
uninstall:
|
|
rm -f $(DESTDIR)$(MAN8DIR)/mdadm.8 $(DESTDIR)$(MAN8DIR)/mdmon.8 $(DESTDIR)$(MAN4DIR)/md.4 $(DESTDIR)$(MAN5DIR)/mdadm.conf.5 $(DESTDIR)$(BINDIR)/mdadm
|
|
|
|
--- /dev/null
|
|
+++ mdadm-3.2.6/systemd/mdmon@.service
|
|
@@ -0,0 +1,18 @@
|
|
+# This file is part of mdadm.
|
|
+#
|
|
+# mdadm is free software; you can redistribute it and/or modify it
|
|
+# under the terms of the GNU General Public License as published by
|
|
+# the Free Software Foundation; either version 2 of the License, or
|
|
+# (at your option) any later version.
|
|
+
|
|
+[Unit]
|
|
+Description=MD Metadata Monitor on /dev/%I
|
|
+DefaultDependencies=no
|
|
+Before=initrd-switch-root.target
|
|
+
|
|
+[Service]
|
|
+ExecStart=/sbin/mdmon %I
|
|
+StandardInput=null
|
|
+StandardOutput=null
|
|
+StandardError=null
|
|
+KillMode=none
|
|
--- mdadm-3.2.6.orig/util.c
|
|
+++ mdadm-3.2.6/util.c
|
|
@@ -1641,6 +1641,34 @@ int start_mdmon(int devnum)
|
|
} else
|
|
pathbuf[0] = '\0';
|
|
|
|
+ /* First try to run systemctl */
|
|
+ switch(fork()) {
|
|
+ case 0:
|
|
+ /* FIXME yuk. CLOSE_EXEC?? */
|
|
+ skipped = 0;
|
|
+ for (i = 3; skipped < 20; i++)
|
|
+ if (close(i) < 0)
|
|
+ skipped++;
|
|
+ else
|
|
+ skipped = 0;
|
|
+
|
|
+ snprintf(pathbuf, sizeof(pathbuf), "mdmon@%s.service",
|
|
+ devnum2devname(devnum));
|
|
+ status = execl("/usr/bin/systemctl", "systemctl", "start",
|
|
+ pathbuf, NULL);
|
|
+ status = execl("/bin/systemctl", "systemctl", "start",
|
|
+ pathbuf, NULL);
|
|
+ exit(1);
|
|
+ case -1: fprintf(stderr, Name ":cannot run mdmon. "
|
|
+ "Array remains readonly\n");
|
|
+ return -1;
|
|
+ default: /* parent - good */
|
|
+ pid = wait(&status);
|
|
+ if (pid >= 0 && status == 0)
|
|
+ return 0;
|
|
+ }
|
|
+
|
|
+ /* That failed, try running mdmon directly */
|
|
switch(fork()) {
|
|
case 0:
|
|
/* FIXME yuk. CLOSE_EXEC?? */
|