Clean up exit paths from reshape_array.
We only 'goto release' on error, but that branch contained handling for non-error conditions: reloading metadata. Obviously that doesn't work. So re-arrange the code to make it more of a straight line that is easier to follow and reload the metadata if that might be at all needed. Signed-off-by: NeilBrown <neilb@suse.de>
This commit is contained in:
parent
6b2d630c7d
commit
1cbc5680c8
65
Grow.c
65
Grow.c
|
@ -1962,6 +1962,30 @@ static int reshape_array(char *container, int fd, char *devname,
|
||||||
abort_reshape(sra);
|
abort_reshape(sra);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!st->ss->external &&
|
||||||
|
!(reshape.before.data_disks != reshape.after.data_disks
|
||||||
|
&& info->custom_array_size) &&
|
||||||
|
info->new_level == reshape.level &&
|
||||||
|
!forked) {
|
||||||
|
/* no need to wait for the reshape to finish as
|
||||||
|
* there is nothing more to do.
|
||||||
|
*/
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
wait_reshape(sra);
|
||||||
|
|
||||||
|
if (st->ss->external) {
|
||||||
|
/* Re-load the metadata as much could have changed */
|
||||||
|
int cfd = open_dev(st->container_dev);
|
||||||
|
if (cfd >= 0) {
|
||||||
|
ping_monitor(container);
|
||||||
|
st->ss->free_super(st);
|
||||||
|
st->ss->load_container(st, cfd, container);
|
||||||
|
close(cfd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* set new array size if required customer_array_size is used
|
/* set new array size if required customer_array_size is used
|
||||||
* by this metadata.
|
* by this metadata.
|
||||||
*/
|
*/
|
||||||
|
@ -1971,9 +1995,6 @@ static int reshape_array(char *container, int fd, char *devname,
|
||||||
struct mdinfo *info2;
|
struct mdinfo *info2;
|
||||||
char *subarray = strchr(info->text_version+1, '/')+1;
|
char *subarray = strchr(info->text_version+1, '/')+1;
|
||||||
|
|
||||||
wait_reshape(sra);
|
|
||||||
ping_monitor(container);
|
|
||||||
|
|
||||||
info2 = st->ss->container_content(st, subarray);
|
info2 = st->ss->container_content(st, subarray);
|
||||||
if (info2) {
|
if (info2) {
|
||||||
unsigned long long current_size = 0;
|
unsigned long long current_size = 0;
|
||||||
|
@ -2001,24 +2022,15 @@ static int reshape_array(char *container, int fd, char *devname,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info->new_level != reshape.level) {
|
if (info->new_level != reshape.level) {
|
||||||
/* We need to wait for the reshape to finish
|
|
||||||
* (which will have happened unless
|
|
||||||
* odata < ndata) and then set the level
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (reshape.before.data_disks <
|
|
||||||
reshape.after.data_disks)
|
|
||||||
wait_reshape(sra);
|
|
||||||
|
|
||||||
c = map_num(pers, info->new_level);
|
c = map_num(pers, info->new_level);
|
||||||
if (c == NULL)
|
if (c) {
|
||||||
goto out;/* not possible */
|
err = sysfs_set_str(sra, NULL, "level", c);
|
||||||
|
if (err)
|
||||||
err = sysfs_set_str(sra, NULL, "level", c);
|
fprintf(stderr, Name\
|
||||||
if (err)
|
": %s: could not set level "
|
||||||
fprintf(stderr, Name\
|
"to %s\n", devname, c);
|
||||||
": %s: could not set level "
|
}
|
||||||
"to %s\n", devname, c);
|
|
||||||
}
|
}
|
||||||
out:
|
out:
|
||||||
if (forked)
|
if (forked)
|
||||||
|
@ -2026,20 +2038,7 @@ out:
|
||||||
exit(0);
|
exit(0);
|
||||||
|
|
||||||
release:
|
release:
|
||||||
if (!rv) {
|
if (orig_level != UnSet && sra) {
|
||||||
if (container)
|
|
||||||
ping_monitor(container);
|
|
||||||
if (st->ss->external) {
|
|
||||||
/* Re-load the metadata as much could have changed */
|
|
||||||
int cfd = open_dev(st->container_dev);
|
|
||||||
if (cfd >= 0) {
|
|
||||||
st->ss->free_super(st);
|
|
||||||
st->ss->load_container(st, cfd, container);
|
|
||||||
close(cfd);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (rv && orig_level != UnSet && sra) {
|
|
||||||
c = map_num(pers, orig_level);
|
c = map_num(pers, orig_level);
|
||||||
if (c && sysfs_set_str(sra, NULL, "level", c) == 0)
|
if (c && sysfs_set_str(sra, NULL, "level", c) == 0)
|
||||||
fprintf(stderr, Name ": aborting level change\n");
|
fprintf(stderr, Name ": aborting level change\n");
|
||||||
|
|
Loading…
Reference in New Issue