imsm: FIX: wait_for_reshape_imsm() cleanup
This function needs to be corrected. It should check sysfs operations status and it should not interpret 0 reshape position special meaning. Unused input parameter is removed also. Signed-off-by: Adam Kwolek <adam.kwolek@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
This commit is contained in:
parent
b2c5943816
commit
ae9f01f89b
|
@ -8559,40 +8559,51 @@ exit_imsm_reshape_super:
|
||||||
* reshape process reach new position
|
* reshape process reach new position
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* sra : general array info
|
* sra : general array info
|
||||||
* to_complete : new sync_max position
|
|
||||||
* ndata : number of disks in new array's layout
|
* ndata : number of disks in new array's layout
|
||||||
* Returns:
|
* Returns:
|
||||||
* 0 : success,
|
* 0 : success,
|
||||||
* 1 : there is no reshape in progress,
|
* 1 : there is no reshape in progress,
|
||||||
* -1 : fail
|
* -1 : fail
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
int wait_for_reshape_imsm(struct mdinfo *sra, unsigned long long to_complete,
|
int wait_for_reshape_imsm(struct mdinfo *sra, int ndata)
|
||||||
int ndata)
|
|
||||||
{
|
{
|
||||||
int fd = sysfs_get_fd(sra, NULL, "reshape_position");
|
int fd = sysfs_get_fd(sra, NULL, "reshape_position");
|
||||||
unsigned long long completed;
|
unsigned long long completed;
|
||||||
|
/* to_complete : new sync_max position */
|
||||||
|
unsigned long long to_complete = sra->reshape_progress;
|
||||||
|
unsigned long long position_to_set = to_complete / ndata;
|
||||||
|
|
||||||
struct timeval timeout;
|
struct timeval timeout;
|
||||||
|
|
||||||
if (fd < 0)
|
if (fd < 0) {
|
||||||
|
dprintf("imsm: wait_for_reshape_imsm() "
|
||||||
|
"cannot open reshape_position\n");
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
sysfs_fd_get_ll(fd, &completed);
|
if (sysfs_fd_get_ll(fd, &completed) < 0) {
|
||||||
|
dprintf("imsm: wait_for_reshape_imsm() "
|
||||||
|
"cannot read reshape_position (no reshape in progres)\n");
|
||||||
|
close(fd);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (to_complete == 0) {/* reshape till the end of array */
|
|
||||||
sysfs_set_str(sra, NULL, "sync_max", "max");
|
|
||||||
to_complete = MaxSector;
|
|
||||||
} else {
|
|
||||||
if (completed > to_complete) {
|
if (completed > to_complete) {
|
||||||
|
dprintf("imsm: wait_for_reshape_imsm() "
|
||||||
|
"wrong next position to set %llu (%llu)\n",
|
||||||
|
to_complete, completed);
|
||||||
close(fd);
|
close(fd);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
dprintf("Position set: %llu\n", position_to_set);
|
||||||
if (sysfs_set_num(sra, NULL, "sync_max",
|
if (sysfs_set_num(sra, NULL, "sync_max",
|
||||||
to_complete / ndata) != 0) {
|
position_to_set) != 0) {
|
||||||
|
dprintf("imsm: wait_for_reshape_imsm() "
|
||||||
|
"cannot set reshape position to %llu\n",
|
||||||
|
position_to_set);
|
||||||
close(fd);
|
close(fd);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* FIXME should not need a timeout at all */
|
/* FIXME should not need a timeout at all */
|
||||||
timeout.tv_sec = 30;
|
timeout.tv_sec = 30;
|
||||||
|
@ -8604,6 +8615,8 @@ int wait_for_reshape_imsm(struct mdinfo *sra, unsigned long long to_complete,
|
||||||
FD_SET(fd, &rfds);
|
FD_SET(fd, &rfds);
|
||||||
select(fd+1, NULL, NULL, &rfds, &timeout);
|
select(fd+1, NULL, NULL, &rfds, &timeout);
|
||||||
if (sysfs_fd_get_ll(fd, &completed) < 0) {
|
if (sysfs_fd_get_ll(fd, &completed) < 0) {
|
||||||
|
dprintf("imsm: wait_for_reshape_imsm() "
|
||||||
|
"cannot read reshape_position (in loop)\n");
|
||||||
close(fd);
|
close(fd);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -8853,15 +8866,14 @@ static int imsm_manage_reshape(
|
||||||
next_step = next_step + sra->reshape_progress;
|
next_step = next_step + sra->reshape_progress;
|
||||||
sysfs_set_num(sra, NULL, "suspend_lo", sra->reshape_progress);
|
sysfs_set_num(sra, NULL, "suspend_lo", sra->reshape_progress);
|
||||||
sysfs_set_num(sra, NULL, "suspend_hi", next_step);
|
sysfs_set_num(sra, NULL, "suspend_hi", next_step);
|
||||||
|
sra->reshape_progress = next_step;
|
||||||
|
|
||||||
/* wait until reshape finish */
|
/* wait until reshape finish */
|
||||||
if (wait_for_reshape_imsm(sra, next_step, ndata) < 0) {
|
if (wait_for_reshape_imsm(sra, ndata) < 0) {
|
||||||
dprintf("wait_for_reshape_imsm returned error!\n");
|
dprintf("wait_for_reshape_imsm returned error!\n");
|
||||||
goto abort;
|
goto abort;
|
||||||
}
|
}
|
||||||
|
|
||||||
sra->reshape_progress = next_step;
|
|
||||||
|
|
||||||
if (save_checkpoint_imsm(st, sra, UNIT_SRC_NORMAL) == 1) {
|
if (save_checkpoint_imsm(st, sra, UNIT_SRC_NORMAL) == 1) {
|
||||||
/* ignore error == 2, this can mean end of reshape here
|
/* ignore error == 2, this can mean end of reshape here
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue