]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - Assemble.c
Release 3.2.6 - stability release
[thirdparty/mdadm.git] / Assemble.c
index fadacf5f7e9cbbe9b338edb6c4c10b98ac1e317c..8c8aad37b26dabf0d32a53ca09a12d616b02dabf 100644 (file)
@@ -1069,6 +1069,7 @@ int Assemble(struct supertype *st, char *mddev,
                        int j = best[i];
                        if (j >= 0 &&
                            !devices[j].uptodate &&
+                           devices[j].i.recovery_start == MaxSector &&
                            devices[j].i.events == current_events) {
                                chosen_drive = j;
                                goto add_another;
@@ -1238,6 +1239,7 @@ int Assemble(struct supertype *st, char *mddev,
                        i--;
                        if (fdlist[i]>=0) close(fdlist[i]);
                }
+               free(fdlist);
                if (err) {
                        fprintf(stderr, Name ": Failed to restore critical section for reshape, sorry.\n");
                        if (backup_file == NULL)
@@ -1334,9 +1336,11 @@ int Assemble(struct supertype *st, char *mddev,
                                                sparecnt--;
                                } else if (verbose > 0)
                                        fprintf(stderr, Name ": added %s "
-                                                       "to %s as %d\n",
+                                                       "to %s as %d%s\n",
                                                devices[j].devname, mddev,
-                                               devices[j].i.disk.raid_disk);
+                                               devices[j].i.disk.raid_disk,
+                                               devices[j].uptodate?"":
+                                               " (possibly out of date)");
                        } else if (verbose > 0 && i < content->array.raid_disks)
                                fprintf(stderr, Name ": no uptodate device for "
                                                "slot %d of %s\n",
@@ -1556,6 +1560,7 @@ int assemble_container_content(struct supertype *st, int mdfd,
        int expansion = 0;
        struct map_ent *map = NULL;
        int old_raid_disks;
+       int start_reshape;
 
        sysfs_init(content, mdfd, 0);
 
@@ -1567,7 +1572,17 @@ int assemble_container_content(struct supertype *st, int mdfd,
                        return 1;
                }
 
-       if (st->ss->external && content->recovery_blocked)
+       /* There are two types of reshape: container wide or sub-array specific
+        * Check if metadata requests blocking container wide reshapes
+        */
+       start_reshape = (content->reshape_active &&
+               !((content->reshape_active == CONTAINER_RESHAPE) &&
+               (content->array.state & (1<<MD_SB_BLOCK_CONTAINER_RESHAPE))));
+
+       /* Block subarray here if it is under reshape now
+        * Do not allow for any changes in this array
+        */
+       if (st->ss->external && content->recovery_blocked && start_reshape)
                block_subarray(content);
 
        if (sra)
@@ -1593,14 +1608,7 @@ int assemble_container_content(struct supertype *st, int mdfd,
                 (working + preexist + expansion) >=
                        content->array.working_disks) {
                int err;
-               int start_reshape;
 
-               /* There are two types of reshape: container wide or sub-array specific
-                * Check if metadata requests blocking container wide reshapes
-                */
-               start_reshape = (content->reshape_active &&
-                                !((content->reshape_active == CONTAINER_RESHAPE) &&
-                                  (content->array.state & (1<<MD_SB_BLOCK_CONTAINER_RESHAPE))));
                if (start_reshape) {
                        int spare = content->array.raid_disks + expansion;
                        if (restore_backup(st, content,
@@ -1644,6 +1652,15 @@ int assemble_container_content(struct supertype *st, int mdfd,
                }
                if (!err)
                        sysfs_set_safemode(content, content->safe_mode_delay);
+
+               /* Block subarray here if it is not reshaped now
+                * It has be blocked a little later to allow mdmon to switch in
+                * in to R/W state
+                */
+               if (st->ss->external && content->recovery_blocked &&
+                   !start_reshape)
+                       block_subarray(content);
+
                if (verbose >= 0) {
                        if (err)
                                fprintf(stderr, Name