}
-static int attach_hba_to_super(struct intel_super *super, struct sys_dev *device,
- const char *devname)
+static int attach_hba_to_super(struct intel_super *super, struct sys_dev *device)
{
struct intel_hba *hba;
#endif /* MDASSEMBLE */
+static int find_intel_hba_capability(int fd, struct intel_super *super,
+ char *devname);
+
static struct supertype *match_metadata_desc_imsm(char *arg)
{
struct supertype *st;
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);
+ printf(" RAID Levels :%s%s%s%s%s\n",
+ imsm_orom_has_raid0(orom) ? " raid0" : "",
+ imsm_orom_has_raid1(orom) ? " raid1" : "",
+ imsm_orom_has_raid1e(orom) ? " raid1e" : "",
+ imsm_orom_has_raid10(orom) ? " raid10" : "",
+ imsm_orom_has_raid5(orom) ? " raid5" : "");
+ printf(" Chunk Sizes :%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
+ imsm_orom_has_chunk(orom, 2) ? " 2k" : "",
+ imsm_orom_has_chunk(orom, 4) ? " 4k" : "",
+ imsm_orom_has_chunk(orom, 8) ? " 8k" : "",
+ imsm_orom_has_chunk(orom, 16) ? " 16k" : "",
+ imsm_orom_has_chunk(orom, 32) ? " 32k" : "",
+ imsm_orom_has_chunk(orom, 64) ? " 64k" : "",
+ imsm_orom_has_chunk(orom, 128) ? " 128k" : "",
+ imsm_orom_has_chunk(orom, 256) ? " 256k" : "",
+ imsm_orom_has_chunk(orom, 512) ? " 512k" : "",
+ imsm_orom_has_chunk(orom, 1024*1) ? " 1M" : "",
+ imsm_orom_has_chunk(orom, 1024*2) ? " 2M" : "",
+ imsm_orom_has_chunk(orom, 1024*4) ? " 4M" : "",
+ imsm_orom_has_chunk(orom, 1024*8) ? " 8M" : "",
+ imsm_orom_has_chunk(orom, 1024*16) ? " 16M" : "",
+ imsm_orom_has_chunk(orom, 1024*32) ? " 32M" : "",
+ imsm_orom_has_chunk(orom, 1024*64) ? " 64M" : "");
+ printf(" Max Disks : %d\n", orom->tds);
+ printf(" Max Volumes : %d\n", orom->vpa);
+ return;
+}
+
static int detail_platform_imsm(int verbose, int enumerate_only)
{
/* There are two components to imsm platform support, the ahci SATA
int result=0;
if (enumerate_only) {
- if (check_env("IMSM_NO_PLATFORM") || find_imsm_orom())
+ if (check_env("IMSM_NO_PLATFORM"))
return 0;
- return 2;
+ 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;
}
list = find_intel_devices();
} else if (verbose)
print_found_intel_controllers(list);
- orom = find_imsm_orom();
- if (!orom) {
- free_sys_dev(&list);
- if (verbose)
- fprintf(stderr, Name ": imsm option-rom not found\n");
- return 2;
+ 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);
}
- 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);
- printf(" RAID Levels :%s%s%s%s%s\n",
- imsm_orom_has_raid0(orom) ? " raid0" : "",
- imsm_orom_has_raid1(orom) ? " raid1" : "",
- imsm_orom_has_raid1e(orom) ? " raid1e" : "",
- imsm_orom_has_raid10(orom) ? " raid10" : "",
- imsm_orom_has_raid5(orom) ? " raid5" : "");
- printf(" Chunk Sizes :%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
- imsm_orom_has_chunk(orom, 2) ? " 2k" : "",
- imsm_orom_has_chunk(orom, 4) ? " 4k" : "",
- imsm_orom_has_chunk(orom, 8) ? " 8k" : "",
- imsm_orom_has_chunk(orom, 16) ? " 16k" : "",
- imsm_orom_has_chunk(orom, 32) ? " 32k" : "",
- imsm_orom_has_chunk(orom, 64) ? " 64k" : "",
- imsm_orom_has_chunk(orom, 128) ? " 128k" : "",
- imsm_orom_has_chunk(orom, 256) ? " 256k" : "",
- imsm_orom_has_chunk(orom, 512) ? " 512k" : "",
- imsm_orom_has_chunk(orom, 1024*1) ? " 1M" : "",
- imsm_orom_has_chunk(orom, 1024*2) ? " 2M" : "",
- imsm_orom_has_chunk(orom, 1024*4) ? " 4M" : "",
- imsm_orom_has_chunk(orom, 1024*8) ? " 8M" : "",
- imsm_orom_has_chunk(orom, 1024*16) ? " 16M" : "",
- imsm_orom_has_chunk(orom, 1024*32) ? " 32M" : "",
- imsm_orom_has_chunk(orom, 1024*64) ? " 64M" : "");
- printf(" Max Disks : %d\n", orom->tds);
- printf(" Max Volumes : %d\n", orom->vpa);
-
for (hba = list; hba; hba = hba->next) {
printf(" I/O Controller : %s (%s)\n",
hba->path, get_sys_dev_type(hba->type));
"ports on SATA controller at %s.", hba->pci_id);
result |= 2;
}
- } else if (hba->type == SYS_DEV_SAS) {
- if (verbose)
- fprintf(stderr, Name ": failed to enumerate "
- "devices on SAS controller at %s.", hba->pci_id);
- result |= 2;
}
}
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
info->recovery_start = MaxSector;
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: {
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;
+
+ /* checkpoint is written per disks unit
+ * recalculate it to reshape position
+ */
+ used_disks = imsm_num_data_members(dev, 0);
+ info->reshape_progress *= used_disks;
dprintf("IMSM: General Migration checkpoint : %llu "
"(%llu) -> read reshape progress : %llu\n",
units, blocks_per_unit, info->reshape_progress);
- unsigned long long array_blocks;
- int used_disks;
used_disks = imsm_num_data_members(dev, 1);
if (used_disks > 0) {
/* 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;
tst->sb = NULL;
return 0;
}
+ /* in platform dependent environment test if the disks
+ * use the same Intel hba
+ */
+ if (!check_env("IMSM_NO_PLATFORM")) {
+ if (first->hba->type != sec->hba->type) {
+ fprintf(stderr,
+ "HBAs of devices does not match %s != %s\n",
+ get_sys_dev_type(first->hba->type),
+ get_sys_dev_type(sec->hba->type));
+ return 3;
+ }
+ }
/* if an anchor does not have num_raid_devs set then it is a free
* floating spare
static void __free_imsm(struct intel_super *super, int free_disks);
/* load_imsm_mpb - read matrix metadata
- * allocates super->mpb to be freed by free_super
+ * allocates super->mpb to be freed by free_imsm
*/
static int load_imsm_mpb(int fd, struct intel_super *super, char *devname)
{
}
__free_imsm(super, 0);
+ /* reload capability and hba */
+
+ /* capability and hba must be updated with new super allocation */
+ find_intel_hba_capability(fd, super, devname);
super->len = ROUND_UP(anchor->mpb_size, 512);
if (posix_memalign(&super->buf, 512, super->len) != 0) {
if (devname)
free(super->buf);
super->buf = NULL;
}
+ /* unlink capability description */
+ super->orom = NULL;
if (free_disks)
free_imsm_disks(super);
free_devlist(super);
memset(super, 0, sizeof(*super));
super->current_vol = -1;
super->create_offset = ~((__u32 ) 0);
- if (!check_env("IMSM_NO_PLATFORM"))
- super->orom = find_imsm_orom();
}
-
return super;
}
+/*
+ * find and allocate hba and OROM/EFI based on valid fd of RAID component device
+ */
+static int find_intel_hba_capability(int fd, struct intel_super *super, char *devname)
+{
+ struct sys_dev *hba_name;
+ int rv = 0;
+
+ if ((fd < 0) || check_env("IMSM_NO_PLATFORM")) {
+ super->orom = NULL;
+ super->hba = NULL;
+ return 0;
+ }
+ hba_name = find_disk_attached_hba(fd, NULL);
+ if (!hba_name) {
+ if (devname)
+ fprintf(stderr,
+ Name ": %s is not attached to Intel(R) RAID controller.\n",
+ devname);
+ return 1;
+ }
+ rv = attach_hba_to_super(super, hba_name);
+ if (rv == 2) {
+ if (devname) {
+ struct intel_hba *hba = super->hba;
+
+ 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,
+ hba_name->path,
+ hba_name->pci_id ? : "Err!",
+ get_sys_dev_type(hba_name->type));
+
+ 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 2;
+ }
+ super->orom = find_imsm_capability(hba_name->type);
+ free_sys_dev(&hba_name);
+ if (!super->orom)
+ return 3;
+ return 0;
+}
+
#ifndef MDASSEMBLE
/* find_missing - helper routine for load_super_imsm_all that identifies
* disks that have disappeared from the system. This routine relies on
struct intel_super *s = alloc_super();
char nm[32];
int dfd;
+ int rv;
err = 1;
if (!s)
if (dfd < 0)
goto error;
+ rv = find_intel_hba_capability(dfd, s, devname);
+ /* no orom/efi or non-intel hba of the disk */
+ if (rv != 0)
+ goto error;
+
err = load_and_parse_mpb(dfd, s, NULL, 1);
/* retry the load if we might have raced against mdmon */
sizeof(*super));
return 1;
}
+ rv = find_intel_hba_capability(fd, super, devname);
+ /* no orom/efi or non-intel hba of the disk */
+ if (rv != 0) {
+ if (devname)
+ fprintf(stderr,
+ Name ": No OROM/EFI properties for %s\n", devname);
+ free_imsm(super);
+ return 2;
+ }
rv = load_and_parse_mpb(fd, super, devname, 0);
* We do not need to test disks attachment for container based additions,
* they shall be already tested when container was created/assembled.
*/
- 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, devname);
- 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);
+ rv = find_intel_hba_capability(fd, super, devname);
+ /* no orom/efi or non-intel hba of the disk */
+ if (rv != 0) {
+ dprintf("capability: %p fd: %d ret: %d\n",
+ super->orom, fd, rv);
+ return 1;
}
if (super->current_vol >= 0)
{
int fd;
unsigned long long ldsize;
- const struct imsm_orom *orom;
+ struct intel_super *super=NULL;
+ int rv = 0;
if (level != LEVEL_CONTAINER)
return 0;
if (!dev)
return 1;
- if (check_env("IMSM_NO_PLATFORM"))
- orom = NULL;
- else
- orom = find_imsm_orom();
- if (orom && raiddisks > orom->tds) {
- if (verbose)
- fprintf(stderr, Name ": %d exceeds maximum number of"
- " platform supported disks: %d\n",
- raiddisks, orom->tds);
- return 0;
- }
-
fd = open(dev, O_RDONLY|O_EXCL, 0);
if (fd < 0) {
if (verbose)
close(fd);
return 0;
}
+
+ /* capabilities retrieve could be possible
+ * note that there is no fd for the disks in array.
+ */
+ super = alloc_super();
+ if (!super) {
+ fprintf(stderr,
+ Name ": malloc of %zu failed.\n",
+ sizeof(*super));
+ close(fd);
+ return 0;
+ }
+
+ rv = find_intel_hba_capability(fd, super, verbose ? dev : NULL);
+ if (rv != 0) {
+#if DEBUG
+ char str[256];
+ fd2devname(fd, str);
+ dprintf("validate_geometry_imsm_container: fd: %d %s orom: %p rv: %d raiddisk: %d\n",
+ fd, str, super->orom, rv, raiddisks);
+#endif
+ /* no orom/efi or non-intel hba of the disk */
+ close(fd);
+ free_imsm(super);
+ return 0;
+ }
close(fd);
+ if (super->orom && raiddisks > super->orom->tds) {
+ if (verbose)
+ fprintf(stderr, Name ": %d exceeds maximum number of"
+ " platform supported disks: %d\n",
+ raiddisks, super->orom->tds);
+
+ free_imsm(super);
+ return 0;
+ }
*freesize = avail_size_imsm(st, ldsize >> 9);
+ free_imsm(super);
return 1;
}
return 0;
}
+
#define pr_vrb(fmt, arg...) (void) (verbose && fprintf(stderr, Name fmt, ##arg))
+/*
+ * validate volume parameters with OROM/EFI capabilities
+ */
static int
validate_geometry_imsm_orom(struct intel_super *super, int level, int layout,
int raiddisks, int *chunk, int verbose)
{
- if (!is_raid_level_supported(super->orom, level, raiddisks)) {
+#if DEBUG
+ verbose = 1;
+#endif
+ /* validate container capabilities */
+ if (super->orom && raiddisks > super->orom->tds) {
+ if (verbose)
+ fprintf(stderr, Name ": %d exceeds maximum number of"
+ " platform supported disks: %d\n",
+ raiddisks, super->orom->tds);
+ return 0;
+ }
+
+ /* capabilities of OROM tested - copied from validate_geometry_imsm_volume */
+ if (super->orom && (!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;
layout, level);
return 0;
}
-
return 1;
}
if (!super)
return 0;
- if (!validate_geometry_imsm_orom(super, level, layout, raiddisks, chunk, verbose))
+ if (!validate_geometry_imsm_orom(super, level, layout, raiddisks, chunk, verbose)) {
+ fprintf(stderr, Name ": RAID gemetry validation failed. "
+ "Cannot proceed with the action(s).\n");
return 0;
-
+ }
if (!dev) {
/* General test: make sure there is space for
* 'raiddisks' device extents of size 'size' at a given
struct mdinfo *sra;
int is_member = 0;
- /* if given unused devices create a container
+ /* load capability
+ * if given unused devices create a container
* if given given devices in a container create a member volume
*/
if (level == LEVEL_CONTAINER) {
struct imsm_map *map;
struct imsm_map *map2;
struct mdinfo *this;
- int slot;
+ int slot, chunk;
char *ep;
if (subarray &&
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",
*/
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;
- if (blocks_per_unit) {
- 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++;
- }
- }
- return 0;
+ goto mark_checkpoint;
} else {
if (a->last_checkpoint == 0 && a->prev_action == reshape) {
/* for some reason we aborted the reshape.
*/
a->check_reshape = 1;
-}
+ }
/* finalize online capacity expansion/reshape */
for (mdi = a->info.devs; mdi; mdi = mdi->next)
imsm_set_disk(a,
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) {