]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - Grow.c
imsm: fix activate_spare off-by-one
[thirdparty/mdadm.git] / Grow.c
diff --git a/Grow.c b/Grow.c
index 14e48f5696cb0c93fb35eb843a4a5fbd99e40b3e..18056047819ad4d6affe74b42b7b950151bc2913 100644 (file)
--- a/Grow.c
+++ b/Grow.c
@@ -1,7 +1,7 @@
 /*
  * mdadm - manage Linux "md" devices aka RAID arrays.
  *
- * Copyright (C) 2001-2006 Neil Brown <neilb@suse.de>
+ * Copyright (C) 2001-2009 Neil Brown <neilb@suse.de>
  *
  *
  *    This program is free software; you can redistribute it and/or modify
  *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
  *    Author: Neil Brown
- *    Email: <neilb@cse.unsw.edu.au>
- *    Paper: Neil Brown
- *           School of Computer Science and Engineering
- *           The University of New South Wales
- *           Sydney, 2052
- *           Australia
+ *    Email: <neilb@suse.de>
  */
 #include       "mdadm.h"
 #include       "dlink.h"
@@ -809,12 +804,21 @@ int Grow_reshape(char *devname, int fd, int quiet, char *backup_file,
                /* wait for reshape to pass the critical region */
                while(1) {
                        unsigned long long comp;
+
                        if (sysfs_get_ll(sra, NULL, "sync_completed", &comp)<0) {
                                sleep(5);
                                break;
                        }
                        if (comp >= nstripe)
                                break;
+                       if (comp == 0) {
+                               /* Maybe it finished already */
+                               char action[20];
+                               if (sysfs_get_str(sra, NULL, "sync_action",
+                                                 action, 20) > 0 &&
+                                   strncmp(action, "reshape", 7) != 0)
+                                       break;
+                       }
                        sleep(1);
                }