Merge pull request #691 from arutk/fix_core_load_err

Fix core load cleanup loop
This commit is contained in:
Robert Baldyga 2022-04-01 14:57:58 +02:00 committed by GitHub
commit 65918344c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -300,33 +300,29 @@ static void init_attached_data_structures_recovery(ocf_cache_t cache,
} }
/**************************************************************** /****************************************************************
* Function for removing all uninitialized core objects * * Function for removing all initialized core objects *
* from the cache instance. * * from the cache instance. *
* Used in case of cache initialization errors. * * Used in case of cache initialization errors. *
****************************************************************/ ****************************************************************/
static void _ocf_mngt_close_all_uninitialized_cores( static void _ocf_mngt_deinit_added_cores(
struct ocf_cache_attach_context *context) struct ocf_cache_attach_context *context)
{ {
ocf_cache_t cache = context->cache; ocf_cache_t cache = context->cache;
ocf_core_t core;
ocf_core_id_t core_id;
ocf_volume_t volume; ocf_volume_t volume;
int j, i;
for (j = cache->conf_meta->core_count, i = 0; j > 0; ++i) { for_each_core(cache, core, core_id) {
if (!cache->core[i].added) volume = &core->volume;
continue;
volume = &(cache->core[i].volume);
if (context->cfg.open_cores) if (context->cfg.open_cores)
ocf_volume_close(volume); ocf_volume_close(volume);
--j; if (core->seq_cutoff)
ocf_core_seq_cutoff_deinit(core);
if (cache->core[i].seq_cutoff) env_free(core->counters);
ocf_core_seq_cutoff_deinit(&cache->core[i]); core->counters = NULL;
core->added = false;
env_free(cache->core[i].counters);
cache->core[i].counters = NULL;
cache->core[i].added = false;
} }
} }
@ -441,7 +437,7 @@ static void _ocf_mngt_load_add_cores(ocf_pipeline_t pipeline,
OCF_PL_NEXT_RET(context->pipeline); OCF_PL_NEXT_RET(context->pipeline);
err: err:
_ocf_mngt_close_all_uninitialized_cores(context); _ocf_mngt_deinit_added_cores(context);
OCF_PL_FINISH_RET(pipeline, error); OCF_PL_FINISH_RET(pipeline, error);
} }
@ -1781,7 +1777,7 @@ static void _ocf_mngt_attach_handle_error(
__deinit_promotion_policy(cache); __deinit_promotion_policy(cache);
if (context->flags.cores_opened) if (context->flags.cores_opened)
_ocf_mngt_close_all_uninitialized_cores(context); _ocf_mngt_deinit_added_cores(context);
if (context->flags.attached_metadata_inited) if (context->flags.attached_metadata_inited)
ocf_metadata_deinit_variable_size(cache); ocf_metadata_deinit_variable_size(cache);
@ -2455,7 +2451,7 @@ static void _ocf_mngt_activate_handle_error(
__deinit_promotion_policy(cache); __deinit_promotion_policy(cache);
if (context->flags.cores_opened) if (context->flags.cores_opened)
_ocf_mngt_close_all_uninitialized_cores(context); _ocf_mngt_deinit_added_cores(context);
if (context->flags.volume_opened) if (context->flags.volume_opened)
ocf_volume_close(&cache->device->volume); ocf_volume_close(&cache->device->volume);