From ca70ea3fff5779857ff35edb93a14f75cce2f68e Mon Sep 17 00:00:00 2001 From: Michal Mielewczyk Date: Thu, 15 Sep 2022 12:04:55 +0200 Subject: [PATCH] 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 --- src/mngt/ocf_mngt_cache.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/mngt/ocf_mngt_cache.c b/src/mngt/ocf_mngt_cache.c index 7cc1aa8..68f93cf 100644 --- a/src/mngt/ocf_mngt_cache.c +++ b/src/mngt/ocf_mngt_cache.c @@ -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);