diff options
Diffstat (limited to 'super-intel.c')
-rw-r--r-- | super-intel.c | 59 |
1 files changed, 34 insertions, 25 deletions
diff --git a/super-intel.c b/super-intel.c index 520abf5d..a01be132 100644 --- a/super-intel.c +++ b/super-intel.c @@ -1928,7 +1928,6 @@ static void examine_super_imsm(struct supertype *st, char *homehost) strncpy(str, (char *)mpb->sig, MPB_SIG_LEN); str[MPB_SIG_LEN-1] = '\0'; printf(" Magic : %s\n", str); - snprintf(str, strlen(MPB_VERSION_RAID0), "%s", get_imsm_version(mpb)); printf(" Version : %s\n", get_imsm_version(mpb)); printf(" Orig Family : %08x\n", __le32_to_cpu(mpb->orig_family_num)); printf(" Family : %08x\n", __le32_to_cpu(mpb->family_num)); @@ -3228,27 +3227,27 @@ int imsm_reshape_blocks_arrays_changes(struct intel_super *super) } return rv; } -static unsigned long long imsm_component_size_aligment_check(int level, +static unsigned long long imsm_component_size_alignment_check(int level, int chunk_size, unsigned int sector_size, unsigned long long component_size) { - unsigned int component_size_alligment; + unsigned int component_size_alignment; - /* check component size aligment + /* check component size alignment */ - component_size_alligment = component_size % (chunk_size/sector_size); + component_size_alignment = component_size % (chunk_size/sector_size); - dprintf("(Level: %i, chunk_size = %i, component_size = %llu), component_size_alligment = %u\n", + dprintf("(Level: %i, chunk_size = %i, component_size = %llu), component_size_alignment = %u\n", level, chunk_size, component_size, - component_size_alligment); + component_size_alignment); - if (component_size_alligment && (level != 1) && (level != UnSet)) { - dprintf("imsm: reported component size alligned from %llu ", + if (component_size_alignment && (level != 1) && (level != UnSet)) { + dprintf("imsm: reported component size aligned from %llu ", component_size); - component_size -= component_size_alligment; + component_size -= component_size_alignment; dprintf_cont("to %llu (%i).\n", - component_size, component_size_alligment); + component_size, component_size_alignment); } return component_size; @@ -3351,7 +3350,7 @@ static void getinfo_super_imsm_volume(struct supertype *st, struct mdinfo *info, info->data_offset = pba_of_lba0(map_to_analyse); info->component_size = calc_component_size(map, dev); - info->component_size = imsm_component_size_aligment_check( + info->component_size = imsm_component_size_alignment_check( info->array.level, info->array.chunk_size, super->sector_size, @@ -5323,6 +5322,7 @@ static int init_super_imsm_volume(struct supertype *st, mdu_array_info_t *info, struct imsm_map *map; int idx = mpb->num_raid_devs; int i; + int namelen; unsigned long long array_blocks; size_t size_old, size_new; unsigned long long num_data_stripes; @@ -5402,7 +5402,12 @@ static int init_super_imsm_volume(struct supertype *st, mdu_array_info_t *info, return 0; dv = xmalloc(sizeof(*dv)); dev = xcalloc(1, sizeof(*dev) + sizeof(__u32) * (info->raid_disks - 1)); - strncpy((char *) dev->volume, name, MAX_RAID_SERIAL_LEN); + /* + * Explicitly allow truncating to not confuse gcc's + * -Werror=stringop-truncation + */ + namelen = min((int) strlen(name), MAX_RAID_SERIAL_LEN); + memcpy(dev->volume, name, namelen); array_blocks = calc_array_size(info->level, info->raid_disks, info->layout, info->chunk_size, s->size * BLOCKS_PER_KB); @@ -5611,6 +5616,11 @@ static int add_to_super_imsm_volume(struct supertype *st, mdu_disk_info_t *dk, return 1; } + if (mpb->num_disks == 0) + if (!get_dev_sector_size(dl->fd, dl->devname, + &super->sector_size)) + return 1; + if (!drive_validate_sector_size(super, dl)) { pr_err("Combining drives of different sector size in one volume is not allowed\n"); return 1; @@ -7089,7 +7099,7 @@ static int validate_geometry_imsm_volume(struct supertype *st, int level, mpb = super->anchor; if (!validate_geometry_imsm_orom(super, level, layout, raiddisks, chunk, size, verbose)) { - pr_err("RAID gemetry validation failed. Cannot proceed with the action(s).\n"); + pr_err("RAID geometry validation failed. Cannot proceed with the action(s).\n"); return 0; } if (!dev) { @@ -7582,11 +7592,12 @@ static int update_subarray_imsm(struct supertype *st, char *subarray, append_metadata_update(st, u, sizeof(*u)); } else { struct imsm_dev *dev; - int i; + int i, namelen; dev = get_imsm_dev(super, vol); - strncpy((char *) dev->volume, name, MAX_RAID_SERIAL_LEN); - dev->volume[MAX_RAID_SERIAL_LEN-1] = '\0'; + memset(dev->volume, '\0', MAX_RAID_SERIAL_LEN); + namelen = min((int)strlen(name), MAX_RAID_SERIAL_LEN); + memcpy(dev->volume, name, namelen); for (i = 0; i < mpb->num_raid_devs; i++) { dev = get_imsm_dev(super, i); handle_missing(super, dev); @@ -8092,7 +8103,7 @@ static int mark_failure(struct intel_super *super, strcat(buf, ":0"); 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); + memcpy(disk->serial, &buf[shift], len + 1 - shift); disk->status |= FAILED_DISK; set_imsm_ord_tbl_ent(map, slot, idx | IMSM_ORD_REBUILD); @@ -9876,6 +9887,7 @@ static void imsm_process_update(struct supertype *st, /* sanity check that we are not affecting the uuid of * an active array */ + memset(name, 0, sizeof(name)); snprintf(name, MAX_RAID_SERIAL_LEN, "%s", (char *) u->name); name[MAX_RAID_SERIAL_LEN] = '\0'; for (a = st->arrays; a; a = a->next) @@ -9887,7 +9899,7 @@ static void imsm_process_update(struct supertype *st, break; } - snprintf((char *) dev->volume, MAX_RAID_SERIAL_LEN, "%s", name); + memcpy(dev->volume, name, MAX_RAID_SERIAL_LEN); super->updates_pending++; break; } @@ -11434,7 +11446,7 @@ enum imsm_reshape_type imsm_analyze_change(struct supertype *st, if (geo->size > 0 && geo->size != MAX_SIZE) { /* align component size */ - geo->size = imsm_component_size_aligment_check( + geo->size = imsm_component_size_alignment_check( get_imsm_raid_level(dev->vol.map), chunk * 1024, super->sector_size, geo->size * 2); @@ -11468,7 +11480,7 @@ enum imsm_reshape_type imsm_analyze_change(struct supertype *st, max_size = free_size + current_size; /* align component size */ - max_size = imsm_component_size_aligment_check( + max_size = imsm_component_size_alignment_check( get_imsm_raid_level(dev->vol.map), chunk * 1024, super->sector_size, max_size); @@ -11595,9 +11607,6 @@ static int imsm_reshape_super(struct supertype *st, unsigned long long size, dprintf("for level : %i\n", geo.level); dprintf("for raid_disks : %i\n", geo.raid_disks); - if (experimental() == 0) - return ret_val; - if (strcmp(st->container_devnm, st->devnm) == 0) { /* On container level we can only increase number of devices. */ dprintf("imsm: info: Container operation\n"); @@ -11970,7 +11979,7 @@ static int imsm_manage_reshape( buf_size = __le32_to_cpu(migr_rec->blocks_per_unit) * 512; /* extend buffer size for parity disk */ buf_size += __le32_to_cpu(migr_rec->dest_depth_per_unit) * 512; - /* add space for stripe aligment */ + /* add space for stripe alignment */ buf_size += old_data_stripe_length; if (posix_memalign((void **)&buf, MAX_SECTOR_SIZE, buf_size)) { dprintf("imsm: Cannot allocate checkpoint buffer\n"); |