unsigned index;
};
+struct intel_hba {
+ enum sys_dev_type type;
+ char *path;
+ char *pci_id;
+ struct intel_hba *next;
+};
+
enum action {
DISK_REMOVE = 1,
DISK_ADD
active */
struct dl *missing; /* disks removed while we weren't looking */
struct bbm_log *bbm_log;
- const char *hba; /* device path of the raid controller for this metadata */
+ struct intel_hba *hba; /* device path of the raid controller for this metadata */
const struct imsm_orom *orom; /* platform firmware support */
struct intel_super *next; /* (temp) list for disambiguating family_num */
};
unsigned long long start, size;
};
+/* definitions of reshape process types */
+enum imsm_reshape_type {
+ CH_TAKEOVER,
+ CH_MIGRATION,
+};
+
/* definition of messages passed to imsm_process_update */
enum imsm_update_type {
update_activate_spare,
update_rename_array,
update_add_remove_disk,
update_reshape_container_disks,
+ update_takeover
};
struct imsm_update_activate_spare {
int raid_disks;
};
+enum takeover_direction {
+ R10_TO_R0,
+ R0_TO_R10
+};
+struct imsm_update_takeover {
+ enum imsm_update_type type;
+ int subarray;
+ enum takeover_direction direction;
+};
struct imsm_update_reshape {
enum imsm_update_type type;
enum imsm_update_type type;
};
+
+static const char *_sys_dev_type[] = {
+ [SYS_DEV_UNKNOWN] = "Unknown",
+ [SYS_DEV_SAS] = "SAS",
+ [SYS_DEV_SATA] = "SATA"
+};
+
+const char *get_sys_dev_type(enum sys_dev_type type)
+{
+ if (type >= SYS_DEV_MAX)
+ type = SYS_DEV_UNKNOWN;
+
+ return _sys_dev_type[type];
+}
+
+#ifndef MDASSEMBLE
+static struct intel_hba * alloc_intel_hba(struct sys_dev *device)
+{
+ struct intel_hba *result = malloc(sizeof(*result));
+ if (result) {
+ result->type = device->type;
+ result->path = strdup(device->path);
+ result->next = NULL;
+ if (result->path && (result->pci_id = strrchr(result->path, '/')) != NULL)
+ result->pci_id++;
+ }
+ return result;
+}
+
+static struct intel_hba * find_intel_hba(struct intel_hba *hba, struct sys_dev *device)
+{
+ struct intel_hba *result=NULL;
+ for (result = hba; result; result = result->next) {
+ if (result->type == device->type && strcmp(result->path, device->path) == 0)
+ break;
+ }
+ return result;
+}
+
+
+static int attach_hba_to_super(struct intel_super *super, struct sys_dev *device)
+{
+ struct intel_hba *hba;
+
+ /* check if disk attached to Intel HBA */
+ hba = find_intel_hba(super->hba, device);
+ if (hba != NULL)
+ return 1;
+ /* Check if HBA is already attached to super */
+ if (super->hba == NULL) {
+ super->hba = alloc_intel_hba(device);
+ return 1;
+ }
+
+ hba = super->hba;
+ /* Intel metadata allows for all disks attached to the same type HBA.
+ * Do not sypport odf HBA types mixing
+ */
+ if (device->type != hba->type)
+ return 2;
+
+ while (hba->next)
+ hba = hba->next;
+
+ hba->next = alloc_intel_hba(device);
+ return 1;
+}
+
+static struct sys_dev* find_disk_attached_hba(int fd, const char *devname)
+{
+ struct sys_dev *list, *elem, *prev;
+ char *disk_path;
+
+ if ((list = find_intel_devices()) == NULL)
+ return 0;
+
+ if (fd < 0)
+ disk_path = (char *) devname;
+ else
+ disk_path = diskfd_to_devpath(fd);
+
+ if (!disk_path) {
+ free_sys_dev(&list);
+ return 0;
+ }
+
+ for (prev = NULL, elem = list; elem; prev = elem, elem = elem->next) {
+ if (path_attached_to_hba(disk_path, elem->path)) {
+ if (prev == NULL)
+ list = list->next;
+ else
+ prev->next = elem->next;
+ elem->next = NULL;
+ if (disk_path != devname)
+ free(disk_path);
+ free_sys_dev(&list);
+ return elem;
+ }
+ }
+ if (disk_path != devname)
+ free(disk_path);
+ free_sys_dev(&list);
+
+ return NULL;
+}
+#endif /* MDASSEMBLE */
+
+
static struct supertype *match_metadata_desc_imsm(char *arg)
{
struct supertype *st;
struct imsm_map *get_imsm_map(struct imsm_dev *dev, int second_map)
{
+ /* A device can have 2 maps if it is in the middle of a migration.
+ * If second_map is:
+ * 0 - we return the first map
+ * 1 - we return the second map if it exists, else NULL
+ * -1 - we return the second map if it exists, else the first
+ */
struct imsm_map *map = &dev->vol.map[0];
- if (second_map && !dev->vol.migr_state)
+ if (second_map == 1 && !dev->vol.migr_state)
return NULL;
- else if (second_map) {
+ else if (second_map == 1 ||
+ (second_map < 0 && dev->vol.migr_state)) {
void *ptr = map;
return ptr + sizeof_imsm_map(map);
} else
return map;
-
+
}
/* return the size of the device.
return NULL;
}
-static __u32 get_imsm_ord_tbl_ent(struct imsm_dev *dev, int slot)
+/*
+ * for second_map:
+ * == 0 get first map
+ * == 1 get second map
+ * == -1 than get map according to the current migr_state
+ */
+static __u32 get_imsm_ord_tbl_ent(struct imsm_dev *dev,
+ int slot,
+ int second_map)
{
struct imsm_map *map;
- if (dev->vol.migr_state)
- map = get_imsm_map(dev, 1);
- else
- map = get_imsm_map(dev, 0);
+ map = get_imsm_map(dev, second_map);
/* top byte identifies disk under rebuild */
return __le32_to_cpu(map->disk_ord_tbl[slot]);
}
#define ord_to_idx(ord) (((ord) << 8) >> 8)
-static __u32 get_imsm_disk_idx(struct imsm_dev *dev, int slot)
+static __u32 get_imsm_disk_idx(struct imsm_dev *dev, int slot, int second_map)
{
- __u32 ord = get_imsm_ord_tbl_ent(dev, slot);
+ __u32 ord = get_imsm_ord_tbl_ent(dev, slot, second_map);
return ord_to_idx(ord);
}
__u64 sz;
int slot, i;
struct imsm_map *map = get_imsm_map(dev, 0);
+ struct imsm_map *map2 = get_imsm_map(dev, 1);
__u32 ord;
printf("\n");
printf("[%.16s]:\n", dev->volume);
printf(" UUID : %s\n", uuid);
- printf(" RAID Level : %d\n", get_imsm_raid_level(map));
- printf(" Members : %d\n", map->num_members);
+ printf(" RAID Level : %d", get_imsm_raid_level(map));
+ if (map2)
+ printf(" <-- %d", get_imsm_raid_level(map2));
+ printf("\n");
+ printf(" Members : %d", map->num_members);
+ if (map2)
+ printf(" <-- %d", map2->num_members);
+ printf("\n");
printf(" Slots : [");
for (i = 0; i < map->num_members; i++) {
- ord = get_imsm_ord_tbl_ent(dev, i);
+ ord = get_imsm_ord_tbl_ent(dev, i, 0);
printf("%s", ord & IMSM_ORD_REBUILD ? "_" : "U");
}
- printf("]\n");
+ printf("]");
+ if (map2) {
+ printf(" <-- [");
+ for (i = 0; i < map2->num_members; i++) {
+ ord = get_imsm_ord_tbl_ent(dev, i, 1);
+ printf("%s", ord & IMSM_ORD_REBUILD ? "_" : "U");
+ }
+ printf("]");
+ }
+ printf("\n");
+ printf(" Failed disk : ");
+ if (map->failed_disk_num == 0xff)
+ printf("none");
+ else
+ printf("%i", map->failed_disk_num);
+ printf("\n");
slot = get_imsm_disk_slot(map, disk_idx);
if (slot >= 0) {
- ord = get_imsm_ord_tbl_ent(dev, slot);
+ ord = get_imsm_ord_tbl_ent(dev, slot, -1);
printf(" This Slot : %d%s\n", slot,
ord & IMSM_ORD_REBUILD ? " (out-of-sync)" : "");
} else
__le32_to_cpu(map->pba_of_lba0));
printf(" Num Stripes : %u\n",
__le32_to_cpu(map->num_data_stripes));
- printf(" Chunk Size : %u KiB\n",
+ printf(" Chunk Size : %u KiB",
__le16_to_cpu(map->blocks_per_strip) / 2);
+ if (map2)
+ printf(" <-- %u KiB",
+ __le16_to_cpu(map2->blocks_per_strip) / 2);
+ printf("\n");
printf(" Reserved : %d\n", __le32_to_cpu(dev->reserved_blocks));
printf(" Migrate State : ");
if (dev->vol.migr_state) {
static int imsm_read_serial(int fd, char *devname, __u8 *serial);
static void fd2devname(int fd, char *name);
-static int imsm_enumerate_ports(const char *hba_path, int port_count, int host_base, int verbose)
+static int ahci_enumerate_ports(const char *hba_path, int port_count, int host_base, int verbose)
{
- /* dump an unsorted list of devices attached to ahci, as well as
- * non-connected ports
+ /* dump an unsorted list of devices attached to AHCI Intel storage
+ * controller, as well as non-connected ports
*/
int hba_len = strlen(hba_path) + 1;
struct dirent *ent;
return err;
}
-static int detail_platform_imsm(int verbose, int enumerate_only)
+
+
+static void print_found_intel_controllers(struct sys_dev *elem)
+{
+ for (; elem; elem = elem->next) {
+ fprintf(stderr, Name ": found Intel(R) ");
+ if (elem->type == SYS_DEV_SATA)
+ fprintf(stderr, "SATA ");
+ else if (elem->type == SYS_DEV_SAS)
+ fprintf(stderr, "SAS ");
+ fprintf(stderr, "RAID controller");
+ if (elem->pci_id)
+ fprintf(stderr, " at %s", elem->pci_id);
+ fprintf(stderr, ".\n");
+ }
+ fflush(stderr);
+}
+
+static int ahci_get_port_count(const char *hba_path, int *port_count)
{
- /* There are two components to imsm platform support, the ahci SATA
- * controller and the option-rom. To find the SATA controller we
- * simply look in /sys/bus/pci/drivers/ahci to see if an ahci
- * controller with the Intel vendor id is present. This approach
- * allows mdadm to leverage the kernel's ahci detection logic, with the
- * caveat that if ahci.ko is not loaded mdadm will not be able to
- * detect platform raid capabilities. The option-rom resides in a
- * platform "Adapter ROM". We scan for its signature to retrieve the
- * platform capabilities. If raid support is disabled in the BIOS the
- * option-rom capability structure will not be available.
- */
- const struct imsm_orom *orom;
- struct sys_dev *list, *hba;
- DIR *dir;
struct dirent *ent;
- const char *hba_path;
- int host_base = 0;
- int port_count = 0;
+ DIR *dir;
+ int host_base = -1;
- if (enumerate_only) {
- if (check_env("IMSM_NO_PLATFORM") || find_imsm_orom())
- return 0;
- return 2;
- }
+ *port_count = 0;
+ if ((dir = opendir(hba_path)) == NULL)
+ return -1;
- list = find_driver_devices("pci", "ahci");
- for (hba = list; hba; hba = hba->next)
- if (devpath_to_vendor(hba->path) == 0x8086)
- break;
+ for (ent = readdir(dir); ent; ent = readdir(dir)) {
+ int host;
- if (!hba) {
- if (verbose)
- fprintf(stderr, Name ": unable to find active ahci controller\n");
- free_sys_dev(&list);
- return 2;
- } else if (verbose)
- fprintf(stderr, Name ": found Intel SATA AHCI Controller\n");
- hba_path = hba->path;
- hba->path = NULL;
- free_sys_dev(&list);
+ if (sscanf(ent->d_name, "host%d", &host) != 1)
+ continue;
+ if (*port_count == 0)
+ host_base = host;
+ else if (host < host_base)
+ host_base = host;
- orom = find_imsm_orom();
- if (!orom) {
- if (verbose)
- fprintf(stderr, Name ": imsm option-rom not found\n");
- return 2;
+ if (host + 1 > *port_count + host_base)
+ *port_count = host + 1 - host_base;
}
+ closedir(dir);
+ return host_base;
+}
+static void print_imsm_capability(const struct imsm_orom *orom)
+{
printf(" Platform : Intel(R) Matrix Storage Manager\n");
printf(" Version : %d.%d.%d.%d\n", orom->major_ver, orom->minor_ver,
orom->hotfix_ver, orom->build);
imsm_orom_has_chunk(orom, 1024*64) ? " 64M" : "");
printf(" Max Disks : %d\n", orom->tds);
printf(" Max Volumes : %d\n", orom->vpa);
- printf(" I/O Controller : %s\n", hba_path);
-
- /* find the smallest scsi host number to determine a port number base */
- dir = opendir(hba_path);
- for (ent = dir ? readdir(dir) : NULL; ent; ent = readdir(dir)) {
- int host;
-
- if (sscanf(ent->d_name, "host%d", &host) != 1)
- continue;
- if (port_count == 0)
- host_base = host;
- else if (host < host_base)
- host_base = host;
+ return;
+}
- if (host + 1 > port_count + host_base)
- port_count = host + 1 - host_base;
+static int detail_platform_imsm(int verbose, int enumerate_only)
+{
+ /* There are two components to imsm platform support, the ahci SATA
+ * controller and the option-rom. To find the SATA controller we
+ * simply look in /sys/bus/pci/drivers/ahci to see if an ahci
+ * controller with the Intel vendor id is present. This approach
+ * allows mdadm to leverage the kernel's ahci detection logic, with the
+ * caveat that if ahci.ko is not loaded mdadm will not be able to
+ * detect platform raid capabilities. The option-rom resides in a
+ * platform "Adapter ROM". We scan for its signature to retrieve the
+ * platform capabilities. If raid support is disabled in the BIOS the
+ * option-rom capability structure will not be available.
+ */
+ const struct imsm_orom *orom;
+ struct sys_dev *list, *hba;
+ int host_base = 0;
+ int port_count = 0;
+ int result=0;
+ if (enumerate_only) {
+ if (check_env("IMSM_NO_PLATFORM"))
+ return 0;
+ list = find_intel_devices();
+ if (!list)
+ return 2;
+ for (hba = list; hba; hba = hba->next) {
+ orom = find_imsm_capability(hba->type);
+ if (!orom) {
+ result = 2;
+ break;
+ }
+ }
+ free_sys_dev(&list);
+ return result;
}
- if (dir)
- closedir(dir);
- if (!port_count || imsm_enumerate_ports(hba_path, port_count,
- host_base, verbose) != 0) {
+ list = find_intel_devices();
+ if (!list) {
if (verbose)
- fprintf(stderr, Name ": failed to enumerate ports\n");
+ fprintf(stderr, Name ": no active Intel(R) RAID "
+ "controller found.\n");
+ free_sys_dev(&list);
return 2;
+ } else if (verbose)
+ print_found_intel_controllers(list);
+
+ for (hba = list; hba; hba = hba->next) {
+ orom = find_imsm_capability(hba->type);
+ if (!orom)
+ fprintf(stderr, Name ": imsm capabilities not found for controller: %s (type %s)\n",
+ hba->path, get_sys_dev_type(hba->type));
+ else
+ print_imsm_capability(orom);
}
- return 0;
+ for (hba = list; hba; hba = hba->next) {
+ printf(" I/O Controller : %s (%s)\n",
+ hba->path, get_sys_dev_type(hba->type));
+
+ if (hba->type == SYS_DEV_SATA) {
+ host_base = ahci_get_port_count(hba->path, &port_count);
+ if (ahci_enumerate_ports(hba->path, port_count, host_base, verbose)) {
+ if (verbose)
+ fprintf(stderr, Name ": failed to enumerate "
+ "ports on SATA controller at %s.", hba->pci_id);
+ result |= 2;
+ }
+ }
+ }
+
+ free_sys_dev(&list);
+ return result;
}
#endif
return num_stripes_per_unit_resync(dev);
}
-static __u8 imsm_num_data_members(struct imsm_dev *dev)
+static __u8 imsm_num_data_members(struct imsm_dev *dev, int second_map)
{
/* named 'imsm_' because raid0, raid1 and raid10
* counter-intuitively have the same number of data disks
*/
- struct imsm_map *map = get_imsm_map(dev, 0);
+ struct imsm_map *map = get_imsm_map(dev, second_map);
switch (get_imsm_raid_level(map)) {
case 0:
return 0;
switch (migr_type(dev)) {
+ case MIGR_GEN_MIGR:
case MIGR_VERIFY:
case MIGR_REPAIR:
case MIGR_INIT: {
*/
stripes_per_unit = num_stripes_per_unit_resync(dev);
migr_chunk = migr_strip_blocks_resync(dev);
- disks = imsm_num_data_members(dev);
+ disks = imsm_num_data_members(dev, 0);
blocks_per_unit = stripes_per_unit * migr_chunk * disks;
+ if (migr_type(dev) == MIGR_GEN_MIGR)
+ return blocks_per_unit;
stripe = __le32_to_cpu(map->blocks_per_strip) * disks;
segment = blocks_per_unit / stripe;
block_rel = blocks_per_unit - segment * stripe;
migr_chunk = migr_strip_blocks_rebuild(dev);
return migr_chunk * stripes_per_unit;
}
- case MIGR_GEN_MIGR:
- /* FIXME I need a number here */
case MIGR_STATE_CHANGE:
default:
return 0;
struct intel_super *super = st->sb;
struct imsm_dev *dev = get_imsm_dev(super, super->current_vol);
struct imsm_map *map = get_imsm_map(dev, 0);
+ struct imsm_map *prev_map = get_imsm_map(dev, 1);
+ struct imsm_map *map_to_analyse = map;
struct dl *dl;
char *devname;
int map_disks = info->array.raid_disks;
+ if (prev_map)
+ map_to_analyse = prev_map;
+
for (dl = super->disks; dl; dl = dl->next)
if (dl->raiddisk == info->disk.raid_disk)
break;
info->container_member = super->current_vol;
- info->array.raid_disks = map->num_members;
- info->array.level = get_imsm_raid_level(map);
+ info->array.raid_disks = map_to_analyse->num_members;
+ info->array.level = get_imsm_raid_level(map_to_analyse);
info->array.layout = imsm_level_to_layout(info->array.level);
info->array.md_minor = -1;
info->array.ctime = 0;
info->array.utime = 0;
- info->array.chunk_size = __le16_to_cpu(map->blocks_per_strip) << 9;
+ info->array.chunk_size =
+ __le16_to_cpu(map_to_analyse->blocks_per_strip) << 9;
info->array.state = !dev->vol.dirty;
info->custom_array_size = __le32_to_cpu(dev->size_high);
info->custom_array_size <<= 32;
info->custom_array_size |= __le32_to_cpu(dev->size_low);
-
+ if (prev_map && map->map_state == prev_map->map_state) {
+ info->reshape_active = 1;
+ info->new_level = get_imsm_raid_level(map);
+ info->new_layout = imsm_level_to_layout(info->new_level);
+ info->new_chunk = __le16_to_cpu(map->blocks_per_strip) << 9;
+ info->delta_disks = map->num_members - prev_map->num_members;
+ if (info->delta_disks) {
+ /* this needs to be applied to every array
+ * in the container.
+ */
+ info->reshape_active = 2;
+ }
+ /* We shape information that we give to md might have to be
+ * modify to cope with md's requirement for reshaping arrays.
+ * For example, when reshaping a RAID0, md requires it to be
+ * presented as a degraded RAID4.
+ * Also if a RAID0 is migrating to a RAID5 we need to specify
+ * the array as already being RAID5, but the 'before' layout
+ * is a RAID4-like layout.
+ */
+ switch (info->array.level) {
+ case 0:
+ switch(info->new_level) {
+ case 0:
+ /* conversion is happening as RAID4 */
+ info->array.level = 4;
+ info->array.raid_disks += 1;
+ break;
+ case 5:
+ /* conversion is happening as RAID5 */
+ info->array.level = 5;
+ info->array.layout = ALGORITHM_PARITY_N;
+ info->array.raid_disks += 1;
+ info->delta_disks -= 1;
+ break;
+ default:
+ /* FIXME error message */
+ info->array.level = UnSet;
+ break;
+ }
+ break;
+ }
+ } else {
+ info->new_level = UnSet;
+ info->new_layout = UnSet;
+ info->new_chunk = info->array.chunk_size;
+ info->delta_disks = 0;
+ }
info->disk.major = 0;
info->disk.minor = 0;
if (dl) {
info->disk.minor = dl->minor;
}
- info->data_offset = __le32_to_cpu(map->pba_of_lba0);
- info->component_size = __le32_to_cpu(map->blocks_per_member);
+ info->data_offset = __le32_to_cpu(map_to_analyse->pba_of_lba0);
+ info->component_size =
+ __le32_to_cpu(map_to_analyse->blocks_per_member);
memset(info->uuid, 0, sizeof(info->uuid));
info->recovery_start = MaxSector;
- info->reshape_active = 0;
- if (map->map_state == IMSM_T_STATE_UNINITIALIZED || dev->vol.dirty) {
+ info->reshape_progress = 0;
+ info->resync_start = MaxSector;
+ if (map_to_analyse->map_state == IMSM_T_STATE_UNINITIALIZED ||
+ dev->vol.dirty) {
info->resync_start = 0;
- } else if (dev->vol.migr_state) {
+ }
+ if (dev->vol.migr_state) {
switch (migr_type(dev)) {
case MIGR_REPAIR:
case MIGR_INIT: {
info->resync_start = blocks_per_unit * units;
break;
}
+ case MIGR_GEN_MIGR: {
+ __u64 blocks_per_unit = blocks_per_migr_unit(dev);
+ __u64 units = __le32_to_cpu(dev->vol.curr_migr_unit);
+ unsigned long long array_blocks;
+ int used_disks;
+
+ info->reshape_progress = blocks_per_unit * units;
+ dprintf("IMSM: General Migration checkpoint : %llu "
+ "(%llu) -> read reshape progress : %llu\n",
+ units, blocks_per_unit, info->reshape_progress);
+
+ used_disks = imsm_num_data_members(dev, 1);
+ if (used_disks > 0) {
+ array_blocks = map->blocks_per_member *
+ used_disks;
+ /* round array size down to closest MB
+ */
+ info->custom_array_size = (array_blocks
+ >> SECT_PER_MB_SHIFT)
+ << SECT_PER_MB_SHIFT;
+ }
+ }
case MIGR_VERIFY:
/* we could emulate the checkpointing of
* 'sync_action=check' migrations, but for now
*/
case MIGR_REBUILD:
/* this is handled by container_content_imsm() */
- case MIGR_GEN_MIGR:
case MIGR_STATE_CHANGE:
/* FIXME handle other migrations */
default:
/* we are not dirty, so... */
info->resync_start = MaxSector;
}
- } else
- info->resync_start = MaxSector;
+ }
strncpy(info->name, (char *) dev->volume, MAX_RAID_SERIAL_LEN);
info->name[MAX_RAID_SERIAL_LEN] = 0;
dmap[i] = 0;
if (i < info->array.raid_disks) {
struct imsm_disk *dsk;
- j = get_imsm_disk_idx(dev, i);
+ j = get_imsm_disk_idx(dev, i, -1);
dsk = get_imsm_disk(super, j);
if (dsk && (dsk->status & CONFIGURED_DISK))
dmap[i] = 1;
}
}
}
-}
-
-/* check the config file to see if we can return a real uuid for this spare */
-static void fixup_container_spare_uuid(struct mdinfo *inf)
-{
- struct mddev_ident *array_list;
-
- if (inf->array.level != LEVEL_CONTAINER ||
- memcmp(inf->uuid, uuid_match_any, sizeof(int[4])) != 0)
- return;
-
- array_list = conf_get_ident(NULL);
-
- for (; array_list; array_list = array_list->next) {
- if (array_list->uuid_set) {
- struct supertype *_sst; /* spare supertype */
- struct supertype *_cst; /* container supertype */
-
- _cst = array_list->st;
- if (_cst)
- _sst = _cst->ss->match_metadata_desc(inf->text_version);
- else
- _sst = NULL;
-
- if (_sst) {
- memcpy(inf->uuid, array_list->uuid, sizeof(int[4]));
- free(_sst);
- break;
- }
- }
- }
}
-
static __u8 imsm_check_degraded(struct intel_super *super, struct imsm_dev *dev, int failed);
static int imsm_count_failed(struct intel_super *super, struct imsm_dev *dev);
* (catches single-degraded vs double-degraded)
*/
for (j = 0; j < map->num_members; j++) {
- __u32 ord = get_imsm_ord_tbl_ent(dev, i);
+ __u32 ord = get_imsm_ord_tbl_ent(dev, i, -1);
__u32 idx = ord_to_idx(ord);
if (!(ord & IMSM_ORD_REBUILD) &&
*/
if (info->disk.state & (1 << MD_DISK_SYNC) || super->anchor->num_raid_devs)
uuid_from_super_imsm(st, info->uuid);
- else {
- memcpy(info->uuid, uuid_match_any, sizeof(int[4]));
- fixup_container_spare_uuid(info);
- }
+ else
+ memcpy(info->uuid, uuid_zero, sizeof(uuid_zero));
/* I don't know how to compute 'map' on imsm, so use safe default */
if (map) {
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;
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;
super->disks = d->next;
__free_imsm_disk(d);
}
+ while (super->disk_mgmt_list) {
+ d = super->disk_mgmt_list;
+ super->disk_mgmt_list = d->next;
+ __free_imsm_disk(d);
+ }
while (super->missing) {
d = super->missing;
super->missing = d->next;
/* free all the pieces hanging off of a super pointer */
static void __free_imsm(struct intel_super *super, int free_disks)
{
+ struct intel_hba *elem, *next;
+
if (super->buf) {
free(super->buf);
super->buf = NULL;
if (free_disks)
free_imsm_disks(super);
free_devlist(super);
- if (super->hba) {
- free((void *) super->hba);
- super->hba = NULL;
+ elem = super->hba;
+ while (elem) {
+ if (elem->path)
+ free((void *)elem->path);
+ next = elem->next;
+ free(elem);
+ elem = next;
}
+ super->hba = NULL;
}
static void free_imsm(struct intel_super *super)
super->create_offset = ~((__u32 ) 0);
if (!check_env("IMSM_NO_PLATFORM"))
super->orom = find_imsm_orom();
- if (super->orom && !check_env("IMSM_TEST_OROM")) {
- struct sys_dev *list, *ent;
-
- /* find the first intel ahci controller */
- list = find_driver_devices("pci", "ahci");
- for (ent = list; ent; ent = ent->next)
- if (devpath_to_vendor(ent->path) == 0x8086)
- break;
- if (ent) {
- super->hba = ent->path;
- ent->path = NULL;
- }
- free_sys_dev(&list);
- }
}
return super;
struct intel_super *super;
int rv;
-#ifndef MDASSEMBLE
- if (load_super_imsm_all(st, fd, &st->sb, devname) == 0)
- return 0;
-#endif
-
if (test_partition(fd))
/* IMSM not allowed on partitions */
return 1;
fprintf(stderr, Name ": failed to allocate device list entry\n");
return 0;
}
- dev = malloc(sizeof(*dev) + sizeof(__u32) * (info->raid_disks - 1));
+ dev = calloc(1, sizeof(*dev) + sizeof(__u32) * (info->raid_disks - 1));
if (!dev) {
free(dv);
fprintf(stderr, Name": could not allocate raid device\n");
return 0;
}
+
strncpy((char *) dev->volume, name, MAX_RAID_SERIAL_LEN);
if (info->level == 1)
array_blocks = info_to_blocks_per_member(info);
dev->size_low = __cpu_to_le32((__u32) array_blocks);
dev->size_high = __cpu_to_le32((__u32) (array_blocks >> 32));
- dev->status = __cpu_to_le32(0);
- dev->reserved_blocks = __cpu_to_le32(0);
+ dev->status = (DEV_READ_COALESCING | DEV_WRITE_COALESCING);
vol = &dev->vol;
vol->migr_state = 0;
set_migr_type(dev, MIGR_INIT);
/* Check the device has not already been added */
slot = get_imsm_disk_slot(map, dl->index);
if (slot >= 0 &&
- (get_imsm_ord_tbl_ent(dev, slot) & IMSM_ORD_REBUILD) == 0) {
+ (get_imsm_ord_tbl_ent(dev, slot, -1) & IMSM_ORD_REBUILD) == 0) {
fprintf(stderr, Name ": %s has been included in this array twice\n",
devname);
return 1;
return 0;
}
+
static int add_to_super_imsm(struct supertype *st, mdu_disk_info_t *dk,
- int fd, char *devname)
+ int fd, char *devname)
{
struct intel_super *super = st->sb;
struct dl *dd;
int rv;
struct stat stb;
- /* if we are on an RAID enabled platform check that the disk is
- * attached to the raid controller
+ /* If we are on an RAID enabled platform check that the disk is
+ * attached to the raid controller.
+ * We do not need to test disks attachment for container based additions,
+ * they shall be already tested when container was created/assembled.
*/
- if (super->hba && !disk_attached_to_hba(fd, super->hba)) {
- fprintf(stderr,
- Name ": %s is not attached to the raid controller: %s\n",
- devname ? : "disk", super->hba);
- return 1;
+ if ((fd != -1) && !check_env("IMSM_NO_PLATFORM")) {
+ struct sys_dev *hba_name;
+ struct intel_hba *hba;
+
+ hba_name = find_disk_attached_hba(fd, NULL);
+ if (!hba_name) {
+ fprintf(stderr,
+ Name ": %s is not attached to Intel(R) RAID controller.\n",
+ devname ? : "disk");
+ return 1;
+ }
+ rv = attach_hba_to_super(super, hba_name);
+ switch (rv) {
+ case 2:
+ fprintf(stderr, Name ": %s is attached to Intel(R) %s RAID "
+ "controller (%s),\n but the container is assigned to Intel(R) "
+ "%s RAID controller (",
+ devname,
+ get_sys_dev_type(hba_name->type),
+ hba_name->pci_id ? : "Err!",
+ get_sys_dev_type(hba_name->type));
+
+ hba = super->hba;
+ while (hba) {
+ fprintf(stderr, "%s", hba->pci_id ? : "Err!");
+ if (hba->next)
+ fprintf(stderr, ", ");
+ hba = hba->next;
+ }
+
+ fprintf(stderr, ").\n"
+ " Mixing devices attached to different controllers "
+ "is not allowed.\n");
+ free_sys_dev(&hba_name);
+ return 1;
+ }
+ free_sys_dev(&hba_name);
}
if (super->current_vol >= 0)
imsm_copy_dev(&u->dev, dev);
inf = get_disk_info(u);
for (i = 0; i < map->num_members; i++) {
- int idx = get_imsm_disk_idx(dev, i);
+ int idx = get_imsm_disk_idx(dev, i, -1);
disk = get_imsm_disk(super, idx);
serialcpy(inf[i].serial, disk->serial);
if (st->update_tail) {
/* queue the recently created array / added disk
* as a metadata update */
- struct dl *d;
int rv;
/* determine if we are creating a volume or adding a disk */
} else
rv = create_array(st, current_vol);
- for (d = super->disks; d ; d = d->next) {
- close(d->fd);
- d->fd = -1;
- }
-
return rv;
} else {
struct dl *d;
#define pr_vrb(fmt, arg...) (void) (verbose && fprintf(stderr, Name fmt, ##arg))
static int
validate_geometry_imsm_orom(struct intel_super *super, int level, int layout,
- int raiddisks, int chunk, int verbose)
+ int raiddisks, int *chunk, int verbose)
{
if (!is_raid_level_supported(super->orom, level, raiddisks)) {
pr_vrb(": platform does not support raid%d with %d disk%s\n",
level, raiddisks, raiddisks > 1 ? "s" : "");
return 0;
}
- if (super->orom && level != 1 &&
- !imsm_orom_has_chunk(super->orom, chunk)) {
- pr_vrb(": platform does not support a chunk size of: %d\n", chunk);
- return 0;
+ if (super->orom && level != 1) {
+ if (chunk && (*chunk == 0 || *chunk == UnSet))
+ *chunk = imsm_orom_default_chunk(super->orom);
+ else if (chunk && !imsm_orom_has_chunk(super->orom, *chunk)) {
+ pr_vrb(": platform does not support a chunk size of: "
+ "%d\n", *chunk);
+ return 0;
+ }
}
if (layout != imsm_level_to_layout(level)) {
if (level == 5)
* FIX ME add ahci details
*/
static int validate_geometry_imsm_volume(struct supertype *st, int level,
- int layout, int raiddisks, int chunk,
+ int layout, int raiddisks, int *chunk,
unsigned long long size, char *dev,
unsigned long long *freesize,
int verbose)
maxsize = merge_extents(super, extent_cnt);
minsize = size;
if (size == 0)
- minsize = chunk;
+ /* chunk is in K */
+ minsize = chunk * 2;
if (cnt < raiddisks ||
(super->orom && used && used != raiddisks) ||
if (size == 0) {
size = maxsize;
if (chunk) {
- size /= chunk;
- size *= chunk;
+ size /= 2 * chunk;
+ size *= 2 * chunk;
}
}
}
static int validate_geometry_imsm(struct supertype *st, int level, int layout,
- int raiddisks, int chunk, unsigned long long size,
+ int raiddisks, int *chunk, unsigned long long size,
char *dev, unsigned long long *freesize,
int verbose)
{
if (level == LEVEL_CONTAINER) {
/* Must be a fresh device to add to a container */
return validate_geometry_imsm_container(st, level, layout,
- raiddisks, chunk, size,
+ raiddisks,
+ chunk?*chunk:0, size,
dev, freesize,
verbose);
}
raiddisks, chunk,
verbose))
return 0;
- return reserve_space(st, raiddisks, size, chunk, freesize);
+ return reserve_space(st, raiddisks, size,
+ chunk?*chunk:0, freesize);
}
return 1;
}
return 0;
}
-#endif /* MDASSEMBLE */
static int is_gen_migration(struct imsm_dev *dev)
{
return 0;
}
+#endif /* MDASSEMBLE */
static int is_rebuilding(struct imsm_dev *dev)
{
struct imsm_super *mpb = super->anchor;
struct mdinfo *rest = NULL;
unsigned int i;
+ int bbm_errors = 0;
+ struct dl *d;
+ int spare_disks = 0;
- /* do not assemble arrays that might have bad blocks */
- if (imsm_bbm_log_size(super->anchor)) {
- fprintf(stderr, Name ": BBM log found in metadata. "
- "Cannot activate array(s).\n");
- return NULL;
- }
+ /* check for bad blocks */
+ if (imsm_bbm_log_size(super->anchor))
+ bbm_errors = 1;
+
+ /* count spare devices, not used in maps
+ */
+ for (d = super->disks; d; d = d->next)
+ if (d->index == -1)
+ spare_disks++;
for (i = 0; i < mpb->num_raid_devs; i++) {
struct imsm_dev *dev;
struct imsm_map *map;
+ struct imsm_map *map2;
struct mdinfo *this;
- int slot;
+ int slot, chunk;
char *ep;
if (subarray &&
dev = get_imsm_dev(super, i);
map = get_imsm_map(dev, 0);
+ map2 = get_imsm_map(dev, 1);
/* do not publish arrays that are in the middle of an
* unsupported migration
dev->volume);
continue;
}
+ /* do not publish arrays that are not support by controller's
+ * OROM/EFI
+ */
+ chunk = __le16_to_cpu(map->blocks_per_strip) >> 1;
+ if (!validate_geometry_imsm_orom(super,
+ get_imsm_raid_level(map), /* RAID level */
+ imsm_level_to_layout(get_imsm_raid_level(map)),
+ map->num_members, /* raid disks */
+ &chunk,
+ 1 /* verbose */)) {
+ fprintf(stderr, Name ": RAID gemetry validation failed. "
+ "Cannot proceed with the action(s).\n");
+ continue;
+ }
this = malloc(sizeof(*this));
if (!this) {
fprintf(stderr, Name ": failed to allocate %zu bytes\n",
__u32 ord;
skip = 0;
- idx = get_imsm_disk_idx(dev, slot);
- ord = get_imsm_ord_tbl_ent(dev, slot);
+ idx = get_imsm_disk_idx(dev, slot, 0);
+ ord = get_imsm_ord_tbl_ent(dev, slot, -1);
for (d = super->disks; d ; d = d->next)
if (d->index == idx)
break;
info_d->disk.minor = d->minor;
info_d->disk.raid_disk = slot;
info_d->recovery_start = recovery_start;
-
+ if (map2) {
+ if (slot < map2->num_members)
+ info_d->disk.state = (1 << MD_DISK_ACTIVE);
+ else
+ this->array.spare_disks++;
+ } else {
+ if (slot < map->num_members)
+ info_d->disk.state = (1 << MD_DISK_ACTIVE);
+ else
+ this->array.spare_disks++;
+ }
if (info_d->recovery_start == MaxSector)
this->array.working_disks++;
}
/* now that the disk list is up-to-date fixup recovery_start */
update_recovery_start(dev, this);
+ this->array.spare_disks += spare_disks;
rest = this;
}
+ /* if array has bad blocks, set suitable bit in array status */
+ if (bbm_errors)
+ rest->array.state |= (1<<MD_SB_BBM_ERRORS);
+
return rest;
}
int insync = insync;
for (i = 0; i < map->num_members; i++) {
- __u32 ord = get_imsm_ord_tbl_ent(dev, i);
+ __u32 ord = get_imsm_ord_tbl_ent(dev, i, -1);
int idx = ord_to_idx(ord);
struct imsm_disk *disk;
migr_type(dev) == MIGR_REPAIR)
return 1;
+ if (migr_type(dev) == MIGR_GEN_MIGR)
+ return 0;
+
migr_map = get_imsm_map(dev, 1);
- if (migr_map->map_state == IMSM_T_STATE_NORMAL)
+ if ((migr_map->map_state == IMSM_T_STATE_NORMAL) &&
+ (dev->vol.migr_type != MIGR_GEN_MIGR))
return 1;
else
return 0;
__u32 ord;
int slot;
struct imsm_map *map;
+ char buf[MAX_RAID_SERIAL_LEN+3];
+ unsigned int len, shift = 0;
/* new failures are always set in map[0] */
map = get_imsm_map(dev, 0);
if (is_failed(disk) && (ord & IMSM_ORD_REBUILD))
return 0;
+ sprintf(buf, "%s:0", disk->serial);
+ if ((len = strlen(buf)) >= MAX_RAID_SERIAL_LEN)
+ shift = len - MAX_RAID_SERIAL_LEN + 1;
+ strncpy((char *)disk->serial, &buf[shift], MAX_RAID_SERIAL_LEN);
+
disk->status |= FAILED_DISK;
- disk->status &= ~CONFIGURED_DISK;
set_imsm_ord_tbl_ent(map, slot, idx | IMSM_ORD_REBUILD);
if (map->failed_disk_num == 0xff)
map->failed_disk_num = slot;
super->updates_pending++;
}
+static unsigned long long imsm_set_array_size(struct imsm_dev *dev)
+{
+ int used_disks = imsm_num_data_members(dev, 0);
+ unsigned long long array_blocks;
+ struct imsm_map *map;
+
+ if (used_disks == 0) {
+ /* when problems occures
+ * return current array_blocks value
+ */
+ array_blocks = __le32_to_cpu(dev->size_high);
+ array_blocks = array_blocks << 32;
+ array_blocks += __le32_to_cpu(dev->size_low);
+
+ return array_blocks;
+ }
+
+ /* set array size in metadata
+ */
+ map = get_imsm_map(dev, 0);
+ array_blocks = map->blocks_per_member * used_disks;
+
+ /* round array size down to closest MB
+ */
+ array_blocks = (array_blocks >> SECT_PER_MB_SHIFT) << SECT_PER_MB_SHIFT;
+ dev->size_low = __cpu_to_le32((__u32)array_blocks);
+ dev->size_high = __cpu_to_le32((__u32)(array_blocks >> 32));
+
+ return array_blocks;
+}
+
static void imsm_set_disk(struct active_array *a, int n, int state);
+static void imsm_progress_container_reshape(struct intel_super *super)
+{
+ /* if no device has a migr_state, but some device has a
+ * different number of members than the previous device, start
+ * changing the number of devices in this device to match
+ * previous.
+ */
+ struct imsm_super *mpb = super->anchor;
+ int prev_disks = -1;
+ int i;
+ int copy_map_size;
+
+ for (i = 0; i < mpb->num_raid_devs; i++) {
+ struct imsm_dev *dev = get_imsm_dev(super, i);
+ struct imsm_map *map = get_imsm_map(dev, 0);
+ struct imsm_map *map2;
+ int prev_num_members;
+
+ if (dev->vol.migr_state)
+ return;
+
+ if (prev_disks == -1)
+ prev_disks = map->num_members;
+ if (prev_disks == map->num_members)
+ continue;
+
+ /* OK, this array needs to enter reshape mode.
+ * i.e it needs a migr_state
+ */
+
+ copy_map_size = sizeof_imsm_map(map);
+ prev_num_members = map->num_members;
+ map->num_members = prev_disks;
+ dev->vol.migr_state = 1;
+ dev->vol.curr_migr_unit = 0;
+ dev->vol.migr_type = MIGR_GEN_MIGR;
+ for (i = prev_num_members;
+ i < map->num_members; i++)
+ set_imsm_ord_tbl_ent(map, i, i);
+ map2 = get_imsm_map(dev, 1);
+ /* Copy the current map */
+ memcpy(map2, map, copy_map_size);
+ map2->num_members = prev_num_members;
+
+ imsm_set_array_size(dev);
+ super->updates_pending++;
+ }
+}
+
/* Handle dirty -> clean transititions, resync and reshape. Degraded and rebuild
* states are handled in imsm_set_disk() with one exception, when a
* resync is stopped due to a new failure this routine will set the
*/
if (a->curr_action == reshape) {
/* still reshaping, maybe update curr_migr_unit */
- long long blocks_per_unit = blocks_per_migr_unit(dev);
- long long unit = a->last_checkpoint;
- unit /= blocks_per_unit;
- if (unit > __le32_to_cpu(dev->vol.curr_migr_unit)) {
- dev->vol.curr_migr_unit = __cpu_to_le32(unit);
- super->updates_pending++;
- }
+ goto mark_checkpoint;
} else {
if (a->last_checkpoint == 0 && a->prev_action == reshape) {
/* for some reason we aborted the reshape.
if (a->last_checkpoint >= a->info.component_size) {
unsigned long long array_blocks;
int used_disks;
- /* it seems the reshape is all done */
- dev->vol.migr_state = 0;
- dev->vol.migr_type = 0;
- dev->vol.curr_migr_unit = 0;
+ struct mdinfo *mdi;
+
+ used_disks = imsm_num_data_members(dev, 0);
+ if (used_disks > 0) {
+ array_blocks =
+ map->blocks_per_member *
+ used_disks;
+ /* round array size down to closest MB
+ */
+ array_blocks = (array_blocks
+ >> SECT_PER_MB_SHIFT)
+ << SECT_PER_MB_SHIFT;
+ a->info.custom_array_size = array_blocks;
+ /* encourage manager to update array
+ * size
+ */
+
+ a->check_reshape = 1;
+ }
+ /* finalize online capacity expansion/reshape */
+ for (mdi = a->info.devs; mdi; mdi = mdi->next)
+ imsm_set_disk(a,
+ mdi->disk.raid_disk,
+ mdi->curr_state);
- used_disks = imsm_num_data_members(dev);
- array_blocks = map->blocks_per_member * used_disks;
- /* round array size down to closest MB */
- array_blocks = (array_blocks >> SECT_PER_MB_SHIFT)
- << SECT_PER_MB_SHIFT;
- dev->size_low = __cpu_to_le32((__u32) array_blocks);
- dev->size_high = __cpu_to_le32((__u32) (array_blocks >> 32));
- a->info.custom_array_size = array_blocks;
- a->check_reshape = 1; /* encourage manager to update
- * array size
- */
- super->updates_pending++;
- }
+ imsm_progress_container_reshape(super);
+ }
}
- return 0;
}
/* before we activate this array handle any missing disks */
super->updates_pending++;
}
+mark_checkpoint:
/* check if we can update curr_migr_unit from resync_start, recovery_start */
blocks_per_unit = blocks_per_migr_unit(dev);
if (blocks_per_unit) {
super->updates_pending++;
}
- /* finalize online capacity expansion/reshape */
- if ((a->curr_action != reshape) &&
- (a->prev_action == reshape)) {
- struct mdinfo *mdi;
-
- for (mdi = a->info.devs; mdi; mdi = mdi->next)
- imsm_set_disk(a, mdi->disk.raid_disk, mdi->curr_state);
- }
-
return consistent;
}
dprintf("imsm: set_disk %d:%x\n", n, state);
- ord = get_imsm_ord_tbl_ent(dev, n);
+ ord = get_imsm_ord_tbl_ent(dev, n, -1);
disk = get_imsm_disk(super, ord_to_idx(ord));
/* check for new failures */
static struct dl *imsm_readd(struct intel_super *super, int idx, struct active_array *a)
{
struct imsm_dev *dev = get_imsm_dev(super, a->info.container_member);
- int i = get_imsm_disk_idx(dev, idx);
+ int i = get_imsm_disk_idx(dev, idx, -1);
struct dl *dl;
for (dl = super->disks; dl; dl = dl->next)
struct mdinfo *additional_test_list)
{
struct imsm_dev *dev = get_imsm_dev(super, a->info.container_member);
- int idx = get_imsm_disk_idx(dev, slot);
+ int idx = get_imsm_disk_idx(dev, slot, -1);
struct imsm_super *mpb = super->anchor;
struct imsm_map *map;
unsigned long long pos;
* Check if failed disks are deleted from intel
* disk list or are marked to be deleted
*/
- idx = get_imsm_disk_idx(dev2, slot);
+ idx = get_imsm_disk_idx(dev2, slot, -1);
idisk = get_imsm_dl_disk(cont->sb, idx);
/*
* Do not rebuild the array if failed disks
/* No repair during migration */
return NULL;
+ if (a->info.array.level == 4)
+ /* No repair for takeovered array
+ * imsm doesn't support raid4
+ */
+ return NULL;
+
if (imsm_check_degraded(super, dev, failed) != IMSM_T_STATE_DEGRADED)
return NULL;
int j;
for (i = 0; i < map->num_members; i++) {
- disk = get_imsm_disk(super, get_imsm_disk_idx(dev, i));
+ disk = get_imsm_disk(super, get_imsm_disk_idx(dev, i, -1));
for (j = 0; j < new_map->num_members; j++)
if (serialcmp(disk->serial, inf[j].serial) == 0)
return 1;
return check_degraded;
}
+static int apply_reshape_container_disks_update(struct imsm_update_reshape *u,
+ struct intel_super *super,
+ void ***space_list)
+{
+ struct dl *new_disk;
+ struct intel_dev *id;
+ int i;
+ int delta_disks = u->new_raid_disks - u->old_raid_disks;
+ int disk_count = u->old_raid_disks;
+ void **tofree = NULL;
+ int devices_to_reshape = 1;
+ struct imsm_super *mpb = super->anchor;
+ int ret_val = 0;
+ unsigned int dev_id;
+
+ dprintf("imsm: apply_reshape_container_disks_update()\n");
+
+ /* enable spares to use in array */
+ for (i = 0; i < delta_disks; i++) {
+ new_disk = get_disk_super(super,
+ major(u->new_disks[i]),
+ minor(u->new_disks[i]));
+ dprintf("imsm: new disk for reshape is: %i:%i "
+ "(%p, index = %i)\n",
+ major(u->new_disks[i]), minor(u->new_disks[i]),
+ new_disk, new_disk->index);
+ if ((new_disk == NULL) ||
+ ((new_disk->index >= 0) &&
+ (new_disk->index < u->old_raid_disks)))
+ goto update_reshape_exit;
+ new_disk->index = disk_count++;
+ /* slot to fill in autolayout
+ */
+ new_disk->raiddisk = new_disk->index;
+ new_disk->disk.status |=
+ CONFIGURED_DISK;
+ new_disk->disk.status &= ~SPARE_DISK;
+ }
+
+ dprintf("imsm: volume set mpb->num_raid_devs = %i\n",
+ mpb->num_raid_devs);
+ /* manage changes in volume
+ */
+ for (dev_id = 0; dev_id < mpb->num_raid_devs; dev_id++) {
+ void **sp = *space_list;
+ struct imsm_dev *newdev;
+ struct imsm_map *newmap, *oldmap;
+
+ for (id = super->devlist ; id; id = id->next) {
+ if (id->index == dev_id)
+ break;
+ }
+ if (id == NULL)
+ break;
+ if (!sp)
+ continue;
+ *space_list = *sp;
+ newdev = (void*)sp;
+ /* Copy the dev, but not (all of) the map */
+ memcpy(newdev, id->dev, sizeof(*newdev));
+ oldmap = get_imsm_map(id->dev, 0);
+ newmap = get_imsm_map(newdev, 0);
+ /* Copy the current map */
+ memcpy(newmap, oldmap, sizeof_imsm_map(oldmap));
+ /* update one device only
+ */
+ if (devices_to_reshape) {
+ dprintf("imsm: modifying subdev: %i\n",
+ id->index);
+ devices_to_reshape--;
+ newdev->vol.migr_state = 1;
+ newdev->vol.curr_migr_unit = 0;
+ newdev->vol.migr_type = MIGR_GEN_MIGR;
+ newmap->num_members = u->new_raid_disks;
+ for (i = 0; i < delta_disks; i++) {
+ set_imsm_ord_tbl_ent(newmap,
+ u->old_raid_disks + i,
+ u->old_raid_disks + i);
+ }
+ /* New map is correct, now need to save old map
+ */
+ newmap = get_imsm_map(newdev, 1);
+ memcpy(newmap, oldmap, sizeof_imsm_map(oldmap));
+
+ imsm_set_array_size(newdev);
+ }
+
+ sp = (void **)id->dev;
+ id->dev = newdev;
+ *sp = tofree;
+ tofree = sp;
+ }
+ if (tofree)
+ *space_list = tofree;
+ ret_val = 1;
+
+update_reshape_exit:
+
+ return ret_val;
+}
+
+static int apply_takeover_update(struct imsm_update_takeover *u,
+ struct intel_super *super,
+ void ***space_list)
+{
+ struct imsm_dev *dev = NULL;
+ struct intel_dev *dv;
+ struct imsm_dev *dev_new;
+ struct imsm_map *map;
+ struct dl *dm, *du;
+ int i;
+
+ for (dv = super->devlist; dv; dv = dv->next)
+ if (dv->index == (unsigned int)u->subarray) {
+ dev = dv->dev;
+ break;
+ }
+
+ if (dev == NULL)
+ return 0;
+
+ map = get_imsm_map(dev, 0);
+
+ if (u->direction == R10_TO_R0) {
+ /* Number of failed disks must be half of initial disk number */
+ if (imsm_count_failed(super, dev) != (map->num_members / 2))
+ return 0;
+
+ /* iterate through devices to mark removed disks as spare */
+ for (dm = super->disks; dm; dm = dm->next) {
+ if (dm->disk.status & FAILED_DISK) {
+ int idx = dm->index;
+ /* update indexes on the disk list */
+/* FIXME this loop-with-the-loop looks wrong, I'm not convinced
+ the index values will end up being correct.... NB */
+ for (du = super->disks; du; du = du->next)
+ if (du->index > idx)
+ du->index--;
+ /* mark as spare disk */
+ dm->disk.status = SPARE_DISK;
+ dm->index = -1;
+ }
+ }
+ /* update map */
+ map->num_members = map->num_members / 2;
+ map->map_state = IMSM_T_STATE_NORMAL;
+ map->num_domains = 1;
+ map->raid_level = 0;
+ map->failed_disk_num = -1;
+ }
+
+ if (u->direction == R0_TO_R10) {
+ void **space;
+ /* update slots in current disk list */
+ for (dm = super->disks; dm; dm = dm->next) {
+ if (dm->index >= 0)
+ dm->index *= 2;
+ }
+ /* create new *missing* disks */
+ for (i = 0; i < map->num_members; i++) {
+ space = *space_list;
+ if (!space)
+ continue;
+ *space_list = *space;
+ du = (void *)space;
+ memcpy(du, super->disks, sizeof(*du));
+ du->fd = -1;
+ du->minor = 0;
+ du->major = 0;
+ du->index = (i * 2) + 1;
+ sprintf((char *)du->disk.serial,
+ " MISSING_%d", du->index);
+ sprintf((char *)du->serial,
+ "MISSING_%d", du->index);
+ du->next = super->missing;
+ super->missing = du;
+ }
+ /* create new dev and map */
+ space = *space_list;
+ if (!space)
+ return 0;
+ *space_list = *space;
+ dev_new = (void *)space;
+ memcpy(dev_new, dev, sizeof(*dev));
+ /* update new map */
+ map = get_imsm_map(dev_new, 0);
+ map->num_members = map->num_members * 2;
+ map->map_state = IMSM_T_STATE_DEGRADED;
+ map->num_domains = 2;
+ map->raid_level = 1;
+ /* replace dev<->dev_new */
+ dv->dev = dev_new;
+ }
+ /* update disk order table */
+ for (du = super->disks; du; du = du->next)
+ if (du->index >= 0)
+ set_imsm_ord_tbl_ent(map, du->index, du->index);
+ for (du = super->missing; du; du = du->next)
+ if (du->index >= 0) {
+ set_imsm_ord_tbl_ent(map, du->index, du->index);
+ mark_missing(dev_new, &du->disk, du->index);
+ }
+
+ return 1;
+}
+
static void imsm_process_update(struct supertype *st,
struct metadata_update *update)
{
mpb = super->anchor;
switch (type) {
- case update_reshape_container_disks: {
- struct imsm_update_reshape *u = (void *)update->buf;
- struct dl *new_disk;
- struct intel_dev *id;
- int i;
- int delta_disks = u->new_raid_disks - u->old_raid_disks;
- void **tofree = NULL;
-
- dprintf("imsm: imsm_process_update() for update_reshape\n");
-
- /* enable spares to use in array */
- for (i = 0; i < delta_disks; i++) {
-
- new_disk = get_disk_super(super,
- major(u->new_disks[i]),
- minor(u->new_disks[i]));
- if (new_disk == NULL || new_disk->index < 0)
- goto update_reshape_exit;
-
- new_disk->index = mpb->num_disks++;
- /* slot to fill in autolayout */
- new_disk->raiddisk = new_disk->index;
- new_disk->disk.status |=
- CONFIGURED_DISK;
- new_disk->disk.status &= ~SPARE_DISK;
- }
-
- dprintf("imsm: process_update(): update_reshape: volume set"\
- " mpb->num_raid_devs = %i\n", mpb->num_raid_devs);
- /* manage changes in volumes
- */
- for (id = super->devlist ; id; id = id->next) {
- void **sp = update->space_list;
- struct imsm_dev *newdev;
- struct imsm_map *newmap, *oldmap;
-
- if (!sp)
- continue;
- update->space_list = *sp;
- newdev = (void*)sp;
- /* Copy the dev, but not (all of) the map */
- memcpy(newdev, id->dev, sizeof(*newdev));
- oldmap = get_imsm_map(id->dev, 0);
- newmap = get_imsm_map(newdev, 0);
- /* Copy the current map */
- memcpy(newmap, oldmap, sizeof_imsm_map(oldmap));
- newdev->vol.migr_state = 1;
- newdev->vol.curr_migr_unit = 0;
- newdev->vol.migr_type = MIGR_GEN_MIGR;
- newmap->num_members = u->new_raid_disks;
- for (i = 0; i < delta_disks; i++) {
- set_imsm_ord_tbl_ent(newmap,
- u->old_raid_disks + i,
- u->old_raid_disks + i);
- }
- /* New map is correct, now need to save old map */
- oldmap = get_imsm_map(newdev, 1);
- memcpy(newmap, oldmap, sizeof_imsm_map(oldmap));
-
- sp = (void **)id->dev;
- id->dev = newdev;
- *sp = tofree;
- tofree = sp;
+ case update_takeover: {
+ struct imsm_update_takeover *u = (void *)update->buf;
+ if (apply_takeover_update(u, super, &update->space_list)) {
+ imsm_update_version_info(super);
+ super->updates_pending++;
}
+ break;
+ }
- update->space_list = tofree;
- super->updates_pending++;
-update_reshape_exit:
+ case update_reshape_container_disks: {
+ struct imsm_update_reshape *u = (void *)update->buf;
+ if (apply_reshape_container_disks_update(
+ u, super, &update->space_list))
+ super->updates_pending++;
break;
}
case update_activate_spare: {
struct dl *dl;
unsigned int found;
int failed;
- int victim = get_imsm_disk_idx(dev, u->slot);
+ int victim = get_imsm_disk_idx(dev, u->slot, -1);
int i;
for (dl = super->disks; dl; dl = dl->next)
for (i = 0; i < map->num_members; i++) {
if (i == u->slot)
continue;
- disk = get_imsm_disk(super, get_imsm_disk_idx(dev, i));
+ disk = get_imsm_disk(super,
+ get_imsm_disk_idx(dev, i, -1));
if (!disk || is_failed(disk))
failed++;
}
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
for (dl = super->devlist; dl; dl = dl->next) {
int size = sizeof_imsm_dev(dl->dev, 1);
void *s;
- size += sizeof(__u32) * 2 *
- (u->new_raid_disks - u->old_raid_disks);
+ if (u->new_raid_disks > u->old_raid_disks)
+ size += sizeof(__u32)*2*
+ (u->new_raid_disks - u->old_raid_disks);
s = malloc(size);
if (!s)
break;
/* update ord entries being careful not to propagate
* ord-flags to the first map
*/
- ord = get_imsm_ord_tbl_ent(dev, j);
+ ord = get_imsm_ord_tbl_ent(dev, j, -1);
if (ord_to_idx(ord) <= index)
continue;
__free_imsm_disk(dl);
}
}
-#endif /* MDASSEMBLE */
static char disk_by_path[] = "/dev/disk/by-path/";
static const char *imsm_get_disk_controller_domain(const char *path)
{
- struct sys_dev *list, *hba = NULL;
char disk_path[PATH_MAX];
- int ahci = 0;
- char *dpath = NULL;
-
- list = find_driver_devices("pci", "ahci");
- for (hba = list; hba; hba = hba->next)
- if (devpath_to_vendor(hba->path) == 0x8086)
- break;
-
- if (hba) {
- struct stat st;
+ char *drv=NULL;
+ struct stat st;
- strncpy(disk_path, disk_by_path, PATH_MAX - 1);
- strncat(disk_path, path, PATH_MAX - strlen(disk_path) - 1);
- if (stat(disk_path, &st) == 0) {
- dpath = devt_to_devpath(st.st_rdev);
- if (dpath)
- ahci = path_attached_to_hba(dpath, hba->path);
- }
+ strncpy(disk_path, disk_by_path, PATH_MAX - 1);
+ strncat(disk_path, path, PATH_MAX - strlen(disk_path) - 1);
+ if (stat(disk_path, &st) == 0) {
+ struct sys_dev* hba;
+ char *path=NULL;
+
+ path = devt_to_devpath(st.st_rdev);
+ if (path == NULL)
+ return "unknown";
+ hba = find_disk_attached_hba(-1, path);
+ if (hba && hba->type == SYS_DEV_SAS)
+ drv = "isci";
+ else if (hba && hba->type == SYS_DEV_SATA)
+ drv = "ahci";
+ else
+ drv = "unknown";
+ dprintf("path: %s hba: %s attached: %s\n",
+ path, (hba) ? hba->path : "NULL", drv);
+ free(path);
+ if (hba)
+ free_sys_dev(&hba);
}
- dprintf("path: %s(%s) hba: %s attached: %d\n",
- path, dpath, (hba) ? hba->path : "NULL", ahci);
- free_sys_dev(&list);
- if (ahci)
- return "ahci";
- else
- return NULL;
+ return drv;
}
static int imsm_find_array_minor_by_subdev(int subdev, int container, int *minor)
struct geo_params *geo,
int *old_raid_disks)
{
+ /* currently we only support increasing the number of devices
+ * for a container. This increases the number of device for each
+ * member array. They must all be RAID0 or RAID5.
+ */
int ret_val = 0;
struct mdinfo *info, *member;
int devices_that_can_grow = 0;
dprintf("imsm: checking device_num: %i\n",
member->container_member);
- if (geo->raid_disks < member->array.raid_disks) {
+ if (geo->raid_disks <= member->array.raid_disks) {
/* we work on container for Online Capacity Expansion
* only so raid_disks has to grow
*/
(info->array.level != 5)) {
/* we cannot use this container with other raid level
*/
- dprintf("imsm: for container operation wrong"\
+ dprintf("imsm: for container operation wrong"
" raid level (%i) detected\n",
info->array.level);
break;
if (!is_raid_level_supported(super->orom,
member->array.level,
geo->raid_disks)) {
- dprintf("platform does not support raid%d with"\
+ dprintf("platform does not support raid%d with"
" %d disk%s\n",
info->array.level,
geo->raid_disks,
*/
static struct mdinfo *get_spares_for_grow(struct supertype *st)
{
- dev_t dev = 0;
- struct mdinfo *disks, *d, **dp;
unsigned long long min_size = min_acceptable_spare_size_imsm(st);
-
- /* get list of alldisks in container */
- disks = getinfo_super_disks_imsm(st);
-
- if (!disks)
- return NULL;
- /* find spare devices on the list */
- dp = &disks->devs;
- disks->array.spare_disks = 0;
- while (*dp) {
- int found = 0;
- d = *dp;
- if (d->disk.state == 0) {
- /* check if size is acceptable */
- unsigned long long dev_size;
- dev = makedev(d->disk.major,d->disk.minor);
- if (min_size &&
- dev_size_from_id(dev, &dev_size) &&
- dev_size >= min_size) {
- dev = 0;
- found = 1;
- }
- }
- if (found) {
- dp = &d->next;
- disks->array.spare_disks++;
- } else {
- *dp = d->next;
- d->next = NULL;
- sysfs_free(d);
- }
- }
- return disks;
+ return container_choose_spares(st, min_size, NULL, NULL, NULL, 0);
}
/******************************************************************************
struct mdinfo *spares = NULL;
int i;
int delta_disks = 0;
+ struct mdinfo *dev;
dprintf("imsm_update_metadata_for_reshape(enter) raid_disks = %i\n",
geo->raid_disks);
if (spares == NULL
|| delta_disks > spares->array.spare_disks) {
- dprintf("imsm: ERROR: Cannot get spare devices.\n");
+ fprintf(stderr, Name ": imsm: ERROR: Cannot get spare devices "
+ "for %s.\n", geo->dev_name);
goto abort;
}
dprintf("imsm: %i spares are available.\n\n",
spares->array.spare_disks);
+ dev = spares->devs;
for (i = 0; i < delta_disks; i++) {
- struct mdinfo *dev = spares->devs;
struct dl *dl;
+ if (dev == NULL)
+ break;
u->new_disks[i] = makedev(dev->disk.major,
dev->disk.minor);
dl = get_disk_super(super, dev->disk.major, dev->disk.minor);
- dl->index = mpb->num_disks++;
- }
- /* Now update the metadata so that container_content will find
- * the new devices
- */
- for (i = 0; i < mpb->num_raid_devs; i++) {
- int d;
- struct imsm_dev *dev = get_imsm_dev(super, i);
- struct imsm_map *map = get_imsm_map(dev, 0);
- map->num_members = geo->raid_disks;
- for (d = 0; d < delta_disks; d++) {
- set_imsm_ord_tbl_ent(map, old_raid_disks + d,
- mpb->num_disks - delta_disks + d);
- }
+ dl->index = mpb->num_disks;
+ mpb->num_disks++;
+ dev = dev->next;
}
abort:
*/
sysfs_free(spares);
+ dprintf("imsm: reshape update preparation :");
if (i == delta_disks) {
+ dprintf(" OK\n");
*updatep = u;
return update_memory_size;
}
free(u);
+ dprintf(" Error\n");
return 0;
}
+static void imsm_update_metadata_locally(struct supertype *st,
+ void *buf, int len)
+{
+ struct metadata_update mu;
+
+ mu.buf = buf;
+ mu.len = len;
+ mu.space = NULL;
+ mu.space_list = NULL;
+ mu.next = NULL;
+ imsm_prepare_update(st, &mu);
+ imsm_process_update(st, &mu);
+
+ while (mu.space_list) {
+ void **space = mu.space_list;
+ mu.space_list = *space;
+ free(space);
+ }
+}
+
+/***************************************************************************
+* Function: imsm_analyze_change
+* Description: Function analyze change for single volume
+* and validate if transition is supported
+* Parameters: Geometry parameters, supertype structure
+* Returns: Operation type code on success, -1 if fail
+****************************************************************************/
+enum imsm_reshape_type imsm_analyze_change(struct supertype *st,
+ struct geo_params *geo)
+{
+ struct mdinfo info;
+ int change = -1;
+ int check_devs = 0;
+ int chunk;
+
+ getinfo_super_imsm_volume(st, &info, NULL);
+
+ if ((geo->level != info.array.level) &&
+ (geo->level >= 0) &&
+ (geo->level != UnSet)) {
+ switch (info.array.level) {
+ case 0:
+ if (geo->level == 5) {
+ change = CH_MIGRATION;
+ check_devs = 1;
+ }
+ if (geo->level == 10) {
+ change = CH_TAKEOVER;
+ check_devs = 1;
+ }
+ break;
+ case 1:
+ if (geo->level == 0) {
+ change = CH_TAKEOVER;
+ check_devs = 1;
+ }
+ break;
+ case 5:
+ if (geo->level == 0)
+ change = CH_MIGRATION;
+ break;
+ case 10:
+ if (geo->level == 0) {
+ change = CH_TAKEOVER;
+ check_devs = 1;
+ }
+ break;
+ }
+ if (change == -1) {
+ fprintf(stderr,
+ Name " Error. Level Migration from %d to %d "
+ "not supported!\n",
+ info.array.level, geo->level);
+ goto analyse_change_exit;
+ }
+ } else
+ geo->level = info.array.level;
+
+ if ((geo->layout != info.array.layout)
+ && ((geo->layout != UnSet) && (geo->layout != -1))) {
+ change = CH_MIGRATION;
+ if ((info.array.layout == 0)
+ && (info.array.level == 5)
+ && (geo->layout == 5)) {
+ /* reshape 5 -> 4 */
+ } else if ((info.array.layout == 5)
+ && (info.array.level == 5)
+ && (geo->layout == 0)) {
+ /* reshape 4 -> 5 */
+ geo->layout = 0;
+ geo->level = 5;
+ } else {
+ fprintf(stderr,
+ Name " Error. Layout Migration from %d to %d "
+ "not supported!\n",
+ info.array.layout, geo->layout);
+ change = -1;
+ goto analyse_change_exit;
+ }
+ } else
+ geo->layout = info.array.layout;
+
+ if ((geo->chunksize > 0) && (geo->chunksize != UnSet)
+ && (geo->chunksize != info.array.chunk_size))
+ change = CH_MIGRATION;
+ else
+ geo->chunksize = info.array.chunk_size;
+
+ chunk = geo->chunksize / 1024;
+ if (!validate_geometry_imsm(st,
+ geo->level,
+ geo->layout,
+ geo->raid_disks,
+ &chunk,
+ geo->size,
+ 0, 0, 1))
+ change = -1;
+
+ if (check_devs) {
+ struct intel_super *super = st->sb;
+ struct imsm_super *mpb = super->anchor;
+
+ if (mpb->num_raid_devs > 1) {
+ fprintf(stderr,
+ Name " Error. Cannot perform operation on %s"
+ "- for this operation it MUST be single "
+ "array in container\n",
+ geo->dev_name);
+ change = -1;
+ }
+ }
+
+analyse_change_exit:
+
+ return change;
+}
+
+int imsm_takeover(struct supertype *st, struct geo_params *geo)
+{
+ struct intel_super *super = st->sb;
+ struct imsm_update_takeover *u;
+
+ u = malloc(sizeof(struct imsm_update_takeover));
+ if (u == NULL)
+ return 1;
+
+ u->type = update_takeover;
+ u->subarray = super->current_vol;
+
+ /* 10->0 transition */
+ if (geo->level == 0)
+ u->direction = R10_TO_R0;
+
+ /* 0->10 transition */
+ if (geo->level == 10)
+ u->direction = R0_TO_R10;
+
+ /* update metadata locally */
+ imsm_update_metadata_locally(st, u,
+ sizeof(struct imsm_update_takeover));
+ /* and possibly remotely */
+ if (st->update_tail)
+ append_metadata_update(st, u,
+ sizeof(struct imsm_update_takeover));
+ else
+ free(u);
+
+ return 0;
+}
static int imsm_reshape_super(struct supertype *st, long long size, int level,
int layout, int chunksize, int raid_disks,
- char *backup, char *dev, int verbouse)
+ int delta_disks, char *backup, char *dev,
+ int verbose)
{
- /* currently we only support increasing the number of devices
- * for a container. This increases the number of device for each
- * member array. They must all be RAID0 or RAID5.
- */
-
int ret_val = 1;
struct geo_params geo;
dprintf("imsm: reshape_super called.\n");
- memset(&geo, sizeof(struct geo_params), 0);
+ memset(&geo, 0, sizeof(struct geo_params));
geo.dev_name = dev;
+ geo.dev_id = st->devnum;
geo.size = size;
geo.level = level;
geo.layout = layout;
geo.chunksize = chunksize;
geo.raid_disks = raid_disks;
+ if (delta_disks != UnSet)
+ geo.raid_disks += delta_disks;
dprintf("\tfor level : %i\n", geo.level);
dprintf("\tfor raid_disks : %i\n", geo.raid_disks);
if (experimental() == 0)
return ret_val;
- /* verify reshape conditions
- * on container level we can only increase number of devices. */
if (st->container_dev == st->devnum) {
- /* check for delta_disks > 0
- *and supported raid levels 0 and 5 only in container */
+ /* On container level we can only increase number of devices. */
+ dprintf("imsm: info: Container operation\n");
int old_raid_disks = 0;
if (imsm_reshape_is_allowed_on_container(
st, &geo, &old_raid_disks)) {
len = imsm_create_metadata_update_for_reshape(
st, &geo, old_raid_disks, &u);
- if (len) {
- ret_val = 0;
+ if (len <= 0) {
+ dprintf("imsm: Cannot prepare update\n");
+ goto exit_imsm_reshape_super;
+ }
+
+ ret_val = 0;
+ /* update metadata locally */
+ imsm_update_metadata_locally(st, u, len);
+ /* and possibly remotely */
+ if (st->update_tail)
append_metadata_update(st, u, len);
- } else
- dprintf("imsm: Cannot prepare "\
- "update\n");
- } else
- dprintf("imsm: Operation is not allowed "\
- "on this container\n");
- } else
- dprintf("imsm: not a container operation\n");
+ else
+ free(u);
+ } else {
+ fprintf(stderr, Name ": (imsm) Operation "
+ "is not allowed on this container\n");
+ }
+ } else {
+ /* On volume level we support following operations
+ * - takeover: raid10 -> raid0; raid0 -> raid10
+ * - chunk size migration
+ * - migration: raid5 -> raid0; raid0 -> raid5
+ */
+ struct intel_super *super = st->sb;
+ struct intel_dev *dev = super->devlist;
+ int change, devnum;
+ dprintf("imsm: info: Volume operation\n");
+ /* find requested device */
+ while (dev) {
+ imsm_find_array_minor_by_subdev(dev->index, st->container_dev, &devnum);
+ if (devnum == geo.dev_id)
+ break;
+ dev = dev->next;
+ }
+ if (dev == NULL) {
+ fprintf(stderr, Name " Cannot find %s (%i) subarray\n",
+ geo.dev_name, geo.dev_id);
+ goto exit_imsm_reshape_super;
+ }
+ super->current_vol = dev->index;
+ change = imsm_analyze_change(st, &geo);
+ switch (change) {
+ case CH_TAKEOVER:
+ ret_val = imsm_takeover(st, &geo);
+ break;
+ case CH_MIGRATION:
+ ret_val = 0;
+ break;
+ default:
+ ret_val = 1;
+ }
+ }
+
+exit_imsm_reshape_super:
dprintf("imsm: reshape_super Exit code = %i\n", ret_val);
return ret_val;
}
+static int imsm_manage_reshape(
+ int afd, struct mdinfo *sra, struct reshape *reshape,
+ struct supertype *st, unsigned long stripes,
+ int *fds, unsigned long long *offsets,
+ int dests, int *destfd, unsigned long long *destoffsets)
+{
+ /* Just use child_monitor for now */
+ return child_monitor(
+ afd, sra, reshape, st, stripes,
+ fds, offsets, dests, destfd, destoffsets);
+}
+#endif /* MDASSEMBLE */
+
struct superswitch super_imsm = {
#ifndef MDASSEMBLE
.examine_super = examine_super_imsm,
.kill_subarray = kill_subarray_imsm,
.update_subarray = update_subarray_imsm,
.load_container = load_container_imsm,
+ .default_geometry = default_geometry_imsm,
+ .get_disk_controller_domain = imsm_get_disk_controller_domain,
+ .reshape_super = imsm_reshape_super,
+ .manage_reshape = imsm_manage_reshape,
#endif
.match_home = match_home_imsm,
.uuid_from_super= uuid_from_super_imsm,
.free_super = free_super_imsm,
.match_metadata_desc = match_metadata_desc_imsm,
.container_content = container_content_imsm,
- .default_geometry = default_geometry_imsm,
- .get_disk_controller_domain = imsm_get_disk_controller_domain,
- .reshape_super = imsm_reshape_super,
.external = 1,
.name = "imsm",