From b40fa0c2bf4686273bdd984ea331adf7dfb3aaa2 Mon Sep 17 00:00:00 2001 From: Robert Baldyga Date: Wed, 29 Dec 2021 20:54:09 +0100 Subject: [PATCH] Fix closing volume on standby stop Signed-off-by: Robert Baldyga --- src/mngt/ocf_mngt_cache.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/mngt/ocf_mngt_cache.c b/src/mngt/ocf_mngt_cache.c index e392ea9..869705e 100644 --- a/src/mngt/ocf_mngt_cache.c +++ b/src/mngt/ocf_mngt_cache.c @@ -1748,6 +1748,7 @@ struct ocf_mngt_cache_stop_context { ocf_ctx_t ctx; char cache_name[OCF_CACHE_NAME_SIZE]; int cache_write_error; + bool close_volume; }; static void ocf_mngt_cache_stop_wait_metadata_io_finish(void *priv) @@ -2442,6 +2443,17 @@ static void _ocf_mngt_cache_load(ocf_cache_t cache, OCF_PL_NEXT_RET(pipeline); } +static void ocf_mngt_stop_standby_stop_prepare(ocf_pipeline_t pipeline, + void *priv, ocf_pipeline_arg_t arg) +{ + struct ocf_mngt_cache_stop_context *context = priv; + ocf_cache_t cache = context->cache; + + context->close_volume = !ocf_refcnt_frozen(&cache->refcnt.metadata); + + ocf_pipeline_next(pipeline); +} + static void ocf_mngt_stop_standby_stop_cleaner(ocf_pipeline_t pipeline, void *priv, ocf_pipeline_arg_t arg) { @@ -2459,7 +2471,7 @@ static void ocf_mngt_cache_standby_close_cache_volume(ocf_pipeline_t pipeline, struct ocf_mngt_cache_stop_context *context = priv; ocf_cache_t cache = context->cache; - if (!ocf_refcnt_frozen(&cache->refcnt.metadata)) + if (context->close_volume) ocf_volume_close(&cache->device->volume); ocf_pipeline_next(pipeline); @@ -2486,6 +2498,7 @@ ocf_mngt_cache_stop_standby_pipeline_properties = { .priv_size = sizeof(struct ocf_mngt_cache_stop_context), .finish = ocf_mngt_cache_stop_finish, .steps = { + OCF_PL_STEP(ocf_mngt_stop_standby_stop_prepare), OCF_PL_STEP(ocf_mngt_cache_stop_wait_metadata_io), OCF_PL_STEP(ocf_mngt_stop_standby_stop_cleaner), OCF_PL_STEP(ocf_mngt_cache_standby_close_cache_volume),