X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=super-intel.c;h=d3d256a4f36b0ba6199be7e70454ed1ce2574e10;hb=d8b0173894fb4810d861ce390e241216bdfaf325;hp=520d29217f409dbb495ed42b69f76439e8128d1a;hpb=40659392ff90fc9c2861ec18c34ed1bdb54f92ca;p=thirdparty%2Fmdadm.git diff --git a/super-intel.c b/super-intel.c index 520d2921..d3d256a4 100644 --- a/super-intel.c +++ b/super-intel.c @@ -5285,10 +5285,22 @@ static int check_name(struct intel_super *super, char *name, int quiet) { struct imsm_super *mpb = super->anchor; char *reason = NULL; + char *start = name; + size_t len = strlen(name); int i; - if (strlen(name) > MAX_RAID_SERIAL_LEN) + if (len > 0) { + while (isspace(start[len - 1])) + start[--len] = 0; + while (*start && isspace(*start)) + ++start, --len; + memmove(name, start, len + 1); + } + + if (len > MAX_RAID_SERIAL_LEN) reason = "must be 16 characters or less"; + else if (len == 0) + reason = "must be a non-empty string"; for (i = 0; i < mpb->num_raid_devs; i++) { struct imsm_dev *dev = get_imsm_dev(super, i); @@ -5616,6 +5628,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; @@ -7587,11 +7604,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); @@ -9537,12 +9555,6 @@ static int apply_takeover_update(struct imsm_update_takeover *u, if (u->direction == R10_TO_R0) { unsigned long long num_data_stripes; - map->num_domains = 1; - num_data_stripes = imsm_dev_size(dev) / 2; - num_data_stripes /= map->blocks_per_strip; - num_data_stripes /= map->num_domains; - set_num_data_stripes(map, num_data_stripes); - /* Number of failed disks must be half of initial disk number */ if (imsm_count_failed(super, dev, MAP_0) != (map->num_members / 2)) @@ -9568,10 +9580,15 @@ static int apply_takeover_update(struct imsm_update_takeover *u, map->num_domains = 1; map->raid_level = 0; map->failed_disk_num = -1; + num_data_stripes = imsm_dev_size(dev) / 2; + num_data_stripes /= map->blocks_per_strip; + set_num_data_stripes(map, num_data_stripes); } if (u->direction == R0_TO_R10) { void **space; + unsigned long long num_data_stripes; + /* update slots in current disk list */ for (dm = super->disks; dm; dm = dm->next) { if (dm->index >= 0) @@ -9609,6 +9626,11 @@ static int apply_takeover_update(struct imsm_update_takeover *u, map->map_state = IMSM_T_STATE_DEGRADED; map->num_domains = 2; map->raid_level = 1; + num_data_stripes = imsm_dev_size(dev) / 2; + num_data_stripes /= map->blocks_per_strip; + num_data_stripes /= map->num_domains; + set_num_data_stripes(map, num_data_stripes); + /* replace dev<->dev_new */ dv->dev = dev_new; } @@ -11601,9 +11623,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");