diff --git a/src/mngt/ocf_mngt_cache.c b/src/mngt/ocf_mngt_cache.c index 2add57e..3b5f274 100644 --- a/src/mngt/ocf_mngt_cache.c +++ b/src/mngt/ocf_mngt_cache.c @@ -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. * * 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) { ocf_cache_t cache = context->cache; + ocf_core_t core; + ocf_core_id_t core_id; ocf_volume_t volume; - int j, i; - for (j = cache->conf_meta->core_count, i = 0; j > 0; ++i) { - if (!cache->core[i].added) - continue; - - volume = &(cache->core[i].volume); + for_each_core(cache, core, core_id) { + volume = &core->volume; if (context->cfg.open_cores) ocf_volume_close(volume); - --j; + if (core->seq_cutoff) + ocf_core_seq_cutoff_deinit(core); - if (cache->core[i].seq_cutoff) - ocf_core_seq_cutoff_deinit(&cache->core[i]); - - env_free(cache->core[i].counters); - cache->core[i].counters = NULL; - cache->core[i].added = false; + env_free(core->counters); + core->counters = NULL; + core->added = false; } } @@ -441,7 +437,7 @@ static void _ocf_mngt_load_add_cores(ocf_pipeline_t pipeline, OCF_PL_NEXT_RET(context->pipeline); err: - _ocf_mngt_close_all_uninitialized_cores(context); + _ocf_mngt_deinit_added_cores(context); OCF_PL_FINISH_RET(pipeline, error); } @@ -1781,7 +1777,7 @@ static void _ocf_mngt_attach_handle_error( __deinit_promotion_policy(cache); if (context->flags.cores_opened) - _ocf_mngt_close_all_uninitialized_cores(context); + _ocf_mngt_deinit_added_cores(context); if (context->flags.attached_metadata_inited) ocf_metadata_deinit_variable_size(cache); @@ -2455,7 +2451,7 @@ static void _ocf_mngt_activate_handle_error( __deinit_promotion_policy(cache); if (context->flags.cores_opened) - _ocf_mngt_close_all_uninitialized_cores(context); + _ocf_mngt_deinit_added_cores(context); if (context->flags.volume_opened) ocf_volume_close(&cache->device->volume);