summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin H. Johnson <robbat2@gentoo.org>2015-08-08 13:49:04 -0700
committerRobin H. Johnson <robbat2@gentoo.org>2015-08-08 17:38:18 -0700
commit56bd759df1d0c750a065b8c845e93d5dfa6b549d (patch)
tree3f91093cdb475e565ae857f1c5a7fd339e2d781e /sys-fs/mdadm/files
downloadgentoo-56bd759df1d0c750a065b8c845e93d5dfa6b549d.tar.gz
gentoo-56bd759df1d0c750a065b8c845e93d5dfa6b549d.tar.bz2
gentoo-56bd759df1d0c750a065b8c845e93d5dfa6b549d.zip
proj/gentoo: Initial commit
This commit represents a new era for Gentoo: Storing the gentoo-x86 tree in Git, as converted from CVS. This commit is the start of the NEW history. Any historical data is intended to be grafted onto this point. Creation process: 1. Take final CVS checkout snapshot 2. Remove ALL ChangeLog* files 3. Transform all Manifests to thin 4. Remove empty Manifests 5. Convert all stale $Header$/$Id$ CVS keywords to non-expanded Git $Id$ 5.1. Do not touch files with -kb/-ko keyword flags. Signed-off-by: Robin H. Johnson <robbat2@gentoo.org> X-Thanks: Alec Warner <antarus@gentoo.org> - did the GSoC 2006 migration tests X-Thanks: Robin H. Johnson <robbat2@gentoo.org> - infra guy, herding this project X-Thanks: Nguyen Thai Ngoc Duy <pclouds@gentoo.org> - Former Gentoo developer, wrote Git features for the migration X-Thanks: Brian Harring <ferringb@gentoo.org> - wrote much python to improve cvs2svn X-Thanks: Rich Freeman <rich0@gentoo.org> - validation scripts X-Thanks: Patrick Lauer <patrick@gentoo.org> - Gentoo dev, running new 2014 work in migration X-Thanks: Michał Górny <mgorny@gentoo.org> - scripts, QA, nagging X-Thanks: All of other Gentoo developers - many ideas and lots of paint on the bikeshed
Diffstat (limited to 'sys-fs/mdadm/files')
-rw-r--r--sys-fs/mdadm/files/etc-default-mdadm7
-rw-r--r--sys-fs/mdadm/files/mdadm-3.2.1-mdassemble.patch16
-rw-r--r--sys-fs/mdadm/files/mdadm-3.2.x-udevdir.patch26
-rw-r--r--sys-fs/mdadm/files/mdadm-3.3.1-DDF-validate-metadata_update-size-before-using-it.patch44
-rw-r--r--sys-fs/mdadm/files/mdadm-3.3.1-Grow-Do-not-try-to-restart-if-reshape-is-running.patch45
-rw-r--r--sys-fs/mdadm/files/mdadm-3.3.1-Grow-fix-removal-of-line-in-wrong-case.patch39
-rw-r--r--sys-fs/mdadm/files/mdadm-3.3.1-IMSM-use-strcpy-rather-than-pointless-strncpy.patch32
-rw-r--r--sys-fs/mdadm/files/mdadm-3.3.1-IMSM-validate-metadata_update-size-before-using-it.patch128
-rw-r--r--sys-fs/mdadm/files/mdadm-3.3.1-Makefile-install-mdadm-grow-continue-.service.patch28
-rw-r--r--sys-fs/mdadm/files/mdadm-3.3.1-mdmon-allow-prepare_update-to-report-failure.patch119
-rw-r--r--sys-fs/mdadm/files/mdadm-3.3.1-mdmon-ensure-Unix-domain-socket-is-created-with-safe.patch34
-rw-r--r--sys-fs/mdadm/files/mdadm.confd7
-rwxr-xr-xsys-fs/mdadm/files/mdadm.rc26
-rw-r--r--sys-fs/mdadm/files/mdadm.service13
-rw-r--r--sys-fs/mdadm/files/mdadm.tmpfiles.conf1
-rw-r--r--sys-fs/mdadm/files/mdadm.weekly5
-rw-r--r--sys-fs/mdadm/files/mdraid.confd11
-rw-r--r--sys-fs/mdadm/files/mdraid.rc40
18 files changed, 621 insertions, 0 deletions
diff --git a/sys-fs/mdadm/files/etc-default-mdadm b/sys-fs/mdadm/files/etc-default-mdadm
new file mode 100644
index 000000000000..70ff20b8e385
--- /dev/null
+++ b/sys-fs/mdadm/files/etc-default-mdadm
@@ -0,0 +1,7 @@
+# Based on Debian /etc/default/mdadm
+
+# Gentoo comment: The cronjob checks for this value to decide to actually validate arrays. If missing, it does NOT actually do anything.
+# AUTOCHECK:
+# should mdadm run periodic redundancy checks over your arrays? See
+# /etc/cron.d/mdadm.
+AUTOCHECK=true
diff --git a/sys-fs/mdadm/files/mdadm-3.2.1-mdassemble.patch b/sys-fs/mdadm/files/mdadm-3.2.1-mdassemble.patch
new file mode 100644
index 000000000000..6e12dc2534a0
--- /dev/null
+++ b/sys-fs/mdadm/files/mdadm-3.2.1-mdassemble.patch
@@ -0,0 +1,16 @@
+http://bugs.gentoo.org/211426
+
+make default mdassemble sane
+
+--- a/Makefile
++++ b/Makefile
+@@ -181,8 +181,7 @@
+ $(CC) $(CXFLAGS) $(LDFLAGS) -o raid6check raid6check.o $(CHECK_OBJS)
+
+ mdassemble : $(ASSEMBLE_SRCS) $(INCL)
+- rm -f $(OBJS)
+- $(DIET_GCC) $(ASSEMBLE_FLAGS) -o mdassemble $(ASSEMBLE_SRCS) $(STATICSRC)
++ $(CC) $(CFLAGS) $(LDFLAGS) $(ASSEMBLE_FLAGS) -DHAVE_STDINT_H -o mdassemble $(ASSEMBLE_SRCS) $(STATICSRC)
+
+ mdassemble.static : $(ASSEMBLE_SRCS) $(INCL)
+ rm -f $(OBJS)
diff --git a/sys-fs/mdadm/files/mdadm-3.2.x-udevdir.patch b/sys-fs/mdadm/files/mdadm-3.2.x-udevdir.patch
new file mode 100644
index 000000000000..8bfdcd5261ab
--- /dev/null
+++ b/sys-fs/mdadm/files/mdadm-3.2.x-udevdir.patch
@@ -0,0 +1,26 @@
+http://bugs.gentoo.org/430900
+
+--- Makefile
++++ Makefile
+@@ -97,6 +97,12 @@
+ MAN4DIR = $(MANDIR)/man4
+ MAN5DIR = $(MANDIR)/man5
+ MAN8DIR = $(MANDIR)/man8
++PKG_CONFIG ?= pkg-config
++
++UDEVDIR := $(shell $(PKG_CONFIG) --variable=udevdir udev 2>/dev/null)
++ifndef UDEVDIR
++ UDEVDIR = lib/udev
++endif
+
+ OBJS = mdadm.o config.o policy.o mdstat.o ReadMe.o util.o maps.o lib.o \
+ Manage.o Assemble.o Build.o \
+@@ -254,7 +260,7 @@
+ $(INSTALL) -D -m 644 mdadm.conf.5 $(DESTDIR)$(MAN5DIR)/mdadm.conf.5
+
+ install-udev: udev-md-raid.rules
+- $(INSTALL) -D -m 644 udev-md-raid.rules $(DESTDIR)/lib/udev/rules.d/64-md-raid.rules
++ $(INSTALL) -D -m 644 udev-md-raid.rules $(DESTDIR)/$(UDEVDIR)/rules.d/64-md-raid.rules
+
+ 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/sys-fs/mdadm/files/mdadm-3.3.1-DDF-validate-metadata_update-size-before-using-it.patch b/sys-fs/mdadm/files/mdadm-3.3.1-DDF-validate-metadata_update-size-before-using-it.patch
new file mode 100644
index 000000000000..befb7da91735
--- /dev/null
+++ b/sys-fs/mdadm/files/mdadm-3.3.1-DDF-validate-metadata_update-size-before-using-it.patch
@@ -0,0 +1,44 @@
+From 1f17f96b538793a0e665e471f602c6fa490ec167 Mon Sep 17 00:00:00 2001
+From: NeilBrown <neilb@suse.de>
+Date: Thu, 10 Jul 2014 15:59:06 +1000
+Subject: [PATCH 12/14] DDF: validate metadata_update size before using it.
+
+process_update already checks update->len, for all but
+the 'magic', prepare_update doesn't at all.
+
+So add tests to prepare_update that we don't exceed the buffer.
+This will consequently protect process_update from looking
+for a 'magic' which isn't there.
+
+Reported-by: Vincent Berg <vberg@ioactive.com>
+Signed-off-by: NeilBrown <neilb@suse.de>
+---
+ super-ddf.c | 10 ++++++++--
+ 1 file changed, 8 insertions(+), 2 deletions(-)
+
+diff --git a/super-ddf.c b/super-ddf.c
+index 1e43ca2..8957c2e 100644
+--- a/super-ddf.c
++++ b/super-ddf.c
+@@ -4914,10 +4914,16 @@ static int ddf_prepare_update(struct supertype *st,
+ * If a malloc is needed, do it here.
+ */
+ struct ddf_super *ddf = st->sb;
+- be32 *magic = (be32 *)update->buf;
++ be32 *magic;
++ if (update->len < 4)
++ return 0;
++ magic = (be32 *)update->buf;
+ if (be32_eq(*magic, DDF_VD_CONF_MAGIC)) {
+ struct vcl *vcl;
+- struct vd_config *conf = (struct vd_config *) update->buf;
++ struct vd_config *conf;
++ if (update->len < (int)sizeof(*conf))
++ return 0;
++ conf = (struct vd_config *) update->buf;
+ if (posix_memalign(&update->space, 512,
+ offsetof(struct vcl, conf)
+ + ddf->conf_rec_len * 512) != 0) {
+--
+2.0.0
+
diff --git a/sys-fs/mdadm/files/mdadm-3.3.1-Grow-Do-not-try-to-restart-if-reshape-is-running.patch b/sys-fs/mdadm/files/mdadm-3.3.1-Grow-Do-not-try-to-restart-if-reshape-is-running.patch
new file mode 100644
index 000000000000..717317b8a2d0
--- /dev/null
+++ b/sys-fs/mdadm/files/mdadm-3.3.1-Grow-Do-not-try-to-restart-if-reshape-is-running.patch
@@ -0,0 +1,45 @@
+From 13ffbe89b6103c146c08eb1c9a70833306c8322b Mon Sep 17 00:00:00 2001
+From: Pawel Baldysiak <pawel.baldysiak@intel.com>
+Date: Wed, 16 Jul 2014 12:20:34 +0200
+Subject: [PATCH 14/14] Grow: Do not try to restart if reshape is running
+
+Grow process did not check if reshape is already started
+when deciding about restarting.
+Sync_action should be checked in this case, and if
+reshape is running - restart flag should not be set.
+Otherwise, Grow process will fail to write data to
+sysfs, and reshape will not be continued.
+
+Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com>
+Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
+Signed-off-by: NeilBrown <neilb@suse.de>
+---
+ Grow.c | 5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+diff --git a/Grow.c b/Grow.c
+index a2f4f14..ea9cc60 100644
+--- a/Grow.c
++++ b/Grow.c
+@@ -2822,6 +2822,7 @@ static int reshape_array(char *container, int fd, char *devname,
+ unsigned long long array_size;
+ int done;
+ struct mdinfo *sra = NULL;
++ char buf[20];
+
+ /* when reshaping a RAID0, the component_size might be zero.
+ * So try to fix that up.
+@@ -2869,7 +2870,9 @@ static int reshape_array(char *container, int fd, char *devname,
+ goto release;
+ }
+
+- if (st->ss->external && restart && (info->reshape_progress == 0)) {
++ if (st->ss->external && restart && (info->reshape_progress == 0) &&
++ !((sysfs_get_str(info, NULL, "sync_action", buf, sizeof(buf)) > 0) &&
++ (strncmp(buf, "reshape", 7) == 0))) {
+ /* When reshape is restarted from '0', very begin of array
+ * it is possible that for external metadata reshape and array
+ * configuration doesn't happen.
+--
+2.0.0
+
diff --git a/sys-fs/mdadm/files/mdadm-3.3.1-Grow-fix-removal-of-line-in-wrong-case.patch b/sys-fs/mdadm/files/mdadm-3.3.1-Grow-fix-removal-of-line-in-wrong-case.patch
new file mode 100644
index 000000000000..acc38267d160
--- /dev/null
+++ b/sys-fs/mdadm/files/mdadm-3.3.1-Grow-fix-removal-of-line-in-wrong-case.patch
@@ -0,0 +1,39 @@
+From e339dba2a1744dc6860a58e286ded39fc993c2db Mon Sep 17 00:00:00 2001
+From: Pawel Baldysiak <pawel.baldysiak@intel.com>
+Date: Wed, 11 Jun 2014 15:18:44 +0000
+Subject: [PATCH 02/14] Grow: fix removal of line in wrong case
+
+Commit 18d9bcfa33939cee345d4d7735bc6081bcc409c8
+removed wrong line (in case RAID0->RAID4).
+This patch corrects this mistake
+(line should be removed in case RAID4->RAID4).
+
+Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com>
+Signed-off-by: NeilBrown <neilb@suse.de>
+---
+ Grow.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/Grow.c b/Grow.c
+index 12730e2..a2f4f14 100644
+--- a/Grow.c
++++ b/Grow.c
+@@ -1324,6 +1324,7 @@ char *analyse_change(char *devname, struct mdinfo *info, struct reshape *re)
+
+ switch (re->level) {
+ case 4:
++ re->before.layout = 0;
+ re->after.layout = 0;
+ break;
+ case 5:
+@@ -1339,7 +1340,6 @@ char *analyse_change(char *devname, struct mdinfo *info, struct reshape *re)
+
+ switch (re->level) {
+ case 4:
+- re->before.layout = 0;
+ re->after.layout = 0;
+ break;
+ case 5:
+--
+2.0.0
+
diff --git a/sys-fs/mdadm/files/mdadm-3.3.1-IMSM-use-strcpy-rather-than-pointless-strncpy.patch b/sys-fs/mdadm/files/mdadm-3.3.1-IMSM-use-strcpy-rather-than-pointless-strncpy.patch
new file mode 100644
index 000000000000..b63b1e732d36
--- /dev/null
+++ b/sys-fs/mdadm/files/mdadm-3.3.1-IMSM-use-strcpy-rather-than-pointless-strncpy.patch
@@ -0,0 +1,32 @@
+From 6d8d290a2f09a3bfd9e44f382ae5daea128772f7 Mon Sep 17 00:00:00 2001
+From: NeilBrown <neilb@suse.de>
+Date: Thu, 3 Jul 2014 15:04:01 +1000
+Subject: [PATCH 03/14] IMSM: use strcpy rather than pointless strncpy.
+
+As strncpy doesn't guarantee to nul-terminate, some static
+analysers get upset that it is followed by a 'strncat'.
+So just use a 'strcpy' - strlen(disk_by_path) is constant
+and definitely less than PATH_MAX.
+
+Link: https://github.com/neilbrown/mdadm/issues/4
+Signed-off-by: NeilBrown <neilb@suse.de>
+---
+ super-intel.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/super-intel.c b/super-intel.c
+index 9dd807a..0106b4f 100644
+--- a/super-intel.c
++++ b/super-intel.c
+@@ -9357,7 +9357,7 @@ static const char *imsm_get_disk_controller_domain(const char *path)
+ char *drv=NULL;
+ struct stat st;
+
+- strncpy(disk_path, disk_by_path, PATH_MAX - 1);
++ strcpy(disk_path, disk_by_path);
+ strncat(disk_path, path, PATH_MAX - strlen(disk_path) - 1);
+ if (stat(disk_path, &st) == 0) {
+ struct sys_dev* hba;
+--
+2.0.0
+
diff --git a/sys-fs/mdadm/files/mdadm-3.3.1-IMSM-validate-metadata_update-size-before-using-it.patch b/sys-fs/mdadm/files/mdadm-3.3.1-IMSM-validate-metadata_update-size-before-using-it.patch
new file mode 100644
index 000000000000..b1610835753a
--- /dev/null
+++ b/sys-fs/mdadm/files/mdadm-3.3.1-IMSM-validate-metadata_update-size-before-using-it.patch
@@ -0,0 +1,128 @@
+From 095b8088fa99ad1195d1aba03af2aa561b4a6379 Mon Sep 17 00:00:00 2001
+From: NeilBrown <neilb@suse.de>
+Date: Thu, 10 Jul 2014 16:09:28 +1000
+Subject: [PATCH 13/14] IMSM: validate metadata_update size before using it.
+
+Every case in prepare_update check that the size message
+size is sufficient, so process_update doesn't need to check anything.
+
+Reported-by: Vincent Berg <vberg@ioactive.com>
+Signed-off-by: NeilBrown <neilb@suse.de>
+---
+ super-intel.c | 44 +++++++++++++++++++++++++++++++++++++++++---
+ 1 file changed, 41 insertions(+), 3 deletions(-)
+
+diff --git a/super-intel.c b/super-intel.c
+index 2547b4a..b4efa72 100644
+--- a/super-intel.c
++++ b/super-intel.c
+@@ -8587,7 +8587,7 @@ static void imsm_process_update(struct supertype *st,
+ }
+ case update_add_remove_disk: {
+ /* we may be able to repair some arrays if disks are
+- * being added, check teh status of add_remove_disk
++ * being added, check the status of add_remove_disk
+ * if discs has been added.
+ */
+ if (add_remove_disk_update(super)) {
+@@ -8617,19 +8617,28 @@ static int imsm_prepare_update(struct supertype *st,
+ * integrated by the monitor thread without worrying about live pointers
+ * in the manager thread.
+ */
+- enum imsm_update_type type = *(enum imsm_update_type *) update->buf;
++ enum imsm_update_type type;
+ struct intel_super *super = st->sb;
+ struct imsm_super *mpb = super->anchor;
+ size_t buf_len;
+ size_t len = 0;
+
++ if (update->len < (int)sizeof(type))
++ return 0;
++
++ type = *(enum imsm_update_type *) update->buf;
++
+ switch (type) {
+ case update_general_migration_checkpoint:
++ if (update->len < (int)sizeof(struct imsm_update_general_migration_checkpoint))
++ return 0;
+ dprintf("imsm: prepare_update() "
+ "for update_general_migration_checkpoint called\n");
+ break;
+ case update_takeover: {
+ struct imsm_update_takeover *u = (void *)update->buf;
++ if (update->len < (int)sizeof(*u))
++ return 0;
+ if (u->direction == R0_TO_R10) {
+ void **tail = (void **)&update->space_list;
+ struct imsm_dev *dev = get_imsm_dev(super, u->subarray);
+@@ -8670,6 +8679,9 @@ static int imsm_prepare_update(struct supertype *st,
+ struct intel_dev *dl;
+ void **space_tail = (void**)&update->space_list;
+
++ if (update->len < (int)sizeof(*u))
++ return 0;
++
+ dprintf("imsm: imsm_prepare_update() for update_reshape\n");
+
+ for (dl = super->devlist; dl; dl = dl->next) {
+@@ -8702,6 +8714,9 @@ static int imsm_prepare_update(struct supertype *st,
+ void *s;
+ int current_level = -1;
+
++ if (update->len < (int)sizeof(*u))
++ return 0;
++
+ dprintf("imsm: imsm_prepare_update() for update_reshape\n");
+
+ /* add space for bigger array in update
+@@ -8769,6 +8784,13 @@ static int imsm_prepare_update(struct supertype *st,
+ break;
+ }
+ case update_size_change: {
++ if (update->len < (int)sizeof(struct imsm_update_size_change))
++ return 0;
++ break;
++ }
++ case update_activate_spare: {
++ if (update->len < (int)sizeof(struct imsm_update_activate_spare))
++ return 0;
+ break;
+ }
+ case update_create_array: {
+@@ -8781,6 +8803,9 @@ static int imsm_prepare_update(struct supertype *st,
+ int i;
+ int activate = 0;
+
++ if (update->len < (int)sizeof(*u))
++ return 0;
++
+ inf = get_disk_info(u);
+ len = sizeof_imsm_dev(dev, 1);
+ /* allocate a new super->devlist entry */
+@@ -8802,9 +8827,22 @@ static int imsm_prepare_update(struct supertype *st,
+ }
+ len += activate * sizeof(struct imsm_disk);
+ break;
+- default:
++ }
++ case update_kill_array: {
++ if (update->len < (int)sizeof(struct imsm_update_kill_array))
++ return 0;
+ break;
+ }
++ case update_rename_array: {
++ if (update->len < (int)sizeof(struct imsm_update_rename_array))
++ return 0;
++ break;
++ }
++ case update_add_remove_disk:
++ /* no update->len needed */
++ break;
++ default:
++ return 0;
+ }
+
+ /* check if we need a larger metadata buffer */
+--
+2.0.0
+
diff --git a/sys-fs/mdadm/files/mdadm-3.3.1-Makefile-install-mdadm-grow-continue-.service.patch b/sys-fs/mdadm/files/mdadm-3.3.1-Makefile-install-mdadm-grow-continue-.service.patch
new file mode 100644
index 000000000000..431bfd1abe3b
--- /dev/null
+++ b/sys-fs/mdadm/files/mdadm-3.3.1-Makefile-install-mdadm-grow-continue-.service.patch
@@ -0,0 +1,28 @@
+From 616f197f9d6d044afb9e27ddc9cd087d21d610f0 Mon Sep 17 00:00:00 2001
+From: NeilBrown <neilb@suse.de>
+Date: Tue, 10 Jun 2014 20:34:40 +1000
+Subject: [PATCH 01/14] Makefile: install mdadm-grow-continue@.service
+
+Forgot to add this to install-systemd target
+
+Signed-off-by: NeilBrown <neilb@suse.de>
+---
+ Makefile | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/Makefile b/Makefile
+index c7e7a42..1a4a5dc 100644
+--- a/Makefile
++++ b/Makefile
+@@ -290,7 +290,7 @@ install-udev: udev-md-raid-arrays.rules udev-md-raid-assembly.rules
+
+ install-systemd: systemd/mdmon@.service
+ @for file in mdmon@.service mdmonitor.service mdadm-last-resort@.timer \
+- mdadm-last-resort@.service ; \
++ mdadm-last-resort@.service mdadm-grow-continue@.service; \
+ do sed -e 's,BINDIR,$(BINDIR),g' systemd/$$file > .install.tmp && \
+ echo $(INSTALL) -D -m 644 systemd/$$file $(DESTDIR)$(SYSTEMD_DIR)/$$file ; \
+ $(INSTALL) -D -m 644 .install.tmp $(DESTDIR)$(SYSTEMD_DIR)/$$file ; \
+--
+2.0.0
+
diff --git a/sys-fs/mdadm/files/mdadm-3.3.1-mdmon-allow-prepare_update-to-report-failure.patch b/sys-fs/mdadm/files/mdadm-3.3.1-mdmon-allow-prepare_update-to-report-failure.patch
new file mode 100644
index 000000000000..772248b19c3d
--- /dev/null
+++ b/sys-fs/mdadm/files/mdadm-3.3.1-mdmon-allow-prepare_update-to-report-failure.patch
@@ -0,0 +1,119 @@
+From 5fe6f031d9a21a935f0ef1b1fbdb314b53f2199f Mon Sep 17 00:00:00 2001
+From: NeilBrown <neilb@suse.de>
+Date: Thu, 10 Jul 2014 15:54:02 +1000
+Subject: [PATCH 11/14] mdmon: allow prepare_update to report failure.
+
+If 'prepare_update' fails for some reason there is little
+point continuing on to 'process_update'.
+For now only malloc failures are caught, but other failures
+will be considered in future.
+
+Signed-off-by: NeilBrown <neilb@suse.de>
+---
+ managemon.c | 3 ++-
+ mdadm.h | 5 ++++-
+ super-ddf.c | 8 +++++---
+ super-intel.c | 9 +++++----
+ 4 files changed, 16 insertions(+), 9 deletions(-)
+
+diff --git a/managemon.c b/managemon.c
+index 5f7e2ce..1c9eccc 100644
+--- a/managemon.c
++++ b/managemon.c
+@@ -819,7 +819,8 @@ static void handle_message(struct supertype *container, struct metadata_update *
+ mu->space_list = NULL;
+ mu->next = NULL;
+ if (container->ss->prepare_update)
+- container->ss->prepare_update(container, mu);
++ if (!container->ss->prepare_update(container, mu))
++ free_updates(&mu);
+ queue_metadata_update(mu);
+ }
+ }
+diff --git a/mdadm.h b/mdadm.h
+index 914d67c..02a9288 100644
+--- a/mdadm.h
++++ b/mdadm.h
+@@ -929,7 +929,10 @@ extern struct superswitch {
+ void (*sync_metadata)(struct supertype *st);
+ void (*process_update)(struct supertype *st,
+ struct metadata_update *update);
+- void (*prepare_update)(struct supertype *st,
++ /* Prepare updates allocates extra memory that might be
++ * needed. If the update cannot be understood, return 0.
++ */
++ int (*prepare_update)(struct supertype *st,
+ struct metadata_update *update);
+
+ /* activate_spare will check if the array is degraded and, if it
+diff --git a/super-ddf.c b/super-ddf.c
+index ab9fc46..1e43ca2 100644
+--- a/super-ddf.c
++++ b/super-ddf.c
+@@ -4906,8 +4906,8 @@ static void ddf_process_update(struct supertype *st,
+ /* case DDF_SPARE_ASSIGN_MAGIC */
+ }
+
+-static void ddf_prepare_update(struct supertype *st,
+- struct metadata_update *update)
++static int ddf_prepare_update(struct supertype *st,
++ struct metadata_update *update)
+ {
+ /* This update arrived at managemon.
+ * We are about to pass it to monitor.
+@@ -4922,15 +4922,17 @@ static void ddf_prepare_update(struct supertype *st,
+ offsetof(struct vcl, conf)
+ + ddf->conf_rec_len * 512) != 0) {
+ update->space = NULL;
+- return;
++ return 0;
+ }
+ vcl = update->space;
+ vcl->conf.sec_elmnt_count = conf->sec_elmnt_count;
+ if (alloc_other_bvds(ddf, vcl) != 0) {
+ free(update->space);
+ update->space = NULL;
++ return 0;
+ }
+ }
++ return 1;
+ }
+
+ /*
+diff --git a/super-intel.c b/super-intel.c
+index 7734bde..2547b4a 100644
+--- a/super-intel.c
++++ b/super-intel.c
+@@ -8607,8 +8607,8 @@ static void imsm_process_update(struct supertype *st,
+
+ static struct mdinfo *get_spares_for_grow(struct supertype *st);
+
+-static void imsm_prepare_update(struct supertype *st,
+- struct metadata_update *update)
++static int imsm_prepare_update(struct supertype *st,
++ struct metadata_update *update)
+ {
+ /**
+ * Allocate space to hold new disk entries, raid-device entries or a new
+@@ -8828,6 +8828,7 @@ static void imsm_prepare_update(struct supertype *st,
+ else
+ super->next_buf = NULL;
+ }
++ return 1;
+ }
+
+ /* must be called while manager is quiesced */
+@@ -9716,8 +9717,8 @@ static void imsm_update_metadata_locally(struct supertype *st,
+ mu.space = NULL;
+ mu.space_list = NULL;
+ mu.next = NULL;
+- imsm_prepare_update(st, &mu);
+- imsm_process_update(st, &mu);
++ if (imsm_prepare_update(st, &mu))
++ imsm_process_update(st, &mu);
+
+ while (mu.space_list) {
+ void **space = mu.space_list;
+--
+2.0.0
+
diff --git a/sys-fs/mdadm/files/mdadm-3.3.1-mdmon-ensure-Unix-domain-socket-is-created-with-safe.patch b/sys-fs/mdadm/files/mdadm-3.3.1-mdmon-ensure-Unix-domain-socket-is-created-with-safe.patch
new file mode 100644
index 000000000000..9780196e28cd
--- /dev/null
+++ b/sys-fs/mdadm/files/mdadm-3.3.1-mdmon-ensure-Unix-domain-socket-is-created-with-safe.patch
@@ -0,0 +1,34 @@
+From 120ec6f7b96455e42bdfa9131c0c9026c57eaf19 Mon Sep 17 00:00:00 2001
+From: NeilBrown <neilb@suse.de>
+Date: Thu, 3 Jul 2014 17:06:45 +1000
+Subject: [PATCH 09/14] mdmon: ensure Unix domain socket is created with safe
+ permissions.
+
+In the unlikely case that mdmon is started with an overly
+permissive umask, we don't want to risk giving away world acccess.
+
+All other "mkdir" and "O_CREAT" calls in mdmon and mdadm set
+a suitably restrictive permission mask. 'bind' don't take an
+explicit mask so it needs an implicit one.
+
+Reported-by: Vincent Berg <vberg@ioactive.com>
+Signed-off-by: NeilBrown <neilb@suse.de>
+---
+ mdmon.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/mdmon.c b/mdmon.c
+index b84d4d9..21221cd 100644
+--- a/mdmon.c
++++ b/mdmon.c
+@@ -232,6 +232,7 @@ static int make_control_sock(char *devname)
+
+ addr.sun_family = PF_LOCAL;
+ strcpy(addr.sun_path, path);
++ umask(077); /* ensure no world write access */
+ if (bind(sfd, &addr, sizeof(addr)) < 0) {
+ close(sfd);
+ return -1;
+--
+2.0.0
+
diff --git a/sys-fs/mdadm/files/mdadm.confd b/sys-fs/mdadm/files/mdadm.confd
new file mode 100644
index 000000000000..a4ead14dc34e
--- /dev/null
+++ b/sys-fs/mdadm/files/mdadm.confd
@@ -0,0 +1,7 @@
+# /etc/conf.d/mdadm: config file for /etc/init.d/mdadm
+
+# Misc options to pass to mdadm in monitor mode.
+# For more info, run `mdadm --monitor --help` or see
+# the mdadm(8) manpage.
+
+MDADM_OPTS="--syslog"
diff --git a/sys-fs/mdadm/files/mdadm.rc b/sys-fs/mdadm/files/mdadm.rc
new file mode 100755
index 000000000000..f4858c33f435
--- /dev/null
+++ b/sys-fs/mdadm/files/mdadm.rc
@@ -0,0 +1,26 @@
+#!/sbin/runscript
+# Copyright 1999-2006 Gentoo Technologies, Inc.
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+depend() {
+ use logger dns net
+}
+
+start() {
+ ebegin "Starting mdadm monitor"
+ mdadm --monitor --scan \
+ --daemonise \
+ --pid-file /var/run/mdadm.pid \
+ ${MDADM_OPTS}
+ eend $?
+}
+
+stop() {
+ local ret
+ ebegin "Stopping mdadm monitor"
+ start-stop-daemon --stop --pidfile /var/run/mdadm.pid
+ ret=$?
+ rm -f /var/run/mdadm.pid
+ eend ${ret}
+}
diff --git a/sys-fs/mdadm/files/mdadm.service b/sys-fs/mdadm/files/mdadm.service
new file mode 100644
index 000000000000..342177d4f06a
--- /dev/null
+++ b/sys-fs/mdadm/files/mdadm.service
@@ -0,0 +1,13 @@
+[Unit]
+Description=Software RAID monitoring and management
+ConditionPathExists=/etc/mdadm.conf
+
+[Service]
+Type=forking
+PIDFile=/run/mdadm/mdadm.pid
+EnvironmentFile=/etc/conf.d/mdadm
+ExecStart=/sbin/mdadm --monitor --scan -f --pid-file=/run/mdadm/mdadm.pid $MDADM_OPTS
+
+[Install]
+WantedBy=multi-user.target
+
diff --git a/sys-fs/mdadm/files/mdadm.tmpfiles.conf b/sys-fs/mdadm/files/mdadm.tmpfiles.conf
new file mode 100644
index 000000000000..3207ddae0e43
--- /dev/null
+++ b/sys-fs/mdadm/files/mdadm.tmpfiles.conf
@@ -0,0 +1 @@
+d /run/mdadm 0710 root root -
diff --git a/sys-fs/mdadm/files/mdadm.weekly b/sys-fs/mdadm/files/mdadm.weekly
new file mode 100644
index 000000000000..e2b35b550fce
--- /dev/null
+++ b/sys-fs/mdadm/files/mdadm.weekly
@@ -0,0 +1,5 @@
+#!/bin/sh
+# This requires that AUTOCHECK is true in /etc/default/mdadm
+if [ -x /usr/sbin/checkarray ] && [ $(date +\%d) -le 7 ]; then
+ /usr/sbin/checkarray --cron --all --idle --quiet
+fi
diff --git a/sys-fs/mdadm/files/mdraid.confd b/sys-fs/mdadm/files/mdraid.confd
new file mode 100644
index 000000000000..5694d732d006
--- /dev/null
+++ b/sys-fs/mdadm/files/mdraid.confd
@@ -0,0 +1,11 @@
+# /etc/conf.d/mdraid: config file for /etc/init.d/mdraid
+
+# For people who run raid on top of some other layer (like
+# dmcrypt), use rc_need to specify that requirement. See
+# the runscript(8) man page for more information.
+
+# Most configuration happens in /etc/mdadm.conf.
+
+# Pass additional options when assembling raids.
+# Note: This applies to all raids.
+MDADM_ASSEMBLE_OPTS=""
diff --git a/sys-fs/mdadm/files/mdraid.rc b/sys-fs/mdadm/files/mdraid.rc
new file mode 100644
index 000000000000..b46b79f73770
--- /dev/null
+++ b/sys-fs/mdadm/files/mdraid.rc
@@ -0,0 +1,40 @@
+#!/sbin/runscript
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+depend() {
+ before checkfs fsck
+ after modules
+}
+
+start() {
+ local output
+
+ ebegin "Starting up RAID devices"
+ output=$(mdadm -As ${MDADM_ASSEMBLE_OPTS} 2>&1)
+ eend $? "${output}"
+
+ local pat="/dev/md_d*"
+ set -- ${pat}
+ if [ "$*" != "${pat}" ] ; then
+ ebegin "Creating RAID device partitions"
+ blockdev "$@"
+ eend $?
+ # wait because vgscan runs next, and we want udev to fire
+ sleep 1
+ fi
+
+ return 0
+}
+
+stop() {
+ local output
+
+ # XXX: Maybe drop this check ?
+ [ ! -e /etc/mdadm/mdadm.conf ] && [ ! -e /etc/mdadm.conf ] && return 0
+
+ ebegin "Shutting down RAID devices (mdadm)"
+ output=$(mdadm -Ss 2>&1)
+ eend $? "${output}"
+}