]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - Assemble.c
mdadm: add the ability to change cluster name
[thirdparty/mdadm.git] / Assemble.c
index 46ab72e48eb06f307ceafbf709720f28fe510a16..12ac299f2bf3c582e6619de2f6588704f71e6990 100644 (file)
@@ -626,7 +626,10 @@ static int load_devices(struct devs *devices, char *devmap,
 
                        if (strcmp(c->update, "byteorder") == 0)
                                err = 0;
-                       else
+                       else if (strcmp(c->update, "home-cluster") == 0) {
+                               tst->cluster_name = c->homecluster;
+                               tst->ss->write_bitmap(tst, dfd, NameUpdate);
+                       } else
                                err = tst->ss->update_super(tst, content, c->update,
                                                            devname, c->verbose,
                                                            ident->uuid_set,
@@ -817,12 +820,37 @@ static int force_array(struct mdinfo *content,
                     i < content->array.raid_disks * 2 && i < bestcnt;
                     i += 2) {
                        int j = best[i];
-                       if (j>=0 &&
-                           !devices[j].uptodate &&
-                           devices[j].i.recovery_start == MaxSector &&
-                           (chosen_drive < 0 ||
+                       if (j < 0)
+                               continue;
+                       if (devices[j].uptodate)
+                               continue;
+                       if (devices[j].i.recovery_start != MaxSector) {
+                               int delta;
+                               if (!devices[j].i.reshape_active ||
+                                   devices[j].i.delta_disks <= 0)
+                                       continue;
+                               /* When increasing number of devices, an
+                                * added device also appears to be
+                                * recovering.  It is safe to include it
+                                * as long as it won't be a source of
+                                * data.
+                                * For now, just allow for last data
+                                * devices in RAID4 or last devices in RAID4/5/6.
+                                */
+                               delta = devices[j].i.delta_disks;
+                               if (devices[j].i.array.level >= 4 &&
+                                   devices[j].i.array.level <= 6 &&
+                                   i/2 >= content->array.raid_disks - delta)
+                                       /* OK */;
+                               else if (devices[j].i.array.level == 4 &&
+                                        i/2 >= content->array.raid_disks - delta - 1)
+                                       /* OK */;
+                               else
+                                       continue;
+                       }
+                       if (chosen_drive < 0 ||
                             devices[j].i.events
-                            > devices[chosen_drive].i.events))
+                           > devices[chosen_drive].i.events)
                                chosen_drive = j;
                }
                if (chosen_drive < 0)
@@ -1323,7 +1351,10 @@ try_again:
         */
        if (map_lock(&map))
                pr_err("failed to get exclusive lock on mapfile - continue anyway...\n");
-       mp = map_by_uuid(&map, content->uuid);
+       if (c->update && strcmp(c->update,"uuid") == 0)
+               mp = NULL;
+       else
+               mp = map_by_uuid(&map, content->uuid);
        if (mp) {
                struct mdinfo *dv;
                /* array already exists. */