From 8aa2d0fb63dc4824f05fdda34666739e032f574a Mon Sep 17 00:00:00 2001 From: Robert Baldyga Date: Mon, 2 Oct 2023 13:53:02 +0200 Subject: [PATCH 1/4] Remove unused attach context property Signed-off-by: Robert Baldyga Signed-off-by: Michal Mielewczyk --- src/mngt/ocf_mngt_cache.c | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/mngt/ocf_mngt_cache.c b/src/mngt/ocf_mngt_cache.c index 7c1baa0..e6d4ac0 100644 --- a/src/mngt/ocf_mngt_cache.c +++ b/src/mngt/ocf_mngt_cache.c @@ -107,9 +107,6 @@ struct ocf_cache_attach_context { bool device_alloc : 1; /*!< data structure allocated */ - bool volume_stored : 1; - /*!< underlying device volume is stored in contex */ - bool volume_inited : 1; /*!< underlying device volume is initialized */ @@ -2596,9 +2593,6 @@ static void _ocf_mngt_activate_handle_error( else ocf_volume_deinit(context->cfg.device.volume); - if (context->flags.volume_stored) - ocf_volume_move(&cache->device->volume, &context->cache_volume); - if (context->flags.metadata_frozen) ocf_refcnt_unfreeze(&cache->refcnt.metadata); } @@ -2625,12 +2619,6 @@ static void _ocf_mngt_cache_activate_finish(ocf_pipeline_t pipeline, ocf_pipeline_destroy(cache->stop_pipeline); cache->stop_pipeline = stop_pipeline; - if (context->flags.volume_stored) { - if (context->cache_volume.opened) - ocf_volume_close(&context->cache_volume); - ocf_volume_deinit(&context->cache_volume); - } - out: context->cmpl(context->cache, context->priv1, context->priv2, error); From 3d99a2c938aaa8c28f1d8c1259d6ccdb4debe5f0 Mon Sep 17 00:00:00 2001 From: Robert Baldyga Date: Mon, 2 Oct 2023 14:44:32 +0200 Subject: [PATCH 2/4] Add missing ocf_volume_init() calls Signed-off-by: Robert Baldyga Signed-off-by: Michal Mielewczyk --- src/mngt/ocf_mngt_cache.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/mngt/ocf_mngt_cache.c b/src/mngt/ocf_mngt_cache.c index e6d4ac0..ea2cd9f 100644 --- a/src/mngt/ocf_mngt_cache.c +++ b/src/mngt/ocf_mngt_cache.c @@ -892,8 +892,14 @@ static void _ocf_mngt_attach_cache_device(ocf_pipeline_t pipeline, context->flags.device_alloc = true; - ocf_volume_move(&cache->device->volume, device_cfg->volume); + ret = ocf_volume_init(&cache->device->volume, device_cfg->volume->type, + NULL, false); + if (ret) + OCF_PL_FINISH_RET(pipeline, -OCF_ERR_NO_MEM); + context->flags.volume_inited = true; + + ocf_volume_move(&cache->device->volume, device_cfg->volume); cache->device->volume.cache = cache; /* @@ -2469,9 +2475,15 @@ static void _ocf_mngt_activate_set_cache_device(ocf_pipeline_t pipeline, ocf_cache_t cache = context->cache; int ret; + ret = ocf_volume_init(&cache->device->volume, device_cfg->volume->type, + NULL, false); + if (ret) + OCF_PL_FINISH_RET(pipeline, -OCF_ERR_NO_MEM); + + context->flags.volume_inited = true; + ocf_volume_move(&cache->device->volume, device_cfg->volume); cache->device->volume.cache = cache; - context->flags.volume_inited = true; ret = ocf_volume_open(&cache->device->volume, device_cfg->volume_params); From 87b16aef6ace157814201d59494f2208c01d99ac Mon Sep 17 00:00:00 2001 From: Robert Baldyga Date: Tue, 3 Oct 2023 16:58:38 +0200 Subject: [PATCH 3/4] Do not deinit user volume The user is supposed to deinit/destroy it. Signed-off-by: Robert Baldyga Signed-off-by: Michal Mielewczyk --- src/mngt/ocf_mngt_cache.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/mngt/ocf_mngt_cache.c b/src/mngt/ocf_mngt_cache.c index ea2cd9f..4ae8466 100644 --- a/src/mngt/ocf_mngt_cache.c +++ b/src/mngt/ocf_mngt_cache.c @@ -1926,8 +1926,6 @@ static void _ocf_mngt_attach_handle_error( if (context->flags.volume_inited) ocf_volume_deinit(&cache->device->volume); - else - ocf_volume_deinit(context->cfg.device.volume); if (context->flags.front_volume_opened) ocf_volume_close(&cache->device->front_volume); @@ -2602,8 +2600,6 @@ static void _ocf_mngt_activate_handle_error( if (context->flags.volume_inited) ocf_volume_deinit(&cache->device->volume); - else - ocf_volume_deinit(context->cfg.device.volume); if (context->flags.metadata_frozen) ocf_refcnt_unfreeze(&cache->refcnt.metadata); From 2096e344897d0598245a72ff43f094566d3887d0 Mon Sep 17 00:00:00 2001 From: Gershon Geva Date: Sun, 8 Oct 2023 12:33:06 +0300 Subject: [PATCH 4/4] Pass user's params when opening a core volume Signed-off-by: Michal Mielewczyk --- inc/ocf_mngt.h | 6 ++++++ src/mngt/ocf_mngt_core.c | 2 +- tests/functional/pyocf/types/core.py | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/inc/ocf_mngt.h b/inc/ocf_mngt.h index 9234879..cd33c60 100644 --- a/inc/ocf_mngt.h +++ b/inc/ocf_mngt.h @@ -34,6 +34,12 @@ struct ocf_mngt_core_config { */ uint8_t volume_type; + /** + * @brief Optional opaque volume parameters, passed down to core volume + * open callback + */ + void *volume_params; + /** * @brief Add core to pool if cache isn't present or add core to * earlier loaded cache diff --git a/src/mngt/ocf_mngt_core.c b/src/mngt/ocf_mngt_core.c index 32dd58d..ea2f479 100644 --- a/src/mngt/ocf_mngt_core.c +++ b/src/mngt/ocf_mngt_core.c @@ -414,7 +414,7 @@ static void ocf_mngt_cache_add_core_insert(ocf_pipeline_t pipeline, OCF_PL_FINISH_RET(pipeline, result); } - result = ocf_volume_open(volume, NULL); + result = ocf_volume_open(volume, cfg->volume_params); if (result) OCF_PL_FINISH_RET(pipeline, result); diff --git a/tests/functional/pyocf/types/core.py b/tests/functional/pyocf/types/core.py index 0ea11e4..f1fdf96 100644 --- a/tests/functional/pyocf/types/core.py +++ b/tests/functional/pyocf/types/core.py @@ -1,5 +1,6 @@ # # Copyright(c) 2019-2022 Intel Corporation +# Copyright(c) 2024 Huawei Technologies # SPDX-License-Identifier: BSD-3-Clause # @@ -44,6 +45,7 @@ class CoreConfig(Structure): ("_name", c_char * MAX_CORE_NAME_SIZE), ("_uuid", Uuid), ("_volume_type", c_uint8), + ("_volume_params", c_void_p), ("_try_add", c_bool), ("_seq_cutoff_threshold", c_uint32), ("_seq_cutoff_promotion_count", c_uint32),