All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] imsm: assert if there is migration but prev_map doesn't exist
@ 2021-11-08 11:53 Pawel Piatkowski
  2021-11-09 21:57 ` Jes Sorensen
  0 siblings, 1 reply; 2+ messages in thread
From: Pawel Piatkowski @ 2021-11-08 11:53 UTC (permalink / raw)
  To: linux-raid; +Cc: jes

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>
---
 super-intel.c | 29 +++++++++++++++--------------
 1 file changed, 15 insertions(+), 14 deletions(-)

diff --git a/super-intel.c b/super-intel.c
index 28472a1a..bf13f888 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) {
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] imsm: assert if there is migration but prev_map doesn't exist
  2021-11-08 11:53 [PATCH] imsm: assert if there is migration but prev_map doesn't exist Pawel Piatkowski
@ 2021-11-09 21:57 ` Jes Sorensen
  0 siblings, 0 replies; 2+ messages in thread
From: Jes Sorensen @ 2021-11-09 21:57 UTC (permalink / raw)
  To: Pawel Piatkowski, linux-raid

On 11/8/21 6:53 AM, Pawel Piatkowski wrote:
> 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>
> ---

Applied!

Thanks,
Jes



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-11-09 21:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-08 11:53 [PATCH] imsm: assert if there is migration but prev_map doesn't exist Pawel Piatkowski
2021-11-09 21:57 ` Jes Sorensen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.