]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
FIX: Honor !reshape state on wait_reshape() entry
authorAdam Kwolek <adam.kwolek@intel.com>
Fri, 3 Dec 2010 04:10:20 +0000 (15:10 +1100)
committerNeilBrown <neilb@suse.de>
Fri, 3 Dec 2010 04:10:20 +0000 (15:10 +1100)
When wait_reshape() function starts it can occurs that reshape is
finished already, before wait_reshape() start. This can lead to wait
for change state inside this function for a long time.  To avoid this
before wait we should test if finish conditions are not reached
already.

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 c408a92a6fbb839c62dfebf5620526b550c99cc1..3322cf77e61176e378628fee1ad6dc6138bb8624 100644 (file)
--- a/Grow.c
+++ b/Grow.c
@@ -548,17 +548,17 @@ static void wait_reshape(struct mdinfo *sra)
        int fd = sysfs_get_fd(sra, NULL, "sync_action");
        char action[20];
 
-       do {
+       if (fd < 0)
+               return;
+
+       while  (sysfs_fd_get_str(fd, action, 20) > 0 &&
+               strncmp(action, "reshape", 7) == 0) {
                fd_set rfds;
                FD_ZERO(&rfds);
                FD_SET(fd, &rfds);
                select(fd+1, NULL, NULL, &rfds, NULL);
-               
-               if (sysfs_fd_get_str(fd, action, 20) < 0) {
-                       close(fd);
-                       return;
-               }
-       } while  (strncmp(action, "reshape", 7) == 0);
+       }
+       close(fd);
 }
 
 static int reshape_super(struct supertype *st, long long size, int level,