]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - Incremental.c
Incremental: honor an 'enough' flag from external handlers
[thirdparty/mdadm.git] / Incremental.c
index b6f527ab518193aa7b492d4ff5010968346ff306..adef44ee96248faeec116e258a5229d1038212e9 100644 (file)
@@ -2,7 +2,7 @@
  * Incremental.c - support --incremental.  Part of:
  * mdadm - manage Linux "md" devices aka RAID arrays.
  *
- * Copyright (C) 2006 Neil Brown <neilb@suse.de>
+ * Copyright (C) 2006-2009 Neil Brown <neilb@suse.de>
  *
  *
  *    This program is free software; you can redistribute it and/or modify
@@ -221,26 +221,30 @@ int Incremental(char *devname, int verbose, int runstop,
                return 1;
        }
 
-       if (!match && !conf_test_metadata(st->ss->name)) {
-               if (verbose >= 1)
-                       fprintf(stderr, Name
-                               ": %s has metadata type %s for which "
-                               "auto-assembly is disabled\n",
-                               devname, st->ss->name);
-               return 1;
-       }
-
        /* 3a/ if not, check for homehost match.  If no match, continue
         * but don't trust the 'name' in the array. Thus a 'random' minor
         * number will be assigned, and the device name will be based
         * on that. */
        if (match)
                trustworthy = LOCAL;
-       else if ((homehost == NULL ||
-                 st->ss->match_home(st, homehost) != 1) &&
-                st->ss->match_home(st, "any") != 1)
-               trustworthy = FOREIGN;
+       else if (st->ss->match_home(st, homehost) == 1)
+               trustworthy = LOCAL;
+       else if (st->ss->match_home(st, "any") == 1)
+               trustworthy = LOCAL_ANY;
        else
+               trustworthy = FOREIGN;
+
+
+       if (!match && !conf_test_metadata(st->ss->name,
+                                         (trustworthy == LOCAL))) {
+               if (verbose >= 1)
+                       fprintf(stderr, Name
+                               ": %s has metadata type %s for which "
+                               "auto-assembly is disabled\n",
+                               devname, st->ss->name);
+               return 1;
+       }
+       if (trustworthy == LOCAL_ANY)
                trustworthy = LOCAL;
 
        /* There are three possible sources for 'autof':  command line,
@@ -254,6 +258,15 @@ int Incremental(char *devname, int verbose, int runstop,
                autof = ci->autof;
 
        if (st->ss->container_content && st->loaded_container) {
+               if ((runstop > 0 && info.container_enough >= 0) ||
+                   info.container_enough > 0)
+                       /* pass */;
+               else {
+                       if (verbose)
+                               fprintf(stderr, Name ": not enough devices to start the container\n");
+                       return 1;
+               }
+
                /* This is a pre-built container array, so we do something
                 * rather different.
                 */