Merge pull request #639 from arutk/eha

Fix error handling in cache attach
This commit is contained in:
Robert Baldyga 2022-01-19 15:26:34 +01:00 committed by GitHub
commit f4daf05237
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -340,8 +340,9 @@ static void init_attached_data_structures_recovery(ocf_cache_t cache,
* 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_close_all_uninitialized_cores(
ocf_cache_t cache) struct ocf_cache_attach_context *context)
{ {
ocf_cache_t cache = context->cache;
ocf_volume_t volume; ocf_volume_t volume;
int j, i; int j, i;
@ -350,6 +351,7 @@ static void _ocf_mngt_close_all_uninitialized_cores(
continue; continue;
volume = &(cache->core[i].volume); volume = &(cache->core[i].volume);
if (context->cfg.open_cores)
ocf_volume_close(volume); ocf_volume_close(volume);
--j; --j;
@ -480,7 +482,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(cache); _ocf_mngt_close_all_uninitialized_cores(context);
OCF_PL_FINISH_RET(pipeline, -OCF_ERR_START_CACHE_FAIL); OCF_PL_FINISH_RET(pipeline, -OCF_ERR_START_CACHE_FAIL);
} }
@ -1661,7 +1663,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(cache); _ocf_mngt_close_all_uninitialized_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);
@ -2369,7 +2371,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(cache); _ocf_mngt_close_all_uninitialized_cores(context);
if (context->flags.volume_opened) if (context->flags.volume_opened)
ocf_volume_close(&cache->device->volume); ocf_volume_close(&cache->device->volume);