]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - Assemble.c
mdadm.h: Introduced unaligned {get,put}_unaligned{16,32}()
[thirdparty/mdadm.git] / Assemble.c
index a79466c6cf0c1ba570cf3fc8e0d4d1ea78cc825c..420c7b3943eabc4cca8611867f77dc67c5b5b953 100644 (file)
@@ -578,6 +578,7 @@ static int load_devices(struct devs *devices, char *devmap,
                struct supertype *tst;
                int i;
                int dfd;
+               int disk_state;
 
                if (tmpdev->used != 1)
                        continue;
@@ -711,7 +712,9 @@ static int load_devices(struct devs *devices, char *devmap,
                devices[devcnt].i.disk.major = major(stb.st_rdev);
                devices[devcnt].i.disk.minor = minor(stb.st_rdev);
 
-               if (devices[devcnt].i.disk.state == 6) {
+               disk_state = devices[devcnt].i.disk.state & ~((1<<MD_DISK_FAILFAST) |
+                                                             (1<<MD_DISK_WRITEMOSTLY));
+               if (disk_state == ((1<<MD_DISK_ACTIVE) | (1<<MD_DISK_SYNC))) {
                        if (most_recent < 0 ||
                            devices[devcnt].i.events
                            > devices[most_recent].i.events) {
@@ -876,7 +879,7 @@ static int force_array(struct mdinfo *content,
                current_events = devices[chosen_drive].i.events;
        add_another:
                if (c->verbose >= 0)
-                       pr_err("forcing event count in %s(%d) from %d upto %d\n",
+                       pr_err("forcing event count in %s(%d) from %d up to %d\n",
                               devices[chosen_drive].devname,
                               devices[chosen_drive].i.disk.raid_disk,
                               (int)(devices[chosen_drive].i.events),
@@ -1704,6 +1707,9 @@ try_again:
                else
                        desired_state = (1<<MD_DISK_ACTIVE) | (1<<MD_DISK_SYNC);
 
+               desired_state |= devices[j].i.disk.state & ((1<<MD_DISK_FAILFAST) |
+                                                           (1<<MD_DISK_WRITEMOSTLY));
+
                if (!devices[j].uptodate)
                        continue;
 
@@ -2055,8 +2061,22 @@ int assemble_container_content(struct supertype *st, int mdfd,
                                   spare, &c->backup_file, c->verbose) == 1)
                        return 1;
 
-               err = sysfs_set_str(content, NULL,
-                                   "array_state", "readonly");
+               if (content->reshape_progress == 0) {
+                       /* If reshape progress is 0 - we are assembling the
+                        * array that was stopped, before reshape has started.
+                        * Array needs to be started as active, Grow_continue()
+                        * will start the reshape.
+                        */
+                       sysfs_set_num(content, NULL, "reshape_position",
+                                     MaxSector);
+                       err = sysfs_set_str(content, NULL,
+                                           "array_state", "active");
+                       sysfs_set_num(content, NULL, "reshape_position", 0);
+               } else {
+                       err = sysfs_set_str(content, NULL,
+                                           "array_state", "readonly");
+               }
+
                if (err)
                        return 1;