]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
FIX: wait_backup() sometimes hungs
authorAdam Kwolek <adam.kwolek@intel.com>
Fri, 3 Dec 2010 10:33:55 +0000 (21:33 +1100)
committerNeilBrown <neilb@suse.de>
Fri, 3 Dec 2010 10:33:55 +0000 (21:33 +1100)
Sometimes wait_backup() omits transition from reshape to idle state
and mdadm seams to be hung.  So check the 'complete' count
*before* waiting rather than only after.

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 3322cf77e61176e378628fee1ad6dc6138bb8624..cf09a604122482e14d983320dc2c487faac0dee1 100644 (file)
--- a/Grow.c
+++ b/Grow.c
@@ -2058,7 +2058,12 @@ static int wait_backup(struct mdinfo *sra,
        sysfs_set_num(sra, NULL, "sync_max", offset + blocks + blocks2);
        if (offset == 0)
                sysfs_set_str(sra, NULL, "sync_action", "reshape");
-       do {
+
+       if (sysfs_fd_get_ll(fd, &completed) < 0) {
+               close(fd);
+               return -1;
+       }
+       while (completed < offset + blocks) {
                char action[20];
                fd_set rfds;
                FD_ZERO(&rfds);
@@ -2072,7 +2077,7 @@ static int wait_backup(struct mdinfo *sra,
                                  action, 20) > 0 &&
                    strncmp(action, "reshape", 7) != 0)
                        break;
-       } while (completed < offset + blocks);
+       }
        close(fd);
 
        if (part) {