diff options
author | Adam Kwolek <adam.kwolek@intel.com> | 2011-09-21 04:17:30 +0200 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2011-09-21 04:17:30 +0200 |
commit | 3f54bd62dc26c9d9dd3398ad07ab8fbd5a55474d (patch) | |
tree | 654b1b9b0994396aa70021339d580144c2cd2290 /Assemble.c | |
parent | FIX: Memory leak during Assembly (diff) | |
download | mdadm-3f54bd62dc26c9d9dd3398ad07ab8fbd5a55474d.tar.xz mdadm-3f54bd62dc26c9d9dd3398ad07ab8fbd5a55474d.zip |
Move restore backup code to function
Reshape backup should be able to be restored during reshape continuation
also. To reuse already existing code it is moved to function.
Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'Assemble.c')
-rw-r--r-- | Assemble.c | 40 |
1 files changed, 3 insertions, 37 deletions
@@ -1555,44 +1555,10 @@ int assemble_container_content(struct supertype *st, int mdfd, if (content->reshape_active) { int spare = content->array.raid_disks + expansion; - int i; - int *fdlist = malloc(sizeof(int) * - (working + expansion - + content->array.raid_disks)); - for (i=0; i<spare; i++) - fdlist[i] = -1; - for (dev = content->devs; dev; dev = dev->next) { - char buf[20]; - int fd; - sprintf(buf, "%d:%d", - dev->disk.major, - dev->disk.minor); - fd = dev_open(buf, O_RDWR); - - if (dev->disk.raid_disk >= 0) - fdlist[dev->disk.raid_disk] = fd; - else - fdlist[spare++] = fd; - } - if (st->ss->external && st->ss->recover_backup) - err = st->ss->recover_backup(st, content); - else - err = Grow_restart(st, content, fdlist, spare, - backup_file, verbose > 0); - while (spare > 0) { - spare--; - if (fdlist[spare] >= 0) - close(fdlist[spare]); - } - free(fdlist); - if (err) { - fprintf(stderr, Name ": Failed to restore critical" - " section for reshape - sorry.\n"); - if (!backup_file) - fprintf(stderr, Name ": Possibly you need" - " to specify a --backup-file\n"); + if (restore_backup(st, content, + working, + spare, backup_file, verbose) == 1) return 1; - } err = Grow_continue(mdfd, st, content, backup_file); } else switch(content->array.level) { |