]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Incrmental: cope with udev slowness and errors in map file.
authorNeilBrown <neilb@suse.de>
Tue, 4 Nov 2008 10:01:56 +0000 (21:01 +1100)
committerNeilBrown <neilb@suse.de>
Tue, 4 Nov 2008 10:01:56 +0000 (21:01 +1100)
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>
Incremental.c

index 054040d6dd4b2e4bb6bccb84fbbe73bbfcaccf6c..29cbca384af1455a278028f8e66f0ea1f2816b7c 100644 (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);