]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - super-intel.c
imsm: fix: correct debug printing of the volume's name
[thirdparty/mdadm.git] / super-intel.c
index f449fd868270a3d4976465aa643912d4a89c401f..dfa85aa1b7f6f08f953892cb6d67ecc127303b0c 100644 (file)
@@ -2251,8 +2251,7 @@ int imsm_reshape_blocks_arrays_changes(struct intel_super *super)
         */
        for (i_dev = super->devlist; i_dev; i_dev = i_dev->next) {
                dev = i_dev->dev;
-               if (dev->vol.migr_state &&
-                   dev->vol.migr_type == MIGR_GEN_MIGR) {
+               if (is_gen_migration(dev)) {
                        /* No repair during any migration in container
                         */
                        rv = 1;
@@ -2294,7 +2293,10 @@ static void getinfo_super_imsm_volume(struct supertype *st, struct mdinfo *info,
        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->recovery_blocked = imsm_reshape_blocks_arrays_changes(st->sb);
+
+       if (prev_map && map->map_state == prev_map->map_state &&
+           (migr_type(dev) == MIGR_GEN_MIGR)) {
                info->reshape_active = 1;
                info->new_level = get_imsm_raid_level(map);
                info->new_layout = imsm_level_to_layout(info->new_level);
@@ -2373,8 +2375,9 @@ static void getinfo_super_imsm_volume(struct supertype *st, struct mdinfo *info,
 
        info->reshape_progress = 0;
        info->resync_start = MaxSector;
-       if (map_to_analyse->map_state == IMSM_T_STATE_UNINITIALIZED ||
-           dev->vol.dirty) {
+       if ((map_to_analyse->map_state == IMSM_T_STATE_UNINITIALIZED ||
+           dev->vol.dirty) &&
+           imsm_reshape_blocks_arrays_changes(super) == 0) {
                info->resync_start = 0;
        }
        if (dev->vol.migr_state) {
@@ -2515,6 +2518,7 @@ static void getinfo_super_imsm(struct supertype *st, struct mdinfo *info, char *
        info->disk.state = 0;
        info->name[0] = 0;
        info->recovery_start = MaxSector;
+       info->recovery_blocked = imsm_reshape_blocks_arrays_changes(st->sb);
 
        /* do we have the all the insync disks that we expect? */
        mpb = super->anchor;
@@ -2860,7 +2864,7 @@ static void fd2devname(int fd, char *name)
        sprintf(path, "/sys/dev/block/%d:%d",
                major(st.st_rdev), minor(st.st_rdev));
 
-       rv = readlink(path, dname, sizeof(dname));
+       rv = readlink(path, dname, sizeof(dname)-1);
        if (rv <= 0)
                return;
        
@@ -3108,7 +3112,7 @@ static void end_migration(struct imsm_dev *dev, __u8 map_state)
                        }
 
        dev->vol.migr_state = 0;
-       dev->vol.migr_type = 0;
+       set_migr_type(dev, 0);
        dev->vol.curr_migr_unit = 0;
        map->map_state = map_state;
 }
@@ -6011,7 +6015,9 @@ static int mark_failure(struct imsm_dev *dev, struct imsm_disk *disk, int idx)
        if (is_failed(disk) && (ord & IMSM_ORD_REBUILD))
                return 0;
 
-       sprintf(buf, "%s:0", disk->serial);
+       memcpy(buf, disk->serial, MAX_RAID_SERIAL_LEN);
+       buf[MAX_RAID_SERIAL_LEN] = '\000';
+       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);
@@ -6120,7 +6126,7 @@ static void imsm_progress_container_reshape(struct intel_super *super)
                map->num_members = prev_disks;
                dev->vol.migr_state = 1;
                dev->vol.curr_migr_unit = 0;
-               dev->vol.migr_type = MIGR_GEN_MIGR;
+               set_migr_type(dev, MIGR_GEN_MIGR);
                for (i = prev_num_members;
                     i < map->num_members; i++)
                        set_imsm_ord_tbl_ent(map, i, i);
@@ -6170,7 +6176,7 @@ static int imsm_set_array_state(struct active_array *a, int consistent)
                                if (0) {
                                struct imsm_map *map2 = get_imsm_map(dev, 1);
                                dev->vol.migr_state = 0;
-                               dev->vol.migr_type = 0;
+                               set_migr_type(dev, 0);
                                dev->vol.curr_migr_unit = 0;
                                memcpy(map, map2, sizeof_imsm_map(map2));
                                super->updates_pending++;
@@ -6230,7 +6236,8 @@ static int imsm_set_array_state(struct active_array *a, int consistent)
                        super->updates_pending++;
                        a->last_checkpoint = 0;
                }
-       } else if (!is_resyncing(dev) && !failed) {
+       } else if ((!is_resyncing(dev) && !failed) &&
+                  (imsm_reshape_blocks_arrays_changes(super) == 0)) {
                /* mark the start of the init process if nothing is failed */
                dprintf("imsm: mark resync start\n");
                if (map->map_state == IMSM_T_STATE_UNINITIALIZED)
@@ -6635,9 +6642,9 @@ static struct mdinfo *imsm_activate_spare(struct active_array *a,
         * are removed from container.
         */
        if (failed) {
-               dprintf("found failed disks in %s, check if there another"
+               dprintf("found failed disks in %.*s, check if there another"
                        "failed sub-array.\n",
-                       dev->volume);
+                       MAX_RAID_SERIAL_LEN, dev->volume);
                /* check if states of the other volumes allow for rebuild */
                for (i = 0; i <  super->anchor->num_raid_devs; i++) {
                        if (i != inst) {
@@ -6667,9 +6674,9 @@ static struct mdinfo *imsm_activate_spare(struct active_array *a,
                 */
                dl = imsm_readd(super, i, a);
                if (!dl)
-                       dl = imsm_add_spare(super, i, a, 0, NULL);
+                       dl = imsm_add_spare(super, i, a, 0, rv);
                if (!dl)
-                       dl = imsm_add_spare(super, i, a, 1, NULL);
+                       dl = imsm_add_spare(super, i, a, 1, rv);
                if (!dl)
                        continue;
  
@@ -6706,8 +6713,6 @@ static struct mdinfo *imsm_activate_spare(struct active_array *a,
                num_spares++;
                dprintf("%x:%x to be %d at %llu\n", dl->major, dl->minor,
                        i, di->data_offset);
-
-               break;
        }
 
        if (!rv)
@@ -7050,7 +7055,7 @@ static int apply_reshape_container_disks_update(struct imsm_update_reshape *u,
                        devices_to_reshape--;
                        newdev->vol.migr_state = 1;
                        newdev->vol.curr_migr_unit = 0;
-                       newdev->vol.migr_type = MIGR_GEN_MIGR;
+                       set_migr_type(newdev, MIGR_GEN_MIGR);
                        newmap->num_members = u->new_raid_disks;
                        for (i = 0; i < delta_disks; i++) {
                                set_imsm_ord_tbl_ent(newmap,