Incrmental: cope with udev slowness and errors in map file.

If udev hasn't created the array yet, we might still want to
open it.  So open directly by major:minor.

Also, of array in map file doesn't appear to exist, do use
the name associated with it.

Signed-off-by: NeilBrown <neilb@suse.de>
This commit is contained in:
NeilBrown 2008-11-04 21:01:56 +11:00
parent 678a4a36b0
commit ffb3e4945d
1 changed files with 10 additions and 3 deletions

View File

@ -247,9 +247,16 @@ int Incremental(char *devname, int verbose, int runstop,
*/
map_lock(&map);
mp = map_by_uuid(&map, info.uuid);
if (mp)
if (mp) {
mdfd = open_mddev(mp->path, 0);
else
if (mdfd < 0 && mddev_busy(mp->devnum)) {
/* maybe udev hasn't created it yet. */
char buf[50];
sprintf(buf, "%d:%d", dev2major(mp->devnum),
dev2minor(mp->devnum));
mdfd = dev_open(buf, O_RDWR);
}
} else
mdfd = -1;
if (mdfd < 0) {
@ -257,7 +264,7 @@ int Incremental(char *devname, int verbose, int runstop,
struct mdinfo dinfo;
/* Couldn't find an existing array, maybe make a new one */
mdfd = create_mddev(mp ? mp->path : match ? match->devname : NULL,
mdfd = create_mddev(match ? match->devname : NULL,
info.name, autof, trustworthy, chosen_name);