]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Grow: allow metadata to indicate that changing data_offset not supported.
authorNeilBrown <neilb@suse.de>
Tue, 21 May 2013 06:32:00 +0000 (16:32 +1000)
committerNeilBrown <neilb@suse.de>
Wed, 22 May 2013 02:26:19 +0000 (12:26 +1000)
If space_after and space_before are zero (the default) then assume that
metadata doesn't support changing data_offset.

Signed-off-by: NeilBrown <neilb@suse.de>
Grow.c
super1.c

diff --git a/Grow.c b/Grow.c
index 24bf6a9b011b68a708d5a308cecd03cc083c9b91..3bd0b3edb55a7210e596c8639f968dc09e8c8fd0 100644 (file)
--- 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
index 1ce26683ac856edeff85ba442b3153b031865fe2..5331cac1a5b3da6fe1715242895129175a82566f 100644 (file)
--- 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) {