From: Adam Kwolek Date: Fri, 3 Dec 2010 10:33:55 +0000 (+1100) Subject: FIX: wait_backup() sometimes hungs X-Git-Tag: mdadm-3.2~193 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9376b5aac29d89ee5b2be1bb2ced84faf1b50415;p=thirdparty%2Fmdadm.git FIX: wait_backup() sometimes hungs 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 Signed-off-by: NeilBrown --- diff --git a/Grow.c b/Grow.c index 3322cf77..cf09a604 100644 --- 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) {