]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Verify reshape restart position
authorAdam Kwolek <adam.kwolek@intel.com>
Sun, 2 Oct 2011 23:04:32 +0000 (10:04 +1100)
committerNeilBrown <neilb@suse.de>
Sun, 2 Oct 2011 23:04:32 +0000 (10:04 +1100)
Check if reshape restart position is the same as set in md.
If position doesn't match this means that we cannot restart reshape.

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

diff --git a/Grow.c b/Grow.c
index fad4dc88f337f59314bc1b916a0d97348f65ff9f..de177d8c243863dcf3ad8deb0c346ca6653f14c7 100644 (file)
--- a/Grow.c
+++ b/Grow.c
@@ -3645,6 +3645,8 @@ int Grow_continue_command(char *devname, int fd,
        char buf[40];
        int cfd = -1;
        int fd2 = -1;
+       char *ep;
+       unsigned long long position;
 
        dprintf("Grow continue from command line called for %s\n",
                devname);
@@ -3746,6 +3748,35 @@ int Grow_continue_command(char *devname, int fd,
                }
        }
 
+       /* verify that array under reshape is started from
+        * correct position
+        */
+       ret_val = sysfs_get_str(content, NULL, "sync_max", buf, 40);
+       if (ret_val <= 0) {
+               fprintf(stderr, Name
+                       ": cannot open verify reshape progress for %s (%i)\n",
+                       content->sys_name, ret_val);
+               ret_val = 1;
+               goto Grow_continue_command_exit;
+       }
+       dprintf(Name ": Read sync_max sysfs entry is: %s\n", buf);
+       position = strtoull(buf, &ep, 0);
+       if (ep == buf || (*ep != 0 && *ep != '\n' && *ep != ' ')) {
+               fprintf(stderr, Name ": Fatal error: array reshape was"
+                       " not properly frozen\n");
+               ret_val = 1;
+               goto Grow_continue_command_exit;
+       }
+       position *= get_data_disks(map_name(pers, mdstat->level),
+                                  content->new_layout,
+                                  content->array.raid_disks);
+       if (position != content->reshape_progress) {
+               fprintf(stderr, Name ": Fatal error: array reshape was"
+                       " not properly frozen.\n");
+               ret_val = 1;
+               goto Grow_continue_command_exit;
+       }
+
        /* continue reshape
         */
        ret_val = Grow_continue(fd, st, content, backup_file, 0);