imsm: assert if there is migration but prev_map doesn't exist
PATCH 1/1 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.
--- super-intel.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-)
super-intel.c +15 -14
@@ -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) {
Signature · 1 line
2.26.2
Jes Sorensen
AppliedQuoted 11 lines · Pawel Piatkowski
Verify that
prev_mapin not null during volume migration. Practically this case is not possible, deviceprev_mapis 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 bystdbool.h.Signed-off-by Pawel Piatkowski <[email protected]>---
Applied!
Thanks,
Jes