]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - Create.c
Incremental: lock against multiple concurrent additions to an array.
[thirdparty/mdadm.git] / Create.c
index a66ed0ce2f01e50dd61ff94ee43bd866917f2df7..7492c67efaff3724bbc58792d9941ed4e8636001 100644 (file)
--- a/Create.c
+++ b/Create.c
@@ -80,6 +80,7 @@ int Create(struct supertype *st, char *mddev,
        int did_default = 0;
        unsigned long safe_mode_delay = 0;
        char chosen_name[1024];
+       struct map_ent *map = NULL;
 
        int major_num = BITMAP_MAJOR_HI;
 
@@ -422,6 +423,7 @@ int Create(struct supertype *st, char *mddev,
        }
 
        /* We need to create the device */
+       map_lock(&map);
        mdfd = create_mddev(mddev, name, autof, LOCAL, chosen_name);
        if (mdfd < 0)
                return 1;
@@ -561,8 +563,9 @@ int Create(struct supertype *st, char *mddev,
                                " %s metadata\n", info.text_version);
        }
 
-       map_update(NULL, fd2devnum(mdfd), info.text_version,
+       map_update(&map, fd2devnum(mdfd), info.text_version,
                   info.uuid, chosen_name);
+       map_unlock(&map);
 
        if (bitmap_file && vers < 9003) {
                major_num = BITMAP_MAJOR_HOSTENDIAN;