summaryrefslogtreecommitdiff
path: root/Grow.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2011-12-23 06:59:45 +1100
committerNeilBrown <neilb@suse.de>2011-12-23 06:59:45 +1100
commit27a1e5b5a48d89feffb49ceab94e1ac764258f79 (patch)
tree62fde29522029740db6f1ce1906b31ee10e07d77 /Grow.c
parent0b50d3359a66aaface15af2471227560d7707f3b (diff)
Grow: fix start_reshape for shrinking arrays.
When an array is being reshaped to fewer data devices the relationship between sync_max and reshape_progress is different to when the number of devices increases - we need to allow for that when setting sync_max/sync_min. Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'Grow.c')
-rw-r--r--Grow.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/Grow.c b/Grow.c
index 28f82b10..cda78028 100644
--- a/Grow.c
+++ b/Grow.c
@@ -698,7 +698,8 @@ static int subarray_set_num(char *container, struct mdinfo *sra, char *name, int
return rc;
}
-int start_reshape(struct mdinfo *sra, int already_running, int data_disks)
+int start_reshape(struct mdinfo *sra, int already_running,
+ int before_data_disks, int data_disks)
{
int err;
unsigned long long sync_max_to_set;
@@ -707,7 +708,11 @@ int start_reshape(struct mdinfo *sra, int already_running, int data_disks)
err = sysfs_set_num(sra, NULL, "suspend_hi", sra->reshape_progress);
err = err ?: sysfs_set_num(sra, NULL, "suspend_lo",
sra->reshape_progress);
- sync_max_to_set = sra->reshape_progress / data_disks;
+ if (before_data_disks <= data_disks)
+ sync_max_to_set = sra->reshape_progress / data_disks;
+ else
+ sync_max_to_set = (sra->component_size * data_disks
+ - sra->reshape_progress) / data_disks;
if (!already_running)
sysfs_set_num(sra, NULL, "sync_min", sync_max_to_set);
err = err ?: sysfs_set_num(sra, NULL, "sync_max", sync_max_to_set);
@@ -2285,8 +2290,8 @@ started:
}
}
- err = start_reshape(sra, restart,
- info->array.raid_disks - reshape.parity);
+ err = start_reshape(sra, restart, reshape.before.data_disks,
+ reshape.after.data_disks);
if (err) {
fprintf(stderr,
Name ": Cannot %s reshape for %s\n",