[mdadm/f18] Resync with final version of upstream patches for launching mdmon via systemctl.

Jes Sorensen jsorensen at fedoraproject.org
Tue Feb 5 15:25:56 UTC 2013


commit 23c3fb197b98916932e8996b96cc154350680769
Author: Jes Sorensen <Jes.Sorensen at redhat.com>
Date:   Tue Feb 5 16:21:25 2013 +0100

    Resync with final version of upstream patches for launching mdmon via systemctl.
    
    Resolves bz879327
    
    Signed-off-by: Jes Sorensen <Jes.Sorensen at redhat.com>

 ...-for-launching-mdmon-via-systemctl-instea.patch |  232 ++++++++------------
 ...nching-mdmon-fails-print-an-error-message.patch |   32 +++
 ...oot-argument-and-default-to-always-settin.patch |  214 ++++++++++++++++++
 mdadm-3.2.6-mdmon-add-foreground-option.patch      |  106 +++++++++
 mdadm.spec                                         |   41 ++--
 mdmon-offroot at .service                             |   19 --
 mdmon at .service                                     |   13 -
 7 files changed, 467 insertions(+), 190 deletions(-)
---
diff --git a/mdadm-3.2.6-Add-support-for-launching-mdmon-via-systemctl-instea.patch b/mdadm-3.2.6-Add-support-for-launching-mdmon-via-systemctl-instea.patch
index d9301d4..6b69353 100644
--- a/mdadm-3.2.6-Add-support-for-launching-mdmon-via-systemctl-instea.patch
+++ b/mdadm-3.2.6-Add-support-for-launching-mdmon-via-systemctl-instea.patch
@@ -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 at redhat.com>
-Date: Thu, 17 Jan 2013 18:06:43 +0100
-Subject: [PATCH 1/1] Add support for launching mdmon via systemctl instead of
+Date: Fri, 1 Feb 2013 16:15:18 +0100
+Subject: [PATCH 2/4] Add support for launching mdmon via systemctl instead of
  fork/exec
 
-To launch mdmon via systemctl, a new command line argument is added to
-mdadm '--systemctl'. Alternatively it is possible to set the
-environment variable MDMON_SYSTEMCTL.
-
-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).
+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 at redhat.com>
+Signed-off-by: NeilBrown <neilb at suse.de>
 ---
- ReadMe.c |  2 ++
- mdadm.c  |  4 ++++
- mdadm.h  |  2 ++
- mdmon.c  |  4 +++-
- util.c   | 41 ++++++++++++++++++++++++++++++-----------
- 6 files changed, 47 insertions(+), 12 deletions(-)
+ Makefile               |  4 ++++
+ systemd/mdmon at .service | 18 ++++++++++++++++++
+ util.c                 | 28 ++++++++++++++++++++++++++++
+ 3 files changed, 50 insertions(+)
+ create mode 100644 systemd/mdmon at .service
 
-diff --git a/ReadMe.c b/ReadMe.c
-index 0aa8cbd..69b8597 100644
---- a/ReadMe.c
-+++ b/ReadMe.c
-@@ -95,6 +95,7 @@ struct option long_options[] = {
-     {"update-subarray", 1, 0, UpdateSubarray},
-     {"udev-rules", 2, 0, UdevRules},
-     {"offroot", 0, 0, OffRootOpt},
-+    {"systemctl", 0, 0, SystemctlOpt},
- 
-     /* synonyms */
-     {"monitor",   0, 0, 'F'},
-@@ -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;
+diff --git a/Makefile b/Makefile
+index b9787d6..b6edb23 100644
+--- a/Makefile
++++ b/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)\"
+@@ -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
  
-+		case SystemctlOpt:
-+			__mdmon_systemctl = 1;
-+			continue;
++install-systemd: systemd/mdmon at .service
++	$(INSTALL) -D -m 644 systemd/mdmon at .service $(DESTDIR)$(SYSTEMD_DIR)/mdmon at .service
 +
- 		case ':':
- 		case '?':
- 			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 */
-@@ -1485,3 +1486,4 @@ char *xstrdup(const char *str);
- #define MAX_DISKS	4096
+ uninstall:
+ 	rm -f $(DESTDIR)$(MAN8DIR)/mdadm.8 $(DESTDIR)$(MAN8DIR)/mdmon.8 $(DESTDIR)$(MAN4DIR)/md.4 $(DESTDIR)$(MAN5DIR)/mdadm.conf.5 $(DESTDIR)$(BINDIR)/mdadm
  
- extern int __offroot;
-+extern int __mdmon_systemctl;
-diff --git a/mdmon.c b/mdmon.c
-index 5d5ae94..7459ae2 100644
---- a/mdmon.c
-+++ b/mdmon.c
-@@ -188,7 +188,9 @@ static void try_kill_monitor(pid_t pid, char *devname, int sock)
- 	 * might be "@dmon"
- 	 */
- 	if (n < 0 || !(strstr(buf, "mdmon") ||
--		       strstr(buf, "@dmon")))
-+		       strstr(buf, "@dmon") ||
-+		       strstr(buf, "/usr/sbin/mdmon") ||
-+		       strstr(buf, "@usr/sbin/mdmon")))
- 		return;
- 
- 	kill(pid, SIGTERM);
+diff --git a/systemd/mdmon at .service b/systemd/mdmon at .service
+new file mode 100644
+index 0000000..ddb475f
+--- /dev/null
++++ b/systemd/mdmon at .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
 diff --git a/util.c b/util.c
-index 6c10365..8202748 100644
+index e75b754..01af0b5 100644
 --- a/util.c
 +++ b/util.c
-@@ -33,6 +33,7 @@
- #include	<signal.h>
- 
- int __offroot;
-+int __mdmon_systemctl = 1;
- 
- /*
-  * following taken from linux/blkpg.h because they aren't
-@@ -1651,6 +1652,9 @@ int start_mdmon(int devnum)
- 	if (check_env("MDADM_NO_MDMON"))
- 		return 0;
+@@ -1660,6 +1660,34 @@ int start_mdmon(int devnum)
+ 	} else
+ 		pathbuf[0] = '\0';
  
-+	if (check_env("MDMON_SYSTEMCTL"))
-+		__mdmon_systemctl = 1;
++	/* 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;
 +
- 	len = readlink("/proc/self/exe", pathbuf, sizeof(pathbuf)-1);
- 	if (len > 0) {
- 		char *sl;
-@@ -1651,18 +1655,33 @@ int start_mdmon(int devnum)
- 			else
- 				skipped = 0;
- 
--		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);
--				}
-+		if (__mdmon_systemctl) {
-+			if (__offroot) {
-+				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");
++		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?? */
 -- 
 1.7.11.7
 
diff --git a/mdadm-3.2.6-In-case-launching-mdmon-fails-print-an-error-message.patch b/mdadm-3.2.6-In-case-launching-mdmon-fails-print-an-error-message.patch
new file mode 100644
index 0000000..b9dd836
--- /dev/null
+++ b/mdadm-3.2.6-In-case-launching-mdmon-fails-print-an-error-message.patch
@@ -0,0 +1,32 @@
+From 15c10423aa9435ed72bd292fecca69224a20fdc8 Mon Sep 17 00:00:00 2001
+From: Jes Sorensen <Jes.Sorensen at 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 at redhat.com>
+Signed-off-by: NeilBrown <neilb at 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
+
diff --git a/mdadm-3.2.6-Remove-offroot-argument-and-default-to-always-settin.patch b/mdadm-3.2.6-Remove-offroot-argument-and-default-to-always-settin.patch
new file mode 100644
index 0000000..66975dc
--- /dev/null
+++ b/mdadm-3.2.6-Remove-offroot-argument-and-default-to-always-settin.patch
@@ -0,0 +1,214 @@
+From 3e23ba9d7bd3c2a9fbddc286014480672763e563 Mon Sep 17 00:00:00 2001
+From: Jes Sorensen <Jes.Sorensen at 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 at redhat.com>
+Signed-off-by: NeilBrown <neilb at 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
+
diff --git a/mdadm-3.2.6-mdmon-add-foreground-option.patch b/mdadm-3.2.6-mdmon-add-foreground-option.patch
new file mode 100644
index 0000000..36ce25e
--- /dev/null
+++ b/mdadm-3.2.6-mdmon-add-foreground-option.patch
@@ -0,0 +1,106 @@
+From 030419821fb77f9955f2017b4a6d3d8139d6db25 Mon Sep 17 00:00:00 2001
+From: NeilBrown <neilb at 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 at suse.de>
+---
+ mdmon.8                | 10 +++++++++-
+ mdmon.c                |  9 +++++++--
+ systemd/mdmon at .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 at .service b/systemd/mdmon at .service
+index ddb475f..809f527 100644
+--- a/systemd/mdmon at .service
++++ b/systemd/mdmon at .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
+
diff --git a/mdadm.spec b/mdadm.spec
index 6a22265..ff23d8a 100644
--- a/mdadm.spec
+++ b/mdadm.spec
@@ -1,7 +1,7 @@
 Summary:     The mdadm program controls Linux md devices (software RAID arrays)
 Name:        mdadm
 Version:     3.2.6
-Release:     12%{?dist}
+Release:     14%{?dist}
 Source:      http://www.kernel.org/pub/linux/utils/raid/mdadm/mdadm-%{version}.tar.xz
 Source1:     mdmonitor.init
 Source2:     raid-check
@@ -9,13 +9,14 @@ Source3:     mdadm.rules
 Source4:     mdadm-raid-check-sysconfig
 Source5:     mdadm-cron
 Source6:     mdmonitor.service
-Source7:     mdmon-offroot at .service
-Source8:     mdmon at .service
-Source9:     mdadm.conf
-Source10:    mdadm_event.conf
+Source7:     mdadm.conf
+Source8:     mdadm_event.conf
 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
-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
 Patch97:     mdadm-3.2.6-udev.patch
 Patch98:     mdadm-2.5.2-static.patch
@@ -28,7 +29,7 @@ BuildRoot:   %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 Obsoletes:   mdctl,raidtools
 %if "%{fedora}" >= "18"
 Obsoletes:   mdadm-sysvinit
-Conflicts:   dracut < 024-23
+Conflicts:   dracut < 024-25
 Requires(post): systemd-units chkconfig coreutils
 %else
 Requires(post): systemd-units systemd-sysv chkconfig coreutils
@@ -67,7 +68,10 @@ is not used as the system init process.
 %setup -q
 # Use systemctl to launch mdmon on F18 and higher
 %if "%{fedora}" >= "18"
-%patch96 -p1 -b .sysctl
+%patch93 -p1 -b .nooffroot
+%patch94 -p1 -b .sysctl
+%patch95 -p1 -b .mdmonfail
+%patch96 -p1 -b .foreground
 %endif
 
 %patch1 -p1 -b .raidsize
@@ -86,7 +90,7 @@ make %{?_smp_mflags} CXFLAGS="$RPM_OPT_FLAGS" SYSCONFDIR="%{_sysconfdir}" mdadm
 
 %install
 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"
 install -Dp -m 755 %{SOURCE1} %{buildroot}%{_initrddir}/mdmonitor
 %endif
@@ -99,19 +103,17 @@ mkdir -p -m 700 %{buildroot}/var/run/mdadm
 # systemd
 mkdir -p %{buildroot}%{_unitdir}
 install -m644 %{SOURCE6} %{buildroot}%{_unitdir}
-install -m644 %{SOURCE7} %{buildroot}%{_unitdir}
-install -m644 %{SOURCE8} %{buildroot}%{_unitdir}
 
 # tmpfile
 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/
 install -d -m 0710 %{buildroot}%{_localstatedir}/run/%{name}/
 
 # abrt
 %if "%{fedora}" >= "17"
 mkdir -p %{buildroot}/etc/libreport/events.d
-install -m644 %{SOURCE10} %{buildroot}/etc/libreport/events.d
+install -m644 %{SOURCE8} %{buildroot}/etc/libreport/events.d
 %endif
 
 %clean
@@ -144,9 +146,7 @@ rm -rf %{buildroot}
 /lib/udev/rules.d/*
 /sbin/*
 %{_sbindir}/raid-check
-%{_unitdir}/mdmonitor.service
-%{_unitdir}/mdmon-offroot at .service
-%{_unitdir}/mdmon at .service
+%{_unitdir}/*
 %{_mandir}/man*/md*
 %config(noreplace) %{_sysconfdir}/cron.d/*
 %config(noreplace) %{_sysconfdir}/sysconfig/*
@@ -162,6 +162,15 @@ rm -rf %{buildroot}
 %endif
 
 %changelog
+* Tue Feb 5 2013 Jes Sorensen <Jes.Sorensen at 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 at 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 at redhat.com> - 3.2.6-12
 - Launch mdmon via systemctl to avoid it ending up in the wrong cgroup
   and getting killed in the boot process when switching from the


More information about the scm-commits mailing list