Update to mdadm-3.3.1

Resolves bz#1105136

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
This commit is contained in:
Jes Sorensen 2014-06-10 15:12:22 +02:00
parent e77c97f845
commit e444603605
9 changed files with 19 additions and 551 deletions

1
.gitignore vendored
View File

@ -16,3 +16,4 @@ clog
/mdadm-3.2.5.tar.xz
/mdadm-3.2.6.tar.xz
/mdadm-3.3.tar.xz
/mdadm-3.3.1.tar.xz

View File

@ -1,108 +0,0 @@
From 0f7bdf8946316548500858303549e396655450c5 Mon Sep 17 00:00:00 2001
From: Jes Sorensen <Jes.Sorensen@redhat.com>
Date: Fri, 1 Feb 2013 16:15:18 +0100
Subject: [PATCH 2/4] 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
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)$(UDEVDIR)/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
diff --git a/systemd/mdmon@.service b/systemd/mdmon@.service
new file mode 100644
index 0000000..ddb475f
--- /dev/null
+++ b/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
diff --git a/util.c b/util.c
index e75b754..01af0b5 100644
--- a/util.c
+++ b/util.c
@@ -1660,6 +1660,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?? */
--
1.7.11.7

View File

@ -1,32 +0,0 @@
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

@ -1,214 +0,0 @@
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

@ -1,106 +0,0 @@
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,59 +0,0 @@
From f2d6b478f7e171fc23d364dde2d5e059909bcc71 Mon Sep 17 00:00:00 2001
From: Jes Sorensen <Jes.Sorensen@redhat.com>
Date: Thu, 10 Oct 2013 09:17:49 +0200
Subject: [PATCH 1/1] Be consistent in return types from byteswap macros
The bswap_*() macros return int values. Make sure we return the
equivalent types in same byteorder pass-through functions to avoid
problems with the original type leaking through to printf() etc.
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
---
mdadm.h | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/mdadm.h b/mdadm.h
index c90fe10..cb207c9 100644
--- a/mdadm.h
+++ b/mdadm.h
@@ -129,12 +129,12 @@ extern __off64_t lseek64 __P ((int __fd, __off64_t __offset, int __whence));
#if !defined(__KLIBC__)
#if BYTE_ORDER == LITTLE_ENDIAN
-#define __cpu_to_le16(_x) (_x)
-#define __cpu_to_le32(_x) (_x)
-#define __cpu_to_le64(_x) (_x)
-#define __le16_to_cpu(_x) (_x)
-#define __le32_to_cpu(_x) (_x)
-#define __le64_to_cpu(_x) (_x)
+#define __cpu_to_le16(_x) (unsigned int)(_x)
+#define __cpu_to_le32(_x) (unsigned int)(_x)
+#define __cpu_to_le64(_x) (unsigned long long)(_x)
+#define __le16_to_cpu(_x) (unsigned int)(_x)
+#define __le32_to_cpu(_x) (unsigned int)(_x)
+#define __le64_to_cpu(_x) (unsigned long long)(_x)
#define __cpu_to_be16(_x) bswap_16(_x)
#define __cpu_to_be32(_x) bswap_32(_x)
@@ -150,12 +150,12 @@ extern __off64_t lseek64 __P ((int __fd, __off64_t __offset, int __whence));
#define __le32_to_cpu(_x) bswap_32(_x)
#define __le64_to_cpu(_x) bswap_64(_x)
-#define __cpu_to_be16(_x) (_x)
-#define __cpu_to_be32(_x) (_x)
-#define __cpu_to_be64(_x) (_x)
-#define __be16_to_cpu(_x) (_x)
-#define __be32_to_cpu(_x) (_x)
-#define __be64_to_cpu(_x) (_x)
+#define __cpu_to_be16(_x) (unsigned int)(_x)
+#define __cpu_to_be32(_x) (unsigned int)(_x)
+#define __cpu_to_be64(_x) (unsigned long long)(_x)
+#define __be16_to_cpu(_x) (unsigned int)(_x)
+#define __be32_to_cpu(_x) (unsigned int)(_x)
+#define __be64_to_cpu(_x) (unsigned long long)(_x)
#else
# error "unknown endianness."
#endif
--
1.8.3.1

View File

@ -1,27 +1,13 @@
--- mdadm-3.3rc1/udev-md-raid-assembly.rules.udev 2013-04-22 17:24:22.000000000 +0200
+++ mdadm-3.3rc1/udev-md-raid-assembly.rules 2013-06-28 14:59:58.092070982 +0200
@@ -4,16 +4,18 @@
SUBSYSTEM!="block", GOTO="md_inc_end"
--- mdadm-3.3.1/udev-md-raid-assembly.rules~ 2014-06-10 13:29:41.192829830 +0200
+++ mdadm-3.3.1/udev-md-raid-assembly.rules 2014-06-10 13:30:20.838613208 +0200
@@ -5,6 +5,10 @@
ENV{ANACONDA}=="?*", GOTO="md_inc_end"
# assemble md arrays
+# In Fedora we handle the raid components in 65-md-incremental.rules so that
+# we can do things like honor anaconda command line options and such
+GOTO="md_inc_end"
+
SUBSYSTEM!="block", GOTO="md_inc_end"
# handle potential components of arrays (the ones supported by md)
-ENV{ID_FS_TYPE}=="ddf_raid_member|isw_raid_member|linux_raid_member", GOTO="md_inc"
-GOTO="md_inc_end"
+#ENV{ID_FS_TYPE}=="ddf_raid_member|isw_raid_member|linux_raid_member", GOTO="md_inc"
+#GOTO="md_inc_end"
-LABEL="md_inc"
+#LABEL="md_inc"
# remember you can limit what gets auto/incrementally assembled by
# mdadm.conf(5)'s 'AUTO' and selectively whitelist using 'ARRAY'
-ACTION=="add", RUN+="/sbin/mdadm --incremental $devnode --offroot"
-ACTION=="remove", ENV{ID_PATH}=="?*", RUN+="/sbin/mdadm -If $name --path $env{ID_PATH}"
-ACTION=="remove", ENV{ID_PATH}!="?*", RUN+="/sbin/mdadm -If $name"
+#ACTION=="add", RUN+="/sbin/mdadm --incremental $devnode --offroot"
+#ACTION=="remove", ENV{ID_PATH}=="?*", RUN+="/sbin/mdadm -If $name --path $env{ID_PATH}"
+#ACTION=="remove", ENV{ID_PATH}!="?*", RUN+="/sbin/mdadm -If $name"
LABEL="md_inc_end"

View File

@ -1,7 +1,7 @@
Summary: The mdadm program controls Linux md devices (software RAID arrays)
Name: mdadm
Version: 3.3
Release: 8%{?dist}
Version: 3.3.1
Release: 1%{?dist}
Source: http://www.kernel.org/pub/linux/utils/raid/mdadm/mdadm-%{version}.tar.xz
Source1: mdmonitor.init
Source2: raid-check
@ -11,11 +11,6 @@ Source5: mdadm-cron
Source6: mdmonitor.service
Source7: mdadm.conf
Source8: mdadm_event.conf
Patch1: mdadm-3.3-Be-consistent-in-return-types-from-byteswap-macros.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.3-udev.patch
Patch98: mdadm-2.5.2-static.patch
@ -42,7 +37,6 @@ file can be used to help with some common tasks.
%prep
%setup -q
%patch1 -p1 -b .types
# Fedora customization patches
%patch97 -p1 -b .udev
%patch98 -p1 -b .static
@ -99,6 +93,7 @@ rm -rf %{buildroot}
%{_sbindir}/*
%{_unitdir}/*
%{_mandir}/man*/md*
/usr/lib/systemd/system-shutdown/*
%config(noreplace) %{_sysconfdir}/cron.d/*
%config(noreplace) %{_sysconfdir}/sysconfig/*
%dir %{_localstatedir}/run/%{name}/
@ -106,6 +101,11 @@ rm -rf %{buildroot}
/etc/libreport/events.d/*
%changelog
* Tue Jun 10 2014 Jes Sorensen <Jes.Sorensen@redhat.com> - 3.3.1-1
- Update to mdadm-3.3.1
- Fixup mdadm.rules to honor 'change' events
- Resolvez bz1105136
* Sat Jun 07 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 3.3-8
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild

View File

@ -1 +1 @@
abb19b309281b93cf79d29fb2dfb2e85 mdadm-3.3.tar.xz
4227d48de62dfb217c92fa0c54171bbe mdadm-3.3.1.tar.xz