[mdadm/f15: 7/8] Fix problem with IMSM raid not being started correctly during boot

Jes Sorensen jsorensen at fedoraproject.org
Wed Oct 19 15:08:17 UTC 2011


commit 6c5cfe0908976dec153f11df42e864ebd67526e1
Author: Jes Sorensen <Jes.Sorensen at redhat.com>
Date:   Wed Oct 19 13:53:41 2011 +0200

    Fix problem with IMSM raid not being started correctly during boot
    
    Signed-off-by: Jes Sorensen <Jes.Sorensen at redhat.com>

 ...emove-race-for-starting-container-devices.patch |   79 ++++++++++++++++++++
 mdadm-3.2.2-hold-lock-during-assemble.patch        |   45 +++++++++++
 mdadm-3.2.2-no-sysfs-launch-container.patch        |   26 +++++++
 ...3.2.2-resync-does-not-continue-after-auto.patch |   56 ++++++++++++++
 mdadm.spec                                         |   18 ++++-
 5 files changed, 223 insertions(+), 1 deletions(-)
---
diff --git a/mdadm-3.2.2-Remove-race-for-starting-container-devices.patch b/mdadm-3.2.2-Remove-race-for-starting-container-devices.patch
new file mode 100644
index 0000000..9a767b0
--- /dev/null
+++ b/mdadm-3.2.2-Remove-race-for-starting-container-devices.patch
@@ -0,0 +1,79 @@
+From 50177a4bbed446087dd2529b5518697f2f69de08 Mon Sep 17 00:00:00 2001
+From: Jes Sorensen <Jes.Sorensen at redhat.com>
+Date: Thu, 13 Oct 2011 19:35:07 +0200
+Subject: [PATCH 1/3] Remove race for starting container devices.
+
+This moves the lock handling out of Incremental_container() and relies
+on the caller holding the lock. This prevents conflict with a
+follow-on mdadm comment which may try and launch the device in
+parallel.
+
+Signed-off-by: Jes Sorensen <Jes.Sorensen at redhat.com>
+---
+ Incremental.c |   22 ++++++++++++----------
+ 1 files changed, 12 insertions(+), 10 deletions(-)
+
+diff --git a/Incremental.c b/Incremental.c
+index 14184da..9fa6800 100644
+--- a/Incremental.c
++++ b/Incremental.c
+@@ -138,9 +138,15 @@ int Incremental(char *devname, int verbose, int runstop,
+ 			rv = st->ss->load_container(st, dfd, NULL);
+ 
+ 		close(dfd);
+-		if (!rv && st->ss->container_content)
+-			return Incremental_container(st, devname, homehost,
+-						     verbose, runstop, autof);
++		if (!rv && st->ss->container_content) {
++			if (map_lock(&map))
++				fprintf(stderr, Name ": failed to get "
++					"exclusive lock on mapfile\n");
++			rv = Incremental_container(st, devname, homehost,
++						   verbose, runstop, autof);
++			map_unlock(&map);
++			return rv;
++		}
+ 
+ 		fprintf(stderr, Name ": %s is not part of an md array.\n",
+ 			devname);
+@@ -440,7 +446,6 @@ int Incremental(char *devname, int verbose, int runstop,
+ 	if (info.array.level == LEVEL_CONTAINER) {
+ 		int devnum = devnum; /* defined and used iff ->external */
+ 		/* Try to assemble within the container */
+-		map_unlock(&map);
+ 		sysfs_uevent(&info, "change");
+ 		if (verbose >= 0)
+ 			fprintf(stderr, Name
+@@ -451,8 +456,9 @@ int Incremental(char *devname, int verbose, int runstop,
+ 			devnum = fd2devnum(mdfd);
+ 		close(mdfd);
+ 		sysfs_free(sra);
+-		rv = Incremental(chosen_name, verbose, runstop,
+-				 NULL, homehost, require_homehost, autof);
++		rv = Incremental_container(st, chosen_name, homehost,
++					   verbose, runstop, autof);
++		map_unlock(&map);
+ 		if (rv == 1)
+ 			/* Don't fail the whole -I if a subarray didn't
+ 			 * have enough devices to start yet
+@@ -1462,9 +1468,6 @@ static int Incremental_container(struct supertype *st, char *devname,
+ 		trustworthy = FOREIGN;
+ 
+ 	list = st->ss->container_content(st, NULL);
+-	if (map_lock(&map))
+-		fprintf(stderr, Name ": failed to get exclusive lock on "
+-			"mapfile\n");
+ 	/* do not assemble arrays that might have bad blocks */
+ 	if (list->array.state & (1<<MD_SB_BBM_ERRORS)) {
+ 		fprintf(stderr, Name ": BBM log found in metadata. "
+@@ -1602,7 +1605,6 @@ static int Incremental_container(struct supertype *st, char *devname,
+ 			close(sfd);
+ 	}
+ 	domain_free(domains);
+-	map_unlock(&map);
+ 	return 0;
+ }
+ 
+-- 
+1.7.6.4
+
diff --git a/mdadm-3.2.2-hold-lock-during-assemble.patch b/mdadm-3.2.2-hold-lock-during-assemble.patch
new file mode 100644
index 0000000..f9aa8ce
--- /dev/null
+++ b/mdadm-3.2.2-hold-lock-during-assemble.patch
@@ -0,0 +1,45 @@
+From 2eebfb2ed16c7c73fc46c3575160fa47c5fa51c5 Mon Sep 17 00:00:00 2001
+From: Jes Sorensen <Jes.Sorensen at redhat.com>
+Date: Mon, 17 Oct 2011 22:09:17 +0200
+Subject: [PATCH 3/3] Hold the map lock while performing Assemble to avoid
+ races with udev
+
+Signed-off-by: Jes Sorensen <Jes.Sorensen at redhat.com>
+---
+ mdadm.c |    6 ++++++
+ 1 files changed, 6 insertions(+), 0 deletions(-)
+
+diff --git a/mdadm.c b/mdadm.c
+index e01beec..7fa8feb 100644
+--- a/mdadm.c
++++ b/mdadm.c
+@@ -1257,6 +1257,7 @@ int main(int argc, char *argv[])
+ 		} else {
+ 			struct mddev_ident *a, *array_list =  conf_get_ident(NULL);
+ 			struct mddev_dev *devlist = conf_get_devs();
++			struct map_ent *map = NULL;
+ 			int cnt = 0;
+ 			int failures, successes;
+ 			if (devlist == NULL) {
+@@ -1276,6 +1277,10 @@ int main(int argc, char *argv[])
+ 				if (a->autof == 0)
+ 					a->autof = autof;
+ 			}
++			if (map_lock(&map))
++				fprintf(stderr, Name " %s: failed to get "
++					"exclusive lock on mapfile\n",
++					__func__);
+ 			do {
+ 				failures = 0;
+ 				successes = 0;
+@@ -1366,6 +1371,7 @@ int main(int argc, char *argv[])
+ 				fprintf(stderr, Name ": No arrays found in config file\n");
+ 				rv = 1;
+ 			}
++			map_unlock(&map);
+ 		}
+ 		break;
+ 	case BUILD:
+-- 
+1.7.6.4
+
diff --git a/mdadm-3.2.2-no-sysfs-launch-container.patch b/mdadm-3.2.2-no-sysfs-launch-container.patch
new file mode 100644
index 0000000..42ac3d9
--- /dev/null
+++ b/mdadm-3.2.2-no-sysfs-launch-container.patch
@@ -0,0 +1,26 @@
+From 91d610e0cb5a22685c6cc1d31b0ff3d4539a6c99 Mon Sep 17 00:00:00 2001
+From: Jes Sorensen <Jes.Sorensen at redhat.com>
+Date: Thu, 13 Oct 2011 19:46:52 +0200
+Subject: [PATCH 2/3] Don't tell sysfs to launch the container as we are doing
+ it ourselves
+
+Signed-off-by: Jes Sorensen <Jes.Sorensen at redhat.com>
+---
+ Incremental.c |    1 -
+ 1 files changed, 0 insertions(+), 1 deletions(-)
+
+diff --git a/Incremental.c b/Incremental.c
+index 9fa6800..55a4589 100644
+--- a/Incremental.c
++++ b/Incremental.c
+@@ -446,7 +446,6 @@ int Incremental(char *devname, int verbose, int runstop,
+ 	if (info.array.level == LEVEL_CONTAINER) {
+ 		int devnum = devnum; /* defined and used iff ->external */
+ 		/* Try to assemble within the container */
+-		sysfs_uevent(&info, "change");
+ 		if (verbose >= 0)
+ 			fprintf(stderr, Name
+ 				": container %s now has %d devices\n",
+-- 
+1.7.6.4
+
diff --git a/mdadm-3.2.2-resync-does-not-continue-after-auto.patch b/mdadm-3.2.2-resync-does-not-continue-after-auto.patch
new file mode 100644
index 0000000..3ba8d5f
--- /dev/null
+++ b/mdadm-3.2.2-resync-does-not-continue-after-auto.patch
@@ -0,0 +1,56 @@
+From b601104eb4a4733a838fb86e9e279fed14ce9d3f Mon Sep 17 00:00:00 2001
+From: Lukasz Dorau <lukasz.dorau at intel.com>
+Date: Mon, 10 Oct 2011 09:16:40 +1100
+Subject: [PATCH] imsm: fix: stopped resync does not continue after
+ auto-assemblation
+
+Resync stopped with "mdadm -Ss" command does not continue
+after issuing "mdadm -As" command.
+
+Signed-off-by: Lukasz Dorau <lukasz.dorau at intel.com>
+Signed-off-by: NeilBrown <neilb at suse.de>
+---
+ mdadm.conf.5  |    5 ++++-
+ super-intel.c |    3 ++-
+ 2 files changed, 6 insertions(+), 2 deletions(-)
+
+--- mdadm-3.2.2/mdadm.conf.5.orig	2011-10-18 14:35:24.254923974 +0200
++++ mdadm-3.2.2/mdadm.conf.5	2011-10-18 14:35:36.231924727 +0200
+@@ -439,7 +439,7 @@
+ of domains of all devices in that array.  A spare can be automatically
+ moved from one array to another if the set of the destination array's
+ .I domains
+-contains all the
++ppcontains all the
+ .I domains
+ of the new disk or if both arrays have the same
+ .IR spare-group .
+@@ -463,6 +463,7 @@
+ .B path=
+ file glob matching anything from
+ .B /dev/disk/by-path
++.TP
+ .B type=
+ either 
+ .B disk
+@@ -471,6 +472,8 @@
+ .TP
+ .B action=
+ include, re-add, spare, spare-same-slot, or force-spare
++.B auto=
++yes, no, or homehost.
+ 
+ .P
+ The
+--- mdadm-3.2.2/super-intel.c.orig	2011-10-18 14:34:24.000000000 +0200
++++ mdadm-3.2.2/super-intel.c	2011-10-18 14:36:23.356925467 +0200
+@@ -2223,7 +2223,8 @@
+ 	info->custom_array_size   = __le32_to_cpu(dev->size_high);
+ 	info->custom_array_size   <<= 32;
+ 	info->custom_array_size   |= __le32_to_cpu(dev->size_low);
+-	if (prev_map && map->map_state == prev_map->map_state) {
++	if (prev_map && map->map_state == prev_map->map_state &&
++	    (migr_type(dev) == MIGR_GEN_MIGR)) {
+ 		info->reshape_active = 1;
+ 		info->new_level = get_imsm_raid_level(map);
+ 		info->new_layout = imsm_level_to_layout(info->new_level);
diff --git a/mdadm.spec b/mdadm.spec
index 2a146af..da06516 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.2
-Release:     9%{?dist}
+Release:     10%{?dist}
 Source:      http://www.kernel.org/pub/linux/utils/raid/mdadm/mdadm-%{version}.tar.bz2
 Source1:     mdmonitor.init
 Source2:     raid-check
@@ -17,6 +17,10 @@ Patch2:      mdadm-3.2.2-fixbuild.patch
 Patch3:      mdadm-3.2.2-readd.patch
 Patch4:      mdadm-3.2.2-writemostly.patch
 Patch5:      mdadm-3.2.2-attributes.patch
+Patch6:      mdadm-3.2.2-resync-does-not-continue-after-auto.patch
+Patch7:      mdadm-3.2.2-Remove-race-for-starting-container-devices.patch
+Patch8:      mdadm-3.2.2-no-sysfs-launch-container.patch
+Patch9:      mdadm-3.2.2-hold-lock-during-assemble.patch
 Patch19:     mdadm-3.1.3-udev.patch
 Patch20:     mdadm-2.5.2-static.patch
 URL:         http://www.kernel.org/pub/linux/utils/raid/mdadm/
@@ -57,6 +61,10 @@ is not used as the system init process.
 %patch3 -p1 -b .readd
 %patch4 -p1 -b .writemostly
 %patch5 -p1 -b .attributes
+%patch6 -p1 -b .resync
+%patch7 -p1 -b .container
+%patch8 -p1 -b .sysfs
+%patch9 -p1 -b .assemble
 %patch19 -p1 -b .udev
 %patch20 -p1 -b .static
 
@@ -131,6 +139,14 @@ fi
 %{_initrddir}/*
 
 %changelog
+* Wed Oct 19 2011 Jes Sorensen <Jes.Sorensen at redhat.com> - 3.2.2-10
+- Fix problem where a dirty IMSM RAID isn't assembled correctly during
+  boot, preventing booting from this RAID device.
+- Resolves: bz736387 (Fedora 15) bz744217 (Fedora 16)
+- Fix race between udev and mdadm when assembling md device using
+  mdadm -I, where udev would spawn an additional mdadm command to
+  perform the assembly in parallel.
+
 * Wed Aug 31 2011 Doug Ledford <dledford at redhat.com> - 3.2.2-9
 - Fix boot with older imsm arrays that have an unused attribute set
 - Resolves: bz729205


More information about the scm-commits mailing list