Resync with final version of upstream patches for launching mdmon via systemctl.

Resolves bz879327

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
This commit is contained in:
Jes Sorensen 2013-02-05 16:21:25 +01:00
parent 23db92efcc
commit 23c3fb197b
7 changed files with 467 additions and 190 deletions

View File

@ -1,160 +1,108 @@
From df9a354667f1a8b2994cf73a4d396766bc565a91 Mon Sep 17 00:00:00 2001 From 0f7bdf8946316548500858303549e396655450c5 Mon Sep 17 00:00:00 2001
From: Jes Sorensen <Jes.Sorensen@redhat.com> From: Jes Sorensen <Jes.Sorensen@redhat.com>
Date: Thu, 17 Jan 2013 18:06:43 +0100 Date: Fri, 1 Feb 2013 16:15:18 +0100
Subject: [PATCH 1/1] Add support for launching mdmon via systemctl instead of Subject: [PATCH 2/4] Add support for launching mdmon via systemctl instead of
fork/exec fork/exec
To launch mdmon via systemctl, a new command line argument is added to If launching mdmon via systemctl fails, we fall back to the old method
mdadm '--systemctl'. Alternatively it is possible to set the of fork/exec. This allows for having mdmon launched via systemctl
environment variable MDMON_SYSTEMCTL. which avoids problems with it getting killed by systemd due to it
ending up in the parent's cgroup (udev).
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: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
--- ---
ReadMe.c | 2 ++ Makefile | 4 ++++
mdadm.c | 4 ++++ systemd/mdmon@.service | 18 ++++++++++++++++++
mdadm.h | 2 ++ util.c | 28 ++++++++++++++++++++++++++++
mdmon.c | 4 +++- 3 files changed, 50 insertions(+)
util.c | 41 ++++++++++++++++++++++++++++++----------- create mode 100644 systemd/mdmon@.service
6 files changed, 47 insertions(+), 12 deletions(-)
diff --git a/ReadMe.c b/ReadMe.c diff --git a/Makefile b/Makefile
index 0aa8cbd..69b8597 100644 index b9787d6..b6edb23 100644
--- a/ReadMe.c --- a/Makefile
+++ b/ReadMe.c +++ b/Makefile
@@ -95,6 +95,7 @@ struct option long_options[] = { @@ -73,6 +73,7 @@ MAP_PATH = $(MAP_DIR)/$(MAP_FILE)
{"update-subarray", 1, 0, UpdateSubarray}, MDMON_DIR = $(MAP_DIR)
{"udev-rules", 2, 0, UdevRules}, # place for autoreplace cookies
{"offroot", 0, 0, OffRootOpt}, FAILED_SLOTS_DIR = /run/mdadm/failed-slots
+ {"systemctl", 0, 0, SystemctlOpt}, +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)\"
@@ -264,6 +265,9 @@ install-man: mdadm.8 md.4 mdadm.conf.5 mdmon.8
install-udev: udev-md-raid.rules
$(INSTALL) -D -m 644 udev-md-raid.rules $(DESTDIR)/lib/udev/rules.d/64-md-raid.rules
/* synonyms */ +install-systemd: systemd/mdmon@.service
{"monitor", 0, 0, 'F'}, + $(INSTALL) -D -m 644 systemd/mdmon@.service $(DESTDIR)$(SYSTEMD_DIR)/mdmon@.service
@@ -261,6 +262,7 @@ char OptionHelp[] =
" application was launched from initrd/initramfs and\n"
" should not be shutdown by systemd as part of the\n"
" regular shutdown process.\n"
+" --systemctl : Use systemctl to launch mdmon rather than exec/fork\n"
;
/*
"\n"
diff --git a/mdadm.c b/mdadm.c
index 11016e7..4c8d382 100644
--- a/mdadm.c
+++ b/mdadm.c
@@ -176,6 +176,10 @@ int main(int argc, char *argv[])
prefer = NULL;
continue;
+ case SystemctlOpt:
+ __mdmon_systemctl = 1;
+ continue;
+ +
case ':': uninstall:
case '?': rm -f $(DESTDIR)$(MAN8DIR)/mdadm.8 $(DESTDIR)$(MAN8DIR)/mdmon.8 $(DESTDIR)$(MAN4DIR)/md.4 $(DESTDIR)$(MAN5DIR)/mdadm.conf.5 $(DESTDIR)$(BINDIR)/mdadm
fputs(Usage, stderr);
diff --git a/mdadm.h b/mdadm.h
index f1352e3..54874cb 100644
--- a/mdadm.h
+++ b/mdadm.h
@@ -337,6 +337,7 @@ enum special_options {
Continue,
OffRootOpt,
Prefer,
+ SystemctlOpt,
};
/* structures read from config file */ diff --git a/systemd/mdmon@.service b/systemd/mdmon@.service
@@ -1485,3 +1486,4 @@ char *xstrdup(const char *str); new file mode 100644
#define MAX_DISKS 4096 index 0000000..ddb475f
--- /dev/null
extern int __offroot; +++ b/systemd/mdmon@.service
+extern int __mdmon_systemctl; @@ -0,0 +1,18 @@
diff --git a/mdmon.c b/mdmon.c +# This file is part of mdadm.
index 5d5ae94..7459ae2 100644 +#
--- a/mdmon.c +# mdadm is free software; you can redistribute it and/or modify it
+++ b/mdmon.c +# under the terms of the GNU General Public License as published by
@@ -188,7 +188,9 @@ static void try_kill_monitor(pid_t pid, char *devname, int sock) +# the Free Software Foundation; either version 2 of the License, or
* might be "@dmon" +# (at your option) any later version.
*/ +
if (n < 0 || !(strstr(buf, "mdmon") || +[Unit]
- strstr(buf, "@dmon"))) +Description=MD Metadata Monitor on /dev/%I
+ strstr(buf, "@dmon") || +DefaultDependencies=no
+ strstr(buf, "/usr/sbin/mdmon") || +Before=initrd-switch-root.target
+ strstr(buf, "@usr/sbin/mdmon"))) +
return; +[Service]
+ExecStart=/sbin/mdmon %I
kill(pid, SIGTERM); +StandardInput=null
+StandardOutput=null
+StandardError=null
+KillMode=none
diff --git a/util.c b/util.c diff --git a/util.c b/util.c
index 6c10365..8202748 100644 index e75b754..01af0b5 100644
--- a/util.c --- a/util.c
+++ b/util.c +++ b/util.c
@@ -33,6 +33,7 @@ @@ -1660,6 +1660,34 @@ int start_mdmon(int devnum)
#include <signal.h> } else
pathbuf[0] = '\0';
int __offroot; + /* First try to run systemctl */
+int __mdmon_systemctl = 1; + switch(fork()) {
+ case 0:
/* + /* FIXME yuk. CLOSE_EXEC?? */
* following taken from linux/blkpg.h because they aren't + skipped = 0;
@@ -1651,6 +1652,9 @@ int start_mdmon(int devnum) + for (i = 3; skipped < 20; i++)
if (check_env("MDADM_NO_MDMON")) + if (close(i) < 0)
return 0; + skipped++;
+ else
+ if (check_env("MDMON_SYSTEMCTL")) + skipped = 0;
+ __mdmon_systemctl = 1;
+ +
len = readlink("/proc/self/exe", pathbuf, sizeof(pathbuf)-1); + snprintf(pathbuf, sizeof(pathbuf), "mdmon@%s.service",
if (len > 0) { + devnum2devname(devnum));
char *sl; + status = execl("/usr/bin/systemctl", "systemctl", "start",
@@ -1651,18 +1655,33 @@ int start_mdmon(int devnum) + pathbuf, NULL);
else + status = execl("/bin/systemctl", "systemctl", "start",
skipped = 0; + pathbuf, NULL);
+ exit(1);
- for (i=0; paths[i]; i++) + case -1: fprintf(stderr, Name "cannot run mdmon. "
- if (paths[i][0]) { + "Array remains readonly\n");
- if (__offroot) { + return -1;
- execl(paths[i], "mdmon", "--offroot", + default: /* parent - good */
- devnum2devname(devnum), + pid = wait(&status);
- NULL); + if (pid >= 0 && status == 0)
- } else { + return 0;
- execl(paths[i], "mdmon", + }
- devnum2devname(devnum), +
- NULL); + /* That failed, try running mdmon directly */
- } switch(fork()) {
+ if (__mdmon_systemctl) { case 0:
+ if (__offroot) { /* FIXME yuk. CLOSE_EXEC?? */
+ snprintf(pathbuf, 40, "mdmon-offroot@%s.service",
+ devnum2devname(devnum));
+ execl("/usr/bin/systemctl", "systemctl",
+ "start", pathbuf, NULL);
+ } else {
+ snprintf(pathbuf, 30, "mdmon@%s.service",
+ devnum2devname(devnum));
+ execl("/usr/bin/systemctl", "systemctl",
+ "start", pathbuf, NULL);
}
+ } else {
+ for (i = 0; paths[i]; i++)
+ if (paths[i][0]) {
+ if (__offroot) {
+ execl(paths[i], "mdmon",
+ "--offroot",
+ devnum2devname(devnum),
+ NULL);
+ } else {
+ execl(paths[i], "mdmon",
+ devnum2devname(devnum),
+ NULL);
+ }
+ }
+ }
exit(1);
case -1: fprintf(stderr, Name ": cannot run mdmon. "
"Array remains readonly\n");
-- --
1.7.11.7 1.7.11.7

View File

@ -0,0 +1,32 @@
From 15c10423aa9435ed72bd292fecca69224a20fdc8 Mon Sep 17 00:00:00 2001
From: Jes Sorensen <Jes.Sorensen@redhat.com>
Date: Fri, 1 Feb 2013 16:15:19 +0100
Subject: [PATCH 3/4] In case launching mdmon fails, print an error message
before exiting
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
---
util.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/util.c b/util.c
index 01af0b5..8817a3e 100644
--- a/util.c
+++ b/util.c
@@ -1709,8 +1709,11 @@ int start_mdmon(int devnum)
return -1;
default: /* parent - good */
pid = wait(&status);
- if (pid < 0 || status != 0)
+ if (pid < 0 || status != 0) {
+ fprintf(stderr, Name "failed to launch mdmon. "
+ "Array remains readonly\n");
return -1;
+ }
}
return 0;
}
--
1.7.11.7

View File

@ -0,0 +1,214 @@
From 3e23ba9d7bd3c2a9fbddc286014480672763e563 Mon Sep 17 00:00:00 2001
From: Jes Sorensen <Jes.Sorensen@redhat.com>
Date: Fri, 1 Feb 2013 16:15:17 +0100
Subject: [PATCH 1/4] Remove --offroot argument and default to always setting
argv[0] to @
We still allow --offroot to be given - for compatibility with scripts
- but ignore it.
The whole point of --offroot is to get systemd to not auto-kill mdmon,
and we always want that.
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
---
ReadMe.c | 4 ----
mdadm.8.in | 11 -----------
mdadm.c | 15 ++++++++-------
mdadm.h | 2 --
mdmon.8 | 11 +----------
mdmon.c | 14 ++++++--------
util.c | 13 ++-----------
7 files changed, 17 insertions(+), 53 deletions(-)
diff --git a/ReadMe.c b/ReadMe.c
index 4214cb0..c4bb730 100644
--- a/ReadMe.c
+++ b/ReadMe.c
@@ -259,10 +259,6 @@ char OptionHelp[] =
" --query -Q : Display general information about how a\n"
" device relates to the md driver\n"
" --auto-detect : Start arrays auto-detected by the kernel\n"
-" --offroot : Set first character of argv[0] to @ to indicate the\n"
-" application was launched from initrd/initramfs and\n"
-" should not be shutdown by systemd as part of the\n"
-" regular shutdown process.\n"
;
/*
"\n"
diff --git a/mdadm.8.in b/mdadm.8.in
index c1881cd..a3abc2d 100644
--- a/mdadm.8.in
+++ b/mdadm.8.in
@@ -255,17 +255,6 @@ Avoid printing purely informative messages. With this,
.I mdadm
will be silent unless there is something really important to report.
-.TP
-.BR \-\-offroot
-Set first character of argv[0] to @ to indicate mdadm was launched
-from initrd/initramfs and should not be shutdown by systemd as part of
-the regular shutdown process. This option is normally only used by
-the system's initscripts. Please see here for more details on how
-systemd handled argv[0]:
-.IP
-.B http://www.freedesktop.org/wiki/Software/systemd/RootStorageDaemons
-.PP
-
.TP
.BR \-f ", " \-\-force
diff --git a/mdadm.c b/mdadm.c
index 26e8cec..f22fd7b 100644
--- a/mdadm.c
+++ b/mdadm.c
@@ -116,6 +116,13 @@ int main(int argc, char *argv[])
ident.container = NULL;
ident.member = NULL;
+ /*
+ * set first char of argv[0] to @. This is used by
+ * systemd to signal that the task was launched from
+ * initrd/initramfs and should be preserved during shutdown
+ */
+ argv[0][0] = '@';
+
while ((option_index = -1) ,
(opt=getopt_long(argc, argv,
shortopt, long_options,
@@ -159,14 +166,8 @@ int main(int argc, char *argv[])
homehost = optarg;
continue;
- /*
- * --offroot sets first char of argv[0] to @. This is used
- * by systemd to signal that the tast was launched from
- * initrd/initramfs and should be preserved during shutdown
- */
case OffRootOpt:
- argv[0][0] = '@';
- __offroot = 1;
+ /* Silently ignore old option */
continue;
case Prefer:
diff --git a/mdadm.h b/mdadm.h
index be760d2..a761f29 100644
--- a/mdadm.h
+++ b/mdadm.h
@@ -1487,5 +1487,3 @@ char *xstrdup(const char *str);
* v1.x can support 1920
*/
#define MAX_DISKS 4096
-
-extern int __offroot;
diff --git a/mdmon.8 b/mdmon.8
index 598d904..559dd90 100644
--- a/mdmon.8
+++ b/mdmon.8
@@ -5,7 +5,7 @@ mdmon \- monitor MD external metadata arrays
.SH SYNOPSIS
-.BI mdmon " [--all] [--takeover] [--offroot] CONTAINER"
+.BI mdmon " [--all] [--takeover] CONTAINER"
.SH OVERVIEW
The 2.6.27 kernel brings the ability to support external metadata arrays.
@@ -166,15 +166,6 @@ containers with names longer than 5 characters, this argument can be
arbitrarily extended, e.g. to
.BR \-\-all-active-arrays .
.TP
-.BR \-\-offroot
-Set first character of argv[0] to @ to indicate mdmon was launched
-from initrd/initramfs and should not be shutdown by systemd as part of
-the regular shutdown process. This option is normally only used by
-the system's initscripts. Please see here for more details on how
-systemd handled argv[0]:
-.IP
-.B http://www.freedesktop.org/wiki/Software/systemd/RootStorageDaemons
-.PP
.PP
Note that
diff --git a/mdmon.c b/mdmon.c
index 5d5ae94..8720aa5 100644
--- a/mdmon.c
+++ b/mdmon.c
@@ -184,9 +184,6 @@ static void try_kill_monitor(pid_t pid, char *devname, int sock)
buf[sizeof(buf)-1] = 0;
close(fd);
- /* Note that if started with --offroot, the name
- * might be "@dmon"
- */
if (n < 0 || !(strstr(buf, "mdmon") ||
strstr(buf, "@dmon")))
return;
@@ -276,10 +273,6 @@ void usage(void)
" --help -h : This message\n"
" --all : All devices\n"
" --takeover -t : Takeover container\n"
-" --offroot : Set first character of argv[0] to @ to indicate the\n"
-" application was launched from initrd/initramfs and\n"
-" should not be shutdown by systemd as part of the\n"
-" regular shutdown process.\n"
);
exit(2);
}
@@ -303,6 +296,11 @@ int main(int argc, char *argv[])
{NULL, 0, NULL, 0}
};
+ /*
+ * Always change process name to @dmon to avoid systemd killing it
+ */
+ argv[0][0] = '@';
+
while ((opt = getopt_long(argc, argv, "tha", options, NULL)) != -1) {
switch (opt) {
case 'a':
@@ -313,7 +311,7 @@ int main(int argc, char *argv[])
takeover = 1;
break;
case OffRootOpt:
- argv[0][0] = '@';
+ /* silently ignore old option */
break;
case 'h':
default:
diff --git a/util.c b/util.c
index fc9043b..e75b754 100644
--- a/util.c
+++ b/util.c
@@ -32,8 +32,6 @@
#include <dirent.h>
#include <signal.h>
-int __offroot;
-
/*
* following taken from linux/blkpg.h because they aren't
* anywhere else and it isn't safe to #include linux/ * stuff.
@@ -1674,15 +1672,8 @@ int start_mdmon(int devnum)
for (i=0; paths[i]; i++)
if (paths[i][0]) {
- if (__offroot) {
- execl(paths[i], "mdmon", "--offroot",
- devnum2devname(devnum),
- NULL);
- } else {
- execl(paths[i], "mdmon",
- devnum2devname(devnum),
- NULL);
- }
+ execl(paths[i], "mdmon",
+ devnum2devname(devnum), NULL);
}
exit(1);
case -1: fprintf(stderr, Name ": cannot run mdmon. "
--
1.7.11.7

View File

@ -0,0 +1,106 @@
From 030419821fb77f9955f2017b4a6d3d8139d6db25 Mon Sep 17 00:00:00 2001
From: NeilBrown <neilb@suse.de>
Date: Tue, 5 Feb 2013 15:57:09 +1100
Subject: [PATCH 4/4] mdmon: add --foreground option
While not strictly necessary for systemd, it is cleaner to avoid
forking when running from a management daemon. So add a --foreground
option to mdmon.
Signed-off-by: NeilBrown <neilb@suse.de>
---
mdmon.8 | 10 +++++++++-
mdmon.c | 9 +++++++--
systemd/mdmon@.service | 2 +-
3 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/mdmon.8 b/mdmon.8
index 559dd90..a968cdb 100644
--- a/mdmon.8
+++ b/mdmon.8
@@ -5,7 +5,7 @@ mdmon \- monitor MD external metadata arrays
.SH SYNOPSIS
-.BI mdmon " [--all] [--takeover] CONTAINER"
+.BI mdmon " [--all] [--takeover] [--foreground] CONTAINER"
.SH OVERVIEW
The 2.6.27 kernel brings the ability to support external metadata arrays.
@@ -131,6 +131,14 @@ The
device to monitor. It can be a full path like /dev/md/container, or a
simple md device name like md127.
.TP
+.B \-\-foreground
+Normally,
+.I mdmon
+will fork and continue in the background. Adding this option will
+skip that step and run
+.I mdmon
+in the foreground.
+.TP
.B \-\-takeover
This instructs
.I mdmon
diff --git a/mdmon.c b/mdmon.c
index 8720aa5..007071b 100644
--- a/mdmon.c
+++ b/mdmon.c
@@ -288,11 +288,13 @@ int main(int argc, char *argv[])
int opt;
int all = 0;
int takeover = 0;
+ int dofork = 1;
static struct option options[] = {
{"all", 0, NULL, 'a'},
{"takeover", 0, NULL, 't'},
{"help", 0, NULL, 'h'},
{"offroot", 0, NULL, OffRootOpt},
+ {"foreground", 0, NULL, 'F'},
{NULL, 0, NULL, 0}
};
@@ -301,7 +303,7 @@ int main(int argc, char *argv[])
*/
argv[0][0] = '@';
- while ((opt = getopt_long(argc, argv, "tha", options, NULL)) != -1) {
+ while ((opt = getopt_long(argc, argv, "thaF", options, NULL)) != -1) {
switch (opt) {
case 'a':
container_name = argv[optind-1];
@@ -310,6 +312,9 @@ int main(int argc, char *argv[])
case 't':
takeover = 1;
break;
+ case 'F':
+ dofork = 0;
+ break;
case OffRootOpt:
/* silently ignore old option */
break;
@@ -381,7 +386,7 @@ int main(int argc, char *argv[])
container_name);
exit(1);
}
- return mdmon(devname, devnum, do_fork(), takeover);
+ return mdmon(devname, devnum, dofork && do_fork(), takeover);
}
static int mdmon(char *devname, int devnum, int must_fork, int takeover)
diff --git a/systemd/mdmon@.service b/systemd/mdmon@.service
index ddb475f..809f527 100644
--- a/systemd/mdmon@.service
+++ b/systemd/mdmon@.service
@@ -11,7 +11,7 @@ DefaultDependencies=no
Before=initrd-switch-root.target
[Service]
-ExecStart=/sbin/mdmon %I
+ExecStart=/sbin/mdmon --foreground %I
StandardInput=null
StandardOutput=null
StandardError=null
--
1.7.11.7

View File

@ -1,7 +1,7 @@
Summary: The mdadm program controls Linux md devices (software RAID arrays) Summary: The mdadm program controls Linux md devices (software RAID arrays)
Name: mdadm Name: mdadm
Version: 3.2.6 Version: 3.2.6
Release: 12%{?dist} Release: 14%{?dist}
Source: http://www.kernel.org/pub/linux/utils/raid/mdadm/mdadm-%{version}.tar.xz Source: http://www.kernel.org/pub/linux/utils/raid/mdadm/mdadm-%{version}.tar.xz
Source1: mdmonitor.init Source1: mdmonitor.init
Source2: raid-check Source2: raid-check
@ -9,13 +9,14 @@ Source3: mdadm.rules
Source4: mdadm-raid-check-sysconfig Source4: mdadm-raid-check-sysconfig
Source5: mdadm-cron Source5: mdadm-cron
Source6: mdmonitor.service Source6: mdmonitor.service
Source7: mdmon-offroot@.service Source7: mdadm.conf
Source8: mdmon@.service Source8: mdadm_event.conf
Source9: mdadm.conf
Source10: mdadm_event.conf
Patch1: mdadm-3.2.6-Create.c-check-if-freesize-is-equal-0.patch Patch1: mdadm-3.2.6-Create.c-check-if-freesize-is-equal-0.patch
Patch2: mdadm-3.2.6-imsm-Forbid-spanning-between-multiple-controllers.patch Patch2: mdadm-3.2.6-imsm-Forbid-spanning-between-multiple-controllers.patch
Patch96: mdadm-3.2.6-Add-support-for-launching-mdmon-via-systemctl-instea.patch Patch93: mdadm-3.2.6-Remove-offroot-argument-and-default-to-always-settin.patch
Patch94: mdadm-3.2.6-Add-support-for-launching-mdmon-via-systemctl-instea.patch
Patch95: mdadm-3.2.6-In-case-launching-mdmon-fails-print-an-error-message.patch
Patch96: mdadm-3.2.6-mdmon-add-foreground-option.patch
# Fedora customization patches # Fedora customization patches
Patch97: mdadm-3.2.6-udev.patch Patch97: mdadm-3.2.6-udev.patch
Patch98: mdadm-2.5.2-static.patch Patch98: mdadm-2.5.2-static.patch
@ -28,7 +29,7 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
Obsoletes: mdctl,raidtools Obsoletes: mdctl,raidtools
%if "%{fedora}" >= "18" %if "%{fedora}" >= "18"
Obsoletes: mdadm-sysvinit Obsoletes: mdadm-sysvinit
Conflicts: dracut < 024-23 Conflicts: dracut < 024-25
Requires(post): systemd-units chkconfig coreutils Requires(post): systemd-units chkconfig coreutils
%else %else
Requires(post): systemd-units systemd-sysv chkconfig coreutils Requires(post): systemd-units systemd-sysv chkconfig coreutils
@ -67,7 +68,10 @@ is not used as the system init process.
%setup -q %setup -q
# Use systemctl to launch mdmon on F18 and higher # Use systemctl to launch mdmon on F18 and higher
%if "%{fedora}" >= "18" %if "%{fedora}" >= "18"
%patch96 -p1 -b .sysctl %patch93 -p1 -b .nooffroot
%patch94 -p1 -b .sysctl
%patch95 -p1 -b .mdmonfail
%patch96 -p1 -b .foreground
%endif %endif
%patch1 -p1 -b .raidsize %patch1 -p1 -b .raidsize
@ -86,7 +90,7 @@ make %{?_smp_mflags} CXFLAGS="$RPM_OPT_FLAGS" SYSCONFDIR="%{_sysconfdir}" mdadm
%install %install
rm -rf %{buildroot} rm -rf %{buildroot}
make DESTDIR=%{buildroot} MANDIR=%{_mandir} BINDIR=/sbin install make DESTDIR=%{buildroot} MANDIR=%{_mandir} BINDIR=/sbin SYSTEMD_DIR=%{_unitdir} install install-systemd
%if "%{fedora}" <= "17" %if "%{fedora}" <= "17"
install -Dp -m 755 %{SOURCE1} %{buildroot}%{_initrddir}/mdmonitor install -Dp -m 755 %{SOURCE1} %{buildroot}%{_initrddir}/mdmonitor
%endif %endif
@ -99,19 +103,17 @@ mkdir -p -m 700 %{buildroot}/var/run/mdadm
# systemd # systemd
mkdir -p %{buildroot}%{_unitdir} mkdir -p %{buildroot}%{_unitdir}
install -m644 %{SOURCE6} %{buildroot}%{_unitdir} install -m644 %{SOURCE6} %{buildroot}%{_unitdir}
install -m644 %{SOURCE7} %{buildroot}%{_unitdir}
install -m644 %{SOURCE8} %{buildroot}%{_unitdir}
# tmpfile # tmpfile
mkdir -p %{buildroot}%{_prefix}/lib/tmpfiles.d mkdir -p %{buildroot}%{_prefix}/lib/tmpfiles.d
install -m 0644 %{SOURCE9} %{buildroot}%{_prefix}/lib/tmpfiles.d/%{name}.conf install -m 0644 %{SOURCE7} %{buildroot}%{_prefix}/lib/tmpfiles.d/%{name}.conf
mkdir -p %{buildroot}%{_localstatedir}/run/ mkdir -p %{buildroot}%{_localstatedir}/run/
install -d -m 0710 %{buildroot}%{_localstatedir}/run/%{name}/ install -d -m 0710 %{buildroot}%{_localstatedir}/run/%{name}/
# abrt # abrt
%if "%{fedora}" >= "17" %if "%{fedora}" >= "17"
mkdir -p %{buildroot}/etc/libreport/events.d mkdir -p %{buildroot}/etc/libreport/events.d
install -m644 %{SOURCE10} %{buildroot}/etc/libreport/events.d install -m644 %{SOURCE8} %{buildroot}/etc/libreport/events.d
%endif %endif
%clean %clean
@ -144,9 +146,7 @@ rm -rf %{buildroot}
/lib/udev/rules.d/* /lib/udev/rules.d/*
/sbin/* /sbin/*
%{_sbindir}/raid-check %{_sbindir}/raid-check
%{_unitdir}/mdmonitor.service %{_unitdir}/*
%{_unitdir}/mdmon-offroot@.service
%{_unitdir}/mdmon@.service
%{_mandir}/man*/md* %{_mandir}/man*/md*
%config(noreplace) %{_sysconfdir}/cron.d/* %config(noreplace) %{_sysconfdir}/cron.d/*
%config(noreplace) %{_sysconfdir}/sysconfig/* %config(noreplace) %{_sysconfdir}/sysconfig/*
@ -162,6 +162,15 @@ rm -rf %{buildroot}
%endif %endif
%changelog %changelog
* Tue Feb 5 2013 Jes Sorensen <Jes.Sorensen@redhat.com> - 3.2.6-14
- Resync with final version of upstream patches for launching mdmon
via systemctl. Require dracut 024-025 or later to match.
- Resolves bz879327
* Fri Feb 1 2013 Jes Sorensen <Jes.Sorensen@redhat.com> - 3.2.6-13
- Update to upstream solution for launching mdmon via systemctl
- Resolves bz879327
* Mon Jan 21 2013 Jes Sorensen <Jes.Sorensen@redhat.com> - 3.2.6-12 * Mon Jan 21 2013 Jes Sorensen <Jes.Sorensen@redhat.com> - 3.2.6-12
- Launch mdmon via systemctl to avoid it ending up in the wrong cgroup - Launch mdmon via systemctl to avoid it ending up in the wrong cgroup
and getting killed in the boot process when switching from the and getting killed in the boot process when switching from the

View File

@ -1,19 +0,0 @@
# 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
ConditionPathExists=/etc/initrd-release
[Service]
ExecStart=/usr/sbin/mdmon --offroot %I
StandardInput=null
StandardOutput=null
StandardError=null
KillMode=none

View File

@ -1,13 +0,0 @@
# 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
[Service]
ExecStart=/usr/sbin/mdmon %I