summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2012-10-09 13:54:59 +1100
committerNeilBrown <neilb@suse.de>2012-10-18 15:40:01 +1100
commitacf70766113f3cd1ee9d7c622c0ae7aea9a2e43d (patch)
treefe835c2d04fd19841fa6bf25d168524b4840c31a
parentc51f288b1045f55619bee69ae540a83bcdc00bfb (diff)
downloadmdadm-acf70766113f3cd1ee9d7c622c0ae7aea9a2e43d.tar.gz
Grow: allow --grow --continue to work for native metadata.
As it was the code would crash due to "mdstat" being NULL. Code is now more sane, but hasn't been tested on an array that needs to grow. Signed-off-by: NeilBrown <neilb@suse.de>
-rw-r--r--Grow.c41
1 files changed, 37 insertions, 4 deletions
diff --git a/Grow.c b/Grow.c
index 7a46e78..dbd4ae5 100644
--- a/Grow.c
+++ b/Grow.c
@@ -3993,15 +3993,49 @@ int Grow_continue_command(char *devname, int fd,
}
dprintf("Grow continue is run for ");
if (st->ss->external == 0) {
+ int d;
dprintf("native array (%s)\n", devname);
- if (ioctl(fd, GET_ARRAY_INFO, &array) < 0) {
+ if (ioctl(fd, GET_ARRAY_INFO, &array.array) < 0) {
fprintf(stderr, Name ": %s is not an active md array -"
" aborting\n", devname);
ret_val = 1;
goto Grow_continue_command_exit;
}
content = &array;
- sysfs_init(content, fd, st->devnum);
+ /* Need to load a superblock.
+ * FIXME we should really get what we need from
+ * sysfs
+ */
+ for (d = 0; d < MAX_DISKS; d++) {
+ mdu_disk_info_t disk;
+ char *dv;
+ int err;
+ disk.number = d;
+ if (ioctl(fd, GET_DISK_INFO, &disk) < 0)
+ continue;
+ if (disk.major == 0 && disk.minor == 0)
+ continue;
+ if ((disk.state & (1 << MD_DISK_ACTIVE)) == 0)
+ continue;
+ dv = map_dev(disk.major, disk.minor, 1);
+ if (!dv)
+ continue;
+ fd2 = dev_open(dv, O_RDONLY);
+ if (fd2 < 0)
+ continue;
+ err = st->ss->load_super(st, fd2, NULL);
+ close(fd2);
+ if (err)
+ continue;
+ break;
+ }
+ if (d == MAX_DISKS) {
+ fprintf(stderr, Name ": Unable to load metadata for %s\n",
+ devname);
+ ret_val = 1;
+ goto Grow_continue_command_exit;
+ }
+ st->ss->getinfo_super(st, content, NULL);
} else {
int container_dev;
@@ -4114,8 +4148,7 @@ int Grow_continue_command(char *devname, int fd,
/* verify that array under reshape is started from
* correct position
*/
- if (verify_reshape_position(content,
- map_name(pers, mdstat->level)) < 0) {
+ if (verify_reshape_position(content, content->array.level) < 0) {
ret_val = 1;
goto Grow_continue_command_exit;
}