summaryrefslogtreecommitdiff
path: root/Build.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 /Build.c
parent7e6c6cb26790e4b0de2e8694cca655db26bee11a (diff)
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 'Build.c')
-rw-r--r--Build.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/Build.c b/Build.c
index d831e555..c92c6a98 100644
--- a/Build.c
+++ b/Build.c
@@ -62,6 +62,7 @@ int Build(char *mddev, int chunk, int level, int layout,
int mdfd;
char chosen_name[1024];
int uuid[4] = {0,0,0,0};
+ struct map_ent *map = NULL;
/* scan all devices, make sure they really are block devices */
for (dv = devlist; dv; dv=dv->next) {
@@ -116,12 +117,16 @@ int Build(char *mddev, int chunk, int level, int layout,
}
/* We need to create the device. It can have no name. */
+ map_lock(&map);
mdfd = create_mddev(mddev, NULL, autof, LOCAL,
chosen_name);
- if (mdfd < 0)
+ if (mdfd < 0) {
+ map_unlock(&map);
return 1;
+ }
- map_update(NULL, fd2devnum(mdfd), "none", uuid, chosen_name);
+ map_update(&map, fd2devnum(mdfd), "none", uuid, chosen_name);
+ map_unlock(&map);
vers = md_get_version(mdfd);