mdadm/mdadm-3.2.2-Remove-race-for-starting-container-devices.patch
Jes Sorensen 6c5cfe0908 Fix problem with IMSM raid not being started correctly during boot
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
2011-10-19 16:46:54 +02:00

80 lines
2.7 KiB
Diff

From 50177a4bbed446087dd2529b5518697f2f69de08 Mon Sep 17 00:00:00 2001
From: Jes Sorensen <Jes.Sorensen@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@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