diff options
author | NeilBrown <neilb@suse.de> | 2008-11-04 10:50:39 +0100 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2008-11-04 10:50:39 +0100 |
commit | ad5bc697ad9bb52616c34b022fb014e890be6a2d (patch) | |
tree | c8c8905f29d993f4b3bcf7f449c249c4d9f21337 /Build.c | |
parent | Detail: support MD_DEVNAME in --export for metadata-less devices. (diff) | |
download | 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 'Build.c')
-rw-r--r-- | Build.c | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -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); |