Deinit cleaning policy if attaching cache failed

Normally cleaning policy would be deinitialized during stopping cache which is
one of steps of error handling e.g in case of failed cache activation. But since
`cache_stop()` may be called only for an attached cache instance, cleaning
policy needs to deinitialized explicitly.

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
This commit is contained in:
Michal Mielewczyk 2022-09-15 12:04:55 +02:00
parent 21d5da83d9
commit ca70ea3fff

View File

@ -130,6 +130,9 @@ struct ocf_cache_attach_context {
bool promotion_initialized : 1;
/*!< Promotion policy has been started */
bool cleaning_initialized : 1;
/*!< Cleaning policy has been initialized */
bool cores_opened : 1;
/*!< underlying cores are opened (happens only during
* load or recovery
@ -1233,6 +1236,7 @@ static void _ocf_mngt_attach_init_services(ocf_pipeline_t pipeline,
considered to be flushed
*/
cache->conf_meta->dirty_flushed = true;
context->flags.cleaning_initialized = true;
ocf_pipeline_next(pipeline);
}
@ -1728,6 +1732,9 @@ static void _ocf_mngt_attach_handle_error(
if (context->flags.promotion_initialized)
__deinit_promotion_policy(cache);
if (context->flags.cleaning_initialized)
__deinit_cleaning_policy(cache);
if (context->flags.cores_opened)
_ocf_mngt_deinit_added_cores(context);