summaryrefslogtreecommitdiff
path: root/super-intel.c
diff options
context:
space:
mode:
authorAdam Kwolek <adam.kwolek@intel.com>2011-01-31 15:25:16 +0100
committerNeilBrown <neilb@suse.de>2011-02-01 10:31:27 +1100
commit401d313b7f48ab5c4eea9d151ab10244d2c8b227 (patch)
tree0f3b9fb45fd2c5749eec828fd36fb50c580c4a64 /super-intel.c
parent820eb8dba77b3b0aa7351aedf1af252a725d8f6f (diff)
imsm: FIX: mdmon crash during 2 raid0 arrays expansion
When expansion is run on 2 raid0 arrays in container no update is sent to mdmon because mdmon is off (mdadm performs update) Memory size for first reshaped array is allocated to satisfy memory requirements for expanded maps. Memory for second device is allocated using old disks number, as in metadata there is no information about this array reshape. When mdmon initiates second array reshape it overwrites internal structures and crashes). There is no place to keep expanded maps. To avoid this situation during loading metadata, allocated memory should be performed using the maximum used disks number in particular container. Signed-off-by: Adam Kwolek <adam.kwolek@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'super-intel.c')
-rw-r--r--super-intel.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/super-intel.c b/super-intel.c
index 0ab43552..bc3e48df 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -2471,6 +2471,7 @@ static int parse_raid_devices(struct intel_super *super)
int i;
struct imsm_dev *dev_new;
size_t len, len_migr;
+ size_t max_len = 0;
size_t space_needed = 0;
struct imsm_super *mpb = super->anchor;
@@ -2486,7 +2487,11 @@ static int parse_raid_devices(struct intel_super *super)
dv = malloc(sizeof(*dv));
if (!dv)
return 1;
- dev_new = malloc(len_migr);
+ if (max_len < len_migr)
+ max_len = len_migr;
+ if (max_len > len_migr)
+ space_needed += max_len - len_migr;
+ dev_new = malloc(max_len);
if (!dev_new) {
free(dv);
return 1;