From c4b26c643dd8dd4e897288345dad7ecbe318e243 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Tue, 21 May 2013 16:32:00 +1000 Subject: [PATCH] Grow: allow metadata to indicate that changing data_offset not supported. If space_after and space_before are zero (the default) then assume that metadata doesn't support changing data_offset. Signed-off-by: NeilBrown --- Grow.c | 5 +++++ super1.c | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/Grow.c b/Grow.c index 24bf6a9..3bd0b3e 100644 --- a/Grow.c +++ b/Grow.c @@ -2179,6 +2179,11 @@ static int set_new_data_offset(struct mdinfo *sra, struct supertype *st, st2->ss->getinfo_super(st2, &info2, NULL); st2->ss->free_super(st2); free(st2); + if (info2.space_before == 0 && + info2.space_after == 0) { + /* Metadata doesn't support data_offset changes */ + return 1; + } if (delta_disks < 0) { /* Don't need any space as array is shrinking * just move data_offset up by min diff --git a/super1.c b/super1.c index 1ce2668..5331cac 100644 --- a/super1.c +++ b/super1.c @@ -953,6 +953,14 @@ static void getinfo_super1(struct supertype *st, struct mdinfo *info, char *map) info->space_before = 0; info->space_after = misc->device_size - data_size - info->data_offset; } + if (info->space_before == 0 && info->space_after == 0) { + /* It will look like we don't support data_offset changes, + * be we do - it's just that there is no room. + * A change that reduced the number of devices should + * still be allowed, so set the otherwise useless value of '1' + */ + info->space_after = 1; + } info->disk.raid_disk = -1; switch(role) {