summaryrefslogtreecommitdiff
path: root/Grow.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2011-12-23 06:59:48 +1100
committerNeilBrown <neilb@suse.de>2011-12-23 06:59:48 +1100
commitce4783d3d60af3b89e4d06a6948a972d3e1c87cd (patch)
treebe047470a6d99b9d7e0fc6eb1f0047c92b338415 /Grow.c
parent27a1e5b5a48d89feffb49ceab94e1ac764258f79 (diff)
Grow: fix reshape-array for shrinking reshapes.
The value in info->array.raid_disks is the total number of devices, which is the 'after' number when the number is increasing, and the 'before' number when the number is decreasing. The code currently assumes it is always the 'after' number - so fix that. Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'Grow.c')
-rw-r--r--Grow.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/Grow.c b/Grow.c
index cda78028..e9867c8c 100644
--- a/Grow.c
+++ b/Grow.c
@@ -1891,10 +1891,12 @@ static int reshape_array(char *container, int fd, char *devname,
if (info->reshape_active) {
int new_level = info->new_level;
info->new_level = UnSet;
- info->array.raid_disks -= info->delta_disks;
+ if (info->delta_disks > 0)
+ info->array.raid_disks -= info->delta_disks;
msg = analyse_change(info, &reshape);
info->new_level = new_level;
- info->array.raid_disks += info->delta_disks;
+ if (info->delta_disks > 0)
+ info->array.raid_disks += info->delta_disks;
if (!restart)
/* Make sure the array isn't read-only */
ioctl(fd, RESTART_ARRAY_RW, 0);
@@ -1908,7 +1910,7 @@ static int reshape_array(char *container, int fd, char *devname,
(reshape.level != info->array.level ||
reshape.before.layout != info->array.layout ||
reshape.before.data_disks + reshape.parity
- != info->array.raid_disks - info->delta_disks)) {
+ != info->array.raid_disks - max(0, info->delta_disks))) {
fprintf(stderr, Name ": reshape info is not in native format -"
" cannot continue.\n");
goto release;