diff options
author | NeilBrown <neilb@suse.de> | 2013-07-09 11:46:54 +1000 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2013-07-10 16:28:25 +1000 |
commit | 3afaff930c4840911ebf114f43fdd5d93c07af1f (patch) | |
tree | 19c504e205f2f1c873160b9099b72ba5789f1b76 /Manage.c | |
parent | a7a0d8a116c11b2208e70fd4dcc8ab920e472b8b (diff) |
Stop: fix up synchronising end of reshape to good boundary.
If we stop too soon after reshape starts (probably only during
testing), we can get confused by the status of the reshape.
If that might be happening - sleep a bit longer.
Also allow for reshape going unusually slowly (again, probably only
during testing).
Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'Manage.c')
-rw-r--r-- | Manage.c | 22 |
1 files changed, 17 insertions, 5 deletions
@@ -400,16 +400,28 @@ int Manage_stop(char *devname, int fd, int verbose, int will_retry) sysfs_set_str(mdi, NULL, "sync_action", "idle"); /* That should have set things going again. Now we - * wait a little while (1 second max) for sync_completed + * wait a little while (3 second max) for sync_completed * to reach the target. + * The reshape process can block for 500msec if + * the sync speed limit is hit, so we need to wait + * a lot longer than that. 1 second is usually + * enough. 3 is safe. */ - delay = 1000; + delay = 3000; scfd = sysfs_open(mdi->sys_name, NULL, "sync_completed"); - while (scfd >= 0 && delay > 0) { + while (scfd >= 0 && delay > 0 && old_sync_max > 0) { sysfs_get_ll(mdi, NULL, "reshape_position", &curr); sysfs_fd_get_str(scfd, buf, sizeof(buf)); - if (strncmp(buf, "none", 4) == 0) - break; + if (strncmp(buf, "none", 4) == 0) { + /* Either reshape has aborted, or hasn't + * quite started yet. Wait a bit and + * check 'sync_action' to see. + */ + usleep(10000); + sysfs_get_str(mdi, NULL, "sync_action", buf, sizeof(buf)); + if (strncmp(buf, "reshape", 7) != 0) + break; + } if (sysfs_fd_get_ll(scfd, &completed) == 0 && (completed > sync_max || |