If no-restriping needed, we might need to impose some more changes: layout, raid_disks, chunk_size but only for raid5 arrays. Move this part of code before operations connected with restriping. Signed-off-by: Krzysztof Wojcik <krzysztof.wojcik@xxxxxxxxx> --- Grow.c | 81 ++++++++++++++++++++++++++++++++++------------------------------ 1 files changed, 43 insertions(+), 38 deletions(-) diff --git a/Grow.c b/Grow.c index e1ec01c..0ce7c17 100644 --- a/Grow.c +++ b/Grow.c @@ -1656,6 +1656,49 @@ static int reshape_array(char *container, int cfd, int fd, char *devname, } ping_monitor(container); + if (reshape.backup_blocks == 0) { + /* No restriping needed, but we might need to impose + * some more changes: layout, raid_disks, chunk_size + */ + /* Changes possible only for raid5 arrays */ + if (info->array.level != 5) { + unfreeze(st); + return rv; + } + if (info->new_layout != UnSet && + info->new_layout != info->array.layout) { + info->array.layout = info->new_layout; + if (ioctl(fd, SET_ARRAY_INFO, &info->array) != 0) { + fprintf(stderr, Name ": failed to set new layout\n"); + rv = 1; + } else if (!quiet) + printf("layout for %s set to %d\n", + devname, info->array.layout); + } + if (info->delta_disks != UnSet && + info->delta_disks != 0) { + info->array.raid_disks += info->delta_disks; + if (ioctl(fd, SET_ARRAY_INFO, &info->array) != 0) { + fprintf(stderr, Name ": failed to set raid disks\n"); + rv = 1; + } else if (!quiet) + printf("raid_disks for %s set to %d\n", + devname, info->array.raid_disks); + } + if (info->new_chunk != 0 && + info->new_chunk != info->array.chunk_size) { + if (sysfs_set_num(info, NULL, + "chunk_size", info->new_chunk) != 0) { + fprintf(stderr, Name ": failed to set chunk size\n"); + rv = 1; + } else if (!quiet) + printf("chunk size for %s set to %d\n", + devname, info->array.chunk_size); + } + unfreeze(st); + return rv; + } + /* reload metadat as it is possible to change made by monitor */ if ((cfd >= 0) && @@ -1718,44 +1761,6 @@ static int reshape_array(char *container, int cfd, int fd, char *devname, } } - if (reshape.backup_blocks == 0) { - /* No restriping needed, but we might need to impose - * some more changes: layout, raid_disks, chunk_size - */ - if (info->new_layout != UnSet && - info->new_layout != info->array.layout) { - info->array.layout = info->new_layout; - if (ioctl(fd, SET_ARRAY_INFO, &info->array) != 0) { - fprintf(stderr, Name ": failed to set new layout\n"); - rv = 1; - } else if (!quiet) - printf("layout for %s set to %d\n", - devname, info->array.layout); - } - if (info->delta_disks != UnSet && - info->delta_disks != 0) { - info->array.raid_disks += info->delta_disks; - if (ioctl(fd, SET_ARRAY_INFO, &info->array) != 0) { - fprintf(stderr, Name ": failed to set raid disks\n"); - rv = 1; - } else if (!quiet) - printf("raid_disks for %s set to %d\n", - devname, info->array.raid_disks); - } - if (info->new_chunk != 0 && - info->new_chunk != info->array.chunk_size) { - if (sysfs_set_num(info, NULL, - "chunk_size", info->new_chunk) != 0) { - fprintf(stderr, Name ": failed to set chunk size\n"); - rv = 1; - } else if (!quiet) - printf("chunk size for %s set to %d\n", - devname, info->array.chunk_size); - } - unfreeze(st); - return rv; - } - /* * There are three possibilities. * 1/ The array will shrink. -- To unsubscribe from this list: send the line "unsubscribe linux-raid" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html