]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - Grow.c
Grow: Allow for component_size not being set for RAID0 arrays.
[thirdparty/mdadm.git] / Grow.c
diff --git a/Grow.c b/Grow.c
index d596c2de7a7df6bd9ebe0eafdb3e55c365f66f9b..812c1da9e997c3c0f3dda704f98e55e7e5f8ecdf 100644 (file)
--- a/Grow.c
+++ b/Grow.c
@@ -1649,6 +1649,18 @@ static int reshape_array(char *container, int fd, char *devname,
        int done;
        struct mdinfo *sra = NULL;
 
+       /* when reshaping a RAID0, the component_size might be zero.
+        * So try to fix that up.
+        */
+       if (ioctl(fd, GET_ARRAY_INFO, &array) != 0) {
+               dprintf("Cannot get array information.\n");
+               goto release;
+       }
+       if (array.level == 0 && info->component_size == 0) {
+               get_dev_size(fd, NULL, &array_size);
+               info->component_size = array_size / array.raid_disks;
+       }
+
        if (info->reshape_active) {
                int new_level = info->new_level;
                info->new_level = UnSet;
@@ -1671,10 +1683,6 @@ static int reshape_array(char *container, int fd, char *devname,
                        " cannot continue.\n");
                goto release;
        }
-       if (ioctl(fd, GET_ARRAY_INFO, &array) != 0) {
-               dprintf("Cannot get array information.\n");
-               goto release;
-       }
 
        if (restart) {
                /* reshape already started. just skip to monitoring the reshape */