summaryrefslogtreecommitdiff
path: root/Grow.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2013-05-22 12:17:32 +1000
committerNeilBrown <neilb@suse.de>2013-05-22 12:20:39 +1000
commit89ecd3cfe41685cf260ed8f53ff95e2f0ad625cb (patch)
tree728c3e13e277e32f6b69caebc69ab8bb56e6f592 /Grow.c
parent6b2fc3c162a4a9d6bd332aeddeb4ca9a8ba90ad0 (diff)
Grow: introduce min_offset_change to struct reshape.
raid10 currently uses the 'backup_blocks' field to store something else: a minimum offset change. This is bad practice, we will shortly need to have both for RAID5/6, so make a separate field. Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'Grow.c')
-rw-r--r--Grow.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/Grow.c b/Grow.c
index 47496cd4..4c4cad3a 100644
--- a/Grow.c
+++ b/Grow.c
@@ -1128,19 +1128,21 @@ char *analyse_change(struct mdinfo *info, struct reshape *re)
re->before.data_disks = info->array.raid_disks;
re->after.layout = info->new_layout;
re->after.data_disks = new_disks;
- /* For RAID10 we don't do backup, and there is
- * no need to synchronise stripes on both
+ /* For RAID10 we don't do backup but do allow reshape,
+ * so set backup_blocks to INVALID_SECTORS rather than
+ * zero.
+ * And there is no need to synchronise stripes on both
* 'old' and 'new'. So the important
* number is the minimum data_offset difference
* which is the larger of (offset copies * chunk).
*/
-
- re->backup_blocks = max(old_chunk, new_chunk) / 512;
+ re->backup_blocks = INVALID_SECTORS;
+ re->min_offset_change = max(old_chunk, new_chunk) / 512;
if (new_disks < re->before.data_disks &&
- info->space_after < re->backup_blocks)
+ info->space_after < re->min_offset_change)
/* Reduce component size by one chunk */
re->new_size = (info->component_size -
- re->backup_blocks);
+ re->min_offset_change);
else
re->new_size = info->component_size;
re->new_size = re->new_size * new_disks / copies;
@@ -2303,15 +2305,15 @@ static int raid10_reshape(char *container, int fd, char *devname,
/* Changing raid_disks, layout, chunksize or possibly
* just data_offset for a RAID10.
* We must always change data_offset. We change by at least
- * ->backup_blocks which is the largest of the old and new
+ * ->min_offset_change which is the largest of the old and new
* chunk sizes.
* If raid_disks is increasing, then data_offset must decrease
* by at least this copy size.
* If raid_disks is unchanged, data_offset must increase or
- * decrease by at least backup_blocks but preferably by much more.
+ * decrease by at least min_offset_change but preferably by much more.
* We choose half of the available space.
* If raid_disks is decreasing, data_offset must increase by
- * at least backup_blocks. To allow of this, component_size
+ * at least min_offset_change. To allow of this, component_size
* must be decreased by the same amount.
*
* So we calculate the required minimum and direction, possibly
@@ -2332,16 +2334,16 @@ static int raid10_reshape(char *container, int fd, char *devname,
devname);
goto release;
}
- min = reshape->backup_blocks;
+ min = reshape->min_offset_change;
if (info->delta_disks)
sysfs_set_str(sra, NULL, "reshape_direction",
info->delta_disks < 0 ? "backwards" : "forwards");
if (info->delta_disks < 0 &&
- info->space_after < reshape->backup_blocks) {
+ info->space_after < min) {
int rv = sysfs_set_num(sra, NULL, "component_size",
(sra->component_size -
- reshape->backup_blocks)/2);
+ min)/2);
if (rv) {
pr_err("cannot reduce component size\n");
goto release;