summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2011-03-10 15:00:38 +1100
committerNeilBrown <neilb@suse.de>2011-03-10 15:00:38 +1100
commit9468aeac5704bd01d6fd334a0b1c018deb7bf238 (patch)
tree19caea12d9bf7cfbba5e1b2379e4da7deafb21f8
parentd424212ed9c8d1ff95dca3c35177560baddf6a77 (diff)
downloadmdadm-9468aeac5704bd01d6fd334a0b1c018deb7bf238.tar.gz
Grow: Allow for component_size not being set for RAID0 arrays.
When an RAID0 is started using SET_ARRAY_INFO ioctl the component_size will be zero. This confused the code for reshaping a RAID0 via RAID4. So if that seems to be the case, fake a believable component_size Signed-off-by: NeilBrown <neilb@suse.de>
-rw-r--r--Grow.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/Grow.c b/Grow.c
index d596c2d..812c1da 100644
--- 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 */