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>
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);
action, 20) > 0 &&
strncmp(action, "reshape", 7) != 0)
break;
- } while (completed < offset + blocks);
+ }
close(fd);
if (part) {