summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPawel Piatkowski <pawel.piatkowski@intel.com>2021-11-08 12:53:12 +0100
committerJes Sorensen <jsorensen@fb.com>2021-11-09 16:56:51 -0500
commit195d1d7658c4485e4c63e3758464e413d87043d2 (patch)
tree3a3975118347a902bcf4779f3e74e3336c369edf
parent75f3ba2527f37e5d5725b0827510209211c0eda1 (diff)
downloadmdadm-195d1d7658c4485e4c63e3758464e413d87043d2.tar.gz
imsm: assert if there is migration but prev_map doesn't exist
Verify that prev_map in not null during volume migration. Practically this case is not possible, device prev_map is being added if it is in the middle of migration. Add verification to silence static code analyze errors. Change error handling for function is_gen_migration() (as well as values compared with return value from this function) to use boolean types provided by stdbool.h. Signed-off-by: Pawel Piatkowski <pawel.piatkowski@intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
-rw-r--r--super-intel.c29
1 files changed, 15 insertions, 14 deletions
diff --git a/super-intel.c b/super-intel.c
index 3dfc243..d5fad10 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -1658,7 +1658,7 @@ int get_spare_criteria_imsm(struct supertype *st, struct spare_criteria *c)
return 0;
}
-static int is_gen_migration(struct imsm_dev *dev);
+static bool is_gen_migration(struct imsm_dev *dev);
#define IMSM_4K_DIV 8
@@ -1902,7 +1902,7 @@ void examine_migr_rec_imsm(struct intel_super *super)
struct imsm_map *map;
int slot = -1;
- if (is_gen_migration(dev) == 0)
+ if (is_gen_migration(dev) == false)
continue;
printf("\nMigration Record Information:");
@@ -3461,6 +3461,12 @@ static void getinfo_super_imsm_volume(struct supertype *st, struct mdinfo *info,
info->recovery_blocked = imsm_reshape_blocks_arrays_changes(st->sb);
if (is_gen_migration(dev)) {
+ /*
+ * device prev_map should be added if it is in the middle
+ * of migration
+ */
+ assert(prev_map);
+
info->reshape_active = 1;
info->new_level = get_imsm_raid_level(map);
info->new_layout = imsm_level_to_layout(info->new_level);
@@ -4255,7 +4261,7 @@ static void end_migration(struct imsm_dev *dev, struct intel_super *super,
*
* FIXME add support for raid-level-migration
*/
- if (map_state != map->map_state && (is_gen_migration(dev) == 0) &&
+ if (map_state != map->map_state && (is_gen_migration(dev) == false) &&
prev->map_state != IMSM_T_STATE_UNINITIALIZED) {
/* when final map state is other than expected
* merge maps (not for migration)
@@ -7862,18 +7868,13 @@ static int update_subarray_imsm(struct supertype *st, char *subarray,
return 0;
}
-static int is_gen_migration(struct imsm_dev *dev)
+static bool is_gen_migration(struct imsm_dev *dev)
{
- if (dev == NULL)
- return 0;
-
- if (!dev->vol.migr_state)
- return 0;
-
- if (migr_type(dev) == MIGR_GEN_MIGR)
- return 1;
+ if (dev && dev->vol.migr_state &&
+ migr_type(dev) == MIGR_GEN_MIGR)
+ return true;
- return 0;
+ return false;
}
static int is_rebuilding(struct imsm_dev *dev)
@@ -8377,7 +8378,7 @@ static void handle_missing(struct intel_super *super, struct imsm_dev *dev)
dprintf("imsm: mark missing\n");
/* end process for initialization and rebuild only
*/
- if (is_gen_migration(dev) == 0) {
+ if (is_gen_migration(dev) == false) {
int failed = imsm_count_failed(super, dev, MAP_0);
if (failed) {