summaryrefslogtreecommitdiffstats
path: root/Create.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2008-11-04 20:50:39 +1100
committerNeilBrown <neilb@suse.de>2008-11-04 20:50:39 +1100
commitad5bc697ad9bb52616c34b022fb014e890be6a2d (patch)
treec8c8905f29d993f4b3bcf7f449c249c4d9f21337 /Create.c
parent7e6c6cb26790e4b0de2e8694cca655db26bee11a (diff)
downloadmdadm-ad5bc697ad9bb52616c34b022fb014e890be6a2d.tar.gz
mdadm-ad5bc697ad9bb52616c34b022fb014e890be6a2d.tar.xz
mdadm-ad5bc697ad9bb52616c34b022fb014e890be6a2d.zip
Incremental: lock against multiple concurrent additions to an array.
In two devices are added via -I to one array at the same time, mdadm can get badly confused. Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'Create.c')
-rw-r--r--Create.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/Create.c b/Create.c
index a66ed0c..7492c67 100644
--- 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;