]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - Incremental.c
imsm: turn off curr_migr_unit updates
[thirdparty/mdadm.git] / Incremental.c
index 0a0dc03762ee430151cf1d16b952ab91dc31683e..99fc1bfcac611aceb21354ba3ae9b82d6985e0d3 100644 (file)
@@ -220,19 +220,8 @@ int Incremental(char *devname, int verbose, int runstop,
        else if (homehost == NULL ||
                 st->ss->match_home(st, homehost) != 1)
                trustworthy = FOREIGN;
-       name_to_use = strchr(info.name, ':');
-       if (name_to_use)
-               name_to_use++;
        else
-               name_to_use = info.name;
-
-       if ((!name_to_use || name_to_use[0] == 0) &&
-           info.array.level == LEVEL_CONTAINER &&
-           trustworthy == LOCAL) {
-               name_to_use = info.text_version;
-               trustworthy = METADATA;
-       }
-
+               trustworthy = LOCAL;
 
        /* There are three possible sources for 'autof':  command line,
         * ARRAY line in mdadm.conf, or CREATE line in mdadm.conf.
@@ -251,6 +240,19 @@ int Incremental(char *devname, int verbose, int runstop,
                return Incremental_container(st, devname, verbose, runstop,
                                             autof, trustworthy);
        }
+       name_to_use = strchr(info.name, ':');
+       if (name_to_use)
+               name_to_use++;
+       else
+               name_to_use = info.name;
+
+       if ((!name_to_use || name_to_use[0] == 0) &&
+           info.array.level == LEVEL_CONTAINER &&
+           trustworthy == LOCAL) {
+               name_to_use = info.text_version;
+               trustworthy = METADATA;
+       }
+
        /* 4/ Check if array exists.
         */
        map_lock(&map);
@@ -398,6 +400,8 @@ int Incremental(char *devname, int verbose, int runstop,
                                ": container %s now has %d devices\n",
                                chosen_name, info.array.working_disks);
                wait_for(chosen_name);
+               if (runstop < 0)
+                       return 0; /* don't try to assemble */
                return Incremental(chosen_name, verbose, runstop,
                                   NULL, homehost, autof);
        }
@@ -405,7 +409,8 @@ int Incremental(char *devname, int verbose, int runstop,
        active_disks = count_active(st, mdfd, &avail, &info);
        if (enough(info.array.level, info.array.raid_disks,
                   info.array.layout, info.array.state & 1,
-                  avail, active_disks) == 0) {
+                  avail, active_disks) == 0 ||
+           (runstop < 0 && active_disks < info.array.raid_disks)) {
                free(avail);
                if (verbose >= 0)
                        fprintf(stderr, Name
@@ -728,7 +733,10 @@ int Incremental_container(struct supertype *st, char *devname, int verbose,
 
                mp = map_by_uuid(&map, ra->uuid);
 
-               if (!mp) {
+               if (mp) {
+                       mdfd = open_dev(mp->devnum);
+                       strcpy(chosen_name, mp->path);
+               } else {
 
                        /* Check in mdadm.conf for devices == devname and
                         * member == ra->text_version after second slash.
@@ -767,13 +775,13 @@ int Incremental_container(struct supertype *st, char *devname, int verbose,
                                                array_list->member);
                                break;
                        }
-               }
 
-               mdfd = create_mddev(match ? match->devname : NULL,
-                                   ra->name,
-                                   autof,
-                                   trustworthy,
-                                   chosen_name);
+                       mdfd = create_mddev(match ? match->devname : NULL,
+                                           ra->name,
+                                           autof,
+                                           trustworthy,
+                                           chosen_name);
+               }
 
                if (mdfd < 0) {
                        fprintf(stderr, Name ": failed to open %s: %s.\n",