[PATCH 19/33] Assemble: assembly with domains - two runs for imsm spares

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Czarnowska, Anna 
Sent: Monday, July 05, 2010 11:34 AM
To: Neil Brown
Cc: linux-raid@xxxxxxxxxxxxxxx; Czarnowska, Anna; Hawrylewicz Czarnowski, Przemyslaw; Labun, Marcin; Neubauer, Wojciech; Williams, Dan J; Ciechanowski, Ed; dledford@xxxxxxxxxx
Subject: [PATCH 19/33] Assemble: assembly with domains - two runs for imsm spares

UUID of an imsm spare matches any array but we are not able to decide if the spare can be assembled with the array until we know this array's domain. Spares found before determining array's domain are marked and matched in second run.

Signed-off-by: Anna Czarnowska <anna.czarnowska@xxxxxxxxx>
---
 Assemble.c |   46 ++++++++++++++++++++++++++++++++++++----------
 1 files changed, 36 insertions(+), 10 deletions(-)

diff --git a/Assemble.c b/Assemble.c
index cc51428..a1ec8cb 100644
--- a/Assemble.c
+++ b/Assemble.c
@@ -168,6 +168,8 @@ int Assemble(struct supertype *st, char *mddev,
      char *name = NULL;
      int trustworthy;
      char chosen_name[1024];
+     int run = 0;
+     int spare;
 
      struct domain_ent *domain = NULL, *de;
      struct subset *subset = NULL, *ss;
@@ -221,7 +223,9 @@ int Assemble(struct supertype *st, char *mddev,
      if (verbose>0)
          fprintf(stderr, Name ": looking for devices for %s\n",
                mddev ? mddev : "further assembly");
-
+     run = 0;
+     spare = 0;
+second_run:
      /* first walk the list of devices to find a consistent set
       * that match the criterea, if that is possible.
       * We flag the ones we like with 'used'.
@@ -234,8 +238,14 @@ int Assemble(struct supertype *st, char *mddev,
            struct stat stb;
            struct supertype *tst = dup_super(st);
 
-           if (tmpdev->used > 1) continue;
-
+           if (tmpdev->used == 2)
+                 continue;
+           if (run == 1) {
+                 if (tmpdev->used != 3)
+                       continue;
+                 else
+                       tmpdev->used = 0;
+           }
            if (ident->devices &&
                !match_oneof(ident->devices, devname)) {
                  if (report_missmatch)
@@ -399,13 +409,22 @@ int Assemble(struct supertype *st, char *mddev,
                  }
                  ss = conf_get_subset(devname, st, de);
                  if (!domain) {
-                       if (report_missmatch) {
-                             fprintf(stderr, Name ": Base domain set for "
-                                              "device: %s\n",
-                                         devname);
+                       if (memcmp(content->uuid, uuid_match_any,
+                                sizeof(int[4])) != 0) {
+                             if (report_missmatch) {
+                                   fprintf(stderr, Name ": Base domain set for "
+                                         "device: %s\n", devname);
+                             }
+                             domain = de;
+                             subset = ss;
+                       } else{
+                             /* imsm spares only
+                             * we don't know if this spare can
+                             * be used until we know domain
+                             * so mark it for second run */
+                             tmpdev->used = 3;
+                             spare = 1; /* set flag */
                        }
-                       domain = de;
-                       subset = ss;
                  } else {
                        if (domain != de || subset != ss) {
                              if (report_missmatch)
@@ -524,7 +543,8 @@ int Assemble(struct supertype *st, char *mddev,
                  return 1;
            }
 
-           tmpdev->used = 1;
+           if (tmpdev->used != 3)
+                 tmpdev->used = 1;
 
      loop:
            if (tmpdev->content)
@@ -533,6 +553,12 @@ int Assemble(struct supertype *st, char *mddev,
                  tst->ss->free_super(tst);
      }
 
+     /* We may have missed some spares before domain was determined */
+     if (run == 0 && spare && domain) {
+           run = 1;
+           goto second_run;
+     }
+
      if (!st || !st->sb || !content)
            return 2;
 
--
1.6.4.2


--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux RAID Wiki]     [ATA RAID]     [Linux SCSI Target Infrastructure]     [Linux Block]     [Linux IDE]     [Linux SCSI]     [Linux Hams]     [Device Mapper]     [Device Mapper Cryptographics]     [Kernel]     [Linux Admin]     [Linux Net]     [GFS]     [RPM]     [git]     [Yosemite Forum]


  Powered by Linux