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