Wait for name to appear after create/assemble etc.
We don't really want mdadm to exit until udev has created the names in /dev. So wait. Signed-off-by: NeilBrown <neilb@suse.de>
This commit is contained in:
parent
195254b87a
commit
a714580e02
|
@ -1216,6 +1216,10 @@ int assemble_container_content(struct supertype *st, int mdfd,
|
||||||
/* Nothing new, don't try to start */ ;
|
/* Nothing new, don't try to start */ ;
|
||||||
else if (runstop > 0 ||
|
else if (runstop > 0 ||
|
||||||
(working + preexist) >= content->array.working_disks) {
|
(working + preexist) >= content->array.working_disks) {
|
||||||
|
|
||||||
|
map_update(&map, fd2devnum(mdfd),
|
||||||
|
content->text_version,
|
||||||
|
content->uuid, chosen_name);
|
||||||
switch(content->array.level) {
|
switch(content->array.level) {
|
||||||
case LEVEL_LINEAR:
|
case LEVEL_LINEAR:
|
||||||
case LEVEL_MULTIPATH:
|
case LEVEL_MULTIPATH:
|
||||||
|
@ -1241,6 +1245,7 @@ int assemble_container_content(struct supertype *st, int mdfd,
|
||||||
fprintf(stderr, " (%d new)", working);
|
fprintf(stderr, " (%d new)", working);
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
}
|
}
|
||||||
|
wait_for(chosen_name);
|
||||||
/* FIXME should have an O_EXCL and wait for read-auto */
|
/* FIXME should have an O_EXCL and wait for read-auto */
|
||||||
} else
|
} else
|
||||||
if (verbose >= 0)
|
if (verbose >= 0)
|
||||||
|
@ -1248,9 +1253,6 @@ int assemble_container_content(struct supertype *st, int mdfd,
|
||||||
": %s assembled with %d devices but "
|
": %s assembled with %d devices but "
|
||||||
"not started\n",
|
"not started\n",
|
||||||
chosen_name, working);
|
chosen_name, working);
|
||||||
map_update(&map, fd2devnum(mdfd),
|
|
||||||
content->text_version,
|
|
||||||
content->uuid, chosen_name);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
2
Build.c
2
Build.c
|
@ -124,6 +124,7 @@ int Build(char *mddev, int chunk, int level, int layout,
|
||||||
map_unlock(&map);
|
map_unlock(&map);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
mddev = chosen_name;
|
||||||
|
|
||||||
map_update(&map, fd2devnum(mdfd), "none", uuid, chosen_name);
|
map_update(&map, fd2devnum(mdfd), "none", uuid, chosen_name);
|
||||||
map_unlock(&map);
|
map_unlock(&map);
|
||||||
|
@ -281,6 +282,7 @@ int Build(char *mddev, int chunk, int level, int layout,
|
||||||
fprintf(stderr, Name ": array %s built and started.\n",
|
fprintf(stderr, Name ": array %s built and started.\n",
|
||||||
mddev);
|
mddev);
|
||||||
close(mdfd);
|
close(mdfd);
|
||||||
|
wait_for(mddev);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
abort:
|
abort:
|
||||||
|
|
1
Create.c
1
Create.c
|
@ -784,6 +784,7 @@ int Create(struct supertype *st, char *mddev,
|
||||||
fprintf(stderr, Name ": not starting array - not enough devices.\n");
|
fprintf(stderr, Name ": not starting array - not enough devices.\n");
|
||||||
}
|
}
|
||||||
close(mdfd);
|
close(mdfd);
|
||||||
|
wait_for(chosen_name);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
abort:
|
abort:
|
||||||
|
|
|
@ -390,6 +390,7 @@ int Incremental(char *devname, int verbose, int runstop,
|
||||||
fprintf(stderr, Name
|
fprintf(stderr, Name
|
||||||
": container %s now has %d devices\n",
|
": container %s now has %d devices\n",
|
||||||
chosen_name, info.array.working_disks);
|
chosen_name, info.array.working_disks);
|
||||||
|
wait_for(chosen_name);
|
||||||
return Incremental(chosen_name, verbose, runstop,
|
return Incremental(chosen_name, verbose, runstop,
|
||||||
NULL, homehost, autof);
|
NULL, homehost, autof);
|
||||||
}
|
}
|
||||||
|
@ -461,6 +462,7 @@ int Incremental(char *devname, int verbose, int runstop,
|
||||||
": %s attached to %s, which has been started.\n",
|
": %s attached to %s, which has been started.\n",
|
||||||
devname, chosen_name);
|
devname, chosen_name);
|
||||||
rv = 0;
|
rv = 0;
|
||||||
|
wait_for(chosen_name);
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, Name
|
fprintf(stderr, Name
|
||||||
": %s attached to %s, but failed to start: %s.\n",
|
": %s attached to %s, but failed to start: %s.\n",
|
||||||
|
|
1
mdadm.h
1
mdadm.h
|
@ -646,6 +646,7 @@ extern struct supertype *dup_super(struct supertype *st);
|
||||||
extern int get_dev_size(int fd, char *dname, unsigned long long *sizep);
|
extern int get_dev_size(int fd, char *dname, unsigned long long *sizep);
|
||||||
extern void get_one_disk(int mdfd, mdu_array_info_t *ainf,
|
extern void get_one_disk(int mdfd, mdu_array_info_t *ainf,
|
||||||
mdu_disk_info_t *disk);
|
mdu_disk_info_t *disk);
|
||||||
|
void wait_for(char *dev);
|
||||||
|
|
||||||
#if __GNUC__ < 3
|
#if __GNUC__ < 3
|
||||||
struct stat64;
|
struct stat64;
|
||||||
|
|
12
util.c
12
util.c
|
@ -842,6 +842,18 @@ int same_dev(char *one, char *two)
|
||||||
return st1.st_rdev == st2.st_rdev;
|
return st1.st_rdev == st2.st_rdev;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wait_for(char *dev)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i=0 ; i<25 ; i++) {
|
||||||
|
struct stat stb;
|
||||||
|
if (stat(dev, &stb) == 0)
|
||||||
|
return;
|
||||||
|
usleep(200000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
struct superswitch *superlist[] = { &super0, &super1, &super_ddf, &super_imsm, NULL };
|
struct superswitch *superlist[] = { &super0, &super1, &super_ddf, &super_imsm, NULL };
|
||||||
|
|
||||||
#if !defined(MDASSEMBLE) || defined(MDASSEMBLE) && defined(MDASSEMBLE_AUTO)
|
#if !defined(MDASSEMBLE) || defined(MDASSEMBLE) && defined(MDASSEMBLE_AUTO)
|
||||||
|
|
Loading…
Reference in New Issue