From abedf5fc46da5ac25454cad6aab86e1654726720 Mon Sep 17 00:00:00 2001 From: Krzysztof Wojcik Date: Tue, 25 Jan 2011 17:44:10 +1100 Subject: [PATCH] raid0->raid10 takeover- allocate memory for added disks Allocate memory will be used in process_update. For raid0->raid10 takeover operation number of disks doubles so we should allocate memory for additional disks and one imsm_dev structure with extended order table. Signed-off-by: Krzysztof Wojcik Signed-off-by: NeilBrown --- super-intel.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/super-intel.c b/super-intel.c index dd3acebf..8a3fe7fc 100644 --- a/super-intel.c +++ b/super-intel.c @@ -6189,6 +6189,53 @@ static void imsm_prepare_update(struct supertype *st, size_t len = 0; switch (type) { + case update_takeover: { + struct imsm_update_takeover *u = (void *)update->buf; + if (u->direction == R0_TO_R10) { + void **tail = (void **)&update->space_list; + struct imsm_dev *dev = get_imsm_dev(super, u->subarray); + struct imsm_map *map = get_imsm_map(dev, 0); + int num_members = map->num_members; + void *space; + int size, i; + int err = 0; + /* allocate memory for added disks */ + for (i = 0; i < num_members; i++) { + size = sizeof(struct dl); + space = malloc(size); + if (!space) { + err++; + break; + } + *tail = space; + tail = space; + *tail = NULL; + } + /* allocate memory for new device */ + size = sizeof_imsm_dev(super->devlist->dev, 0) + + (num_members * sizeof(__u32)); + space = malloc(size); + if (!space) + err++; + else { + *tail = space; + tail = space; + *tail = NULL; + } + if (!err) { + len = disks_to_mpb_size(num_members * 2); + } else { + /* if allocation didn't success, free buffer */ + while (update->space_list) { + void **sp = update->space_list; + update->space_list = *sp; + free(sp); + } + } + } + + break; + } case update_reshape_container_disks: { /* Every raid device in the container is about to * gain some more devices, and we will enter a -- 2.39.2