]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Always run Grow_continue() for started array.
authorAdam Kwolek <adam.kwolek@intel.com>
Thu, 6 Oct 2011 09:13:22 +0000 (11:13 +0200)
committerNeilBrown <neilb@suse.de>
Thu, 6 Oct 2011 22:46:07 +0000 (09:46 +1100)
So far there were 2 reshape continuation cases:
 1. array is started /e.g. reshape was already invoked during initrd
                      start-up stage using "--freeze-reshape" option/
 2. array is not started yet /"normal" assembling array under reshape case/

This patch narrows continuation cases in to single one. To do this
array should be started /set readonly in to array_state/ before calling
Grow_continue() function.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
Assemble.c
Grow.c

index 285eeee333fc49c88d4f0813f373684ccc729d90..2000dd073c3a560b74b349b50013ee4536581da6 100644 (file)
@@ -1343,10 +1343,14 @@ int Assemble(struct supertype *st, char *mddev,
                        int rv;
 #ifndef MDASSEMBLE
                        if (content->reshape_active &&
-                           content->delta_disks <= 0)
-                               rv = Grow_continue(mdfd, st, content,
-                                                  backup_file, freeze_reshape);
-                       else
+                           content->delta_disks <= 0) {
+                               rv = sysfs_set_str(content, NULL,
+                                                  "array_state", "readonly");
+                               if (rv == 0)
+                                       rv = Grow_continue(mdfd, st, content,
+                                                          backup_file,
+                                                          freeze_reshape);
+                       } else
 #endif
                                rv = ioctl(mdfd, RUN_ARRAY, NULL);
                        if (rv == 0) {
@@ -1561,6 +1565,11 @@ int assemble_container_content(struct supertype *st, int mdfd,
                                           spare, backup_file, verbose) == 1)
                                return 1;
 
+                       err = sysfs_set_str(content, NULL,
+                                           "array_state", "readonly");
+                       if (err)
+                               return 1;
+
                        if (st->ss->external) {
                                if (!mdmon_running(st->container_dev))
                                        start_mdmon(st->container_dev);
diff --git a/Grow.c b/Grow.c
index 6f86987829c78e0a26b2d69694212edc763de87f..4f8b9d74ca0898607c9f996a1e67e0999179ee82 100644 (file)
--- a/Grow.c
+++ b/Grow.c
@@ -3802,33 +3802,28 @@ Grow_continue_command_exit:
 int Grow_continue(int mdfd, struct supertype *st, struct mdinfo *info,
                  char *backup_file, int freeze_reshape)
 {
-       char buf[40];
-       char *container = NULL;
-       int err;
+       int ret_val = 2;
+
+       if (!info->reshape_active)
+               return ret_val;
 
-       err = sysfs_set_str(info, NULL, "array_state", "readonly");
-       if (err)
-               return err;
        if (st->ss->external) {
-               fmt_devname(buf, st->container_dev);
-               container = buf;
+               char container[40];
+               int cfd = open_dev(st->container_dev);
 
-               if (!mdmon_running(st->container_dev))
-                       start_mdmon(st->container_dev);
-               ping_monitor_by_id(st->container_dev);
+               if (cfd < 0)
+                       return 1;
 
+               fmt_devname(container, st->container_dev);
+               st->ss->load_container(st, cfd, container);
+               close(cfd);
+               ret_val = reshape_container(container, NULL,
+                                           st, info, 0, backup_file,
+                                           0, 1, freeze_reshape);
+       } else
+               ret_val = reshape_array(NULL, mdfd, "array", st, info, 1,
+                                       NULL, backup_file, 0, 0, 1,
+                                       freeze_reshape);
 
-               if (info->reshape_active == 2) {
-                       int cfd = open_dev(st->container_dev);
-                       if (cfd < 0)
-                               return 1;
-                       st->ss->load_container(st, cfd, container);
-                       close(cfd);
-                       return reshape_container(container, NULL,
-                                                st, info, 0, backup_file,
-                                                0, 1, freeze_reshape);
-               }
-       }
-       return reshape_array(container, mdfd, "array", st, info, 1,
-                            NULL, backup_file, 0, 0, 1, freeze_reshape);
+       return ret_val;
 }