]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Hold the map lock while performing Assemble to avoid races with udev
authorJes Sorensen <Jes.Sorensen@redhat.com>
Sat, 22 Oct 2011 00:30:43 +0000 (11:30 +1100)
committerNeilBrown <neilb@suse.de>
Sat, 22 Oct 2011 00:30:43 +0000 (11:30 +1100)
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
mdadm.c

diff --git a/mdadm.c b/mdadm.c
index ebf1c46eab78204fbd8a626cc43b3d1cf97d5e56..56de7b7e8df4cd75cd5a2dfd6368317663b02221 100644 (file)
--- a/mdadm.c
+++ b/mdadm.c
@@ -1279,6 +1279,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) {
@@ -1298,6 +1299,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;
@@ -1364,6 +1369,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: