From 4aff637e575423e620403fd9f3c10864a4dae39d Mon Sep 17 00:00:00 2001 From: Kozlowski Mateusz Date: Thu, 22 Apr 2021 13:25:50 +0200 Subject: [PATCH 1/3] Add priv field initialization on cache start This allows access to it in ctx_metadata_updater_init, which is done in the same call stack during initalization. Signed-off-by: Kozlowski Mateusz --- inc/ocf_mngt.h | 3 ++- src/mngt/ocf_mngt_cache.c | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/inc/ocf_mngt.h b/inc/ocf_mngt.h index db48410..a05f63f 100644 --- a/inc/ocf_mngt.h +++ b/inc/ocf_mngt.h @@ -325,12 +325,13 @@ static inline void ocf_mngt_cache_config_set_default( * @param[in] ctx OCF context * @param[out] cache Cache handle * @param[in] cfg Starting cache configuration + * @param[in] priv initial value of priv field in cache * * @retval 0 Cache started successfully * @retval Non-zero Error occurred and starting cache failed */ int ocf_mngt_cache_start(ocf_ctx_t ctx, ocf_cache_t *cache, - struct ocf_mngt_cache_config *cfg); + struct ocf_mngt_cache_config *cfg, void *priv); /** * @brief Set queue to be used during management operations diff --git a/src/mngt/ocf_mngt_cache.c b/src/mngt/ocf_mngt_cache.c index 0d45315..731a09e 100644 --- a/src/mngt/ocf_mngt_cache.c +++ b/src/mngt/ocf_mngt_cache.c @@ -1179,7 +1179,7 @@ static void _ocf_mngt_cache_init(ocf_cache_t cache, } static int _ocf_mngt_cache_start(ocf_ctx_t ctx, ocf_cache_t *cache, - struct ocf_mngt_cache_config *cfg) + struct ocf_mngt_cache_config *cfg, void *priv) { struct ocf_cache_mngt_init_params params; ocf_cache_t tmp_cache; @@ -1208,6 +1208,7 @@ static int _ocf_mngt_cache_start(ocf_ctx_t ctx, ocf_cache_t *cache, tmp_cache = params.cache; tmp_cache->owner = ctx; + tmp_cache->priv = priv; /* * Initialize metadata selected segments of metadata in memory @@ -1946,7 +1947,7 @@ static const char *_ocf_cache_mode_get_name(ocf_cache_mode_t cache_mode) } int ocf_mngt_cache_start(ocf_ctx_t ctx, ocf_cache_t *cache, - struct ocf_mngt_cache_config *cfg) + struct ocf_mngt_cache_config *cfg, void *priv) { int result; @@ -1957,7 +1958,7 @@ int ocf_mngt_cache_start(ocf_ctx_t ctx, ocf_cache_t *cache, if (result) return result; - result = _ocf_mngt_cache_start(ctx, cache, cfg); + result = _ocf_mngt_cache_start(ctx, cache, cfg, priv); if (!result) { _ocf_mngt_cache_set_valid(*cache); From 2b498673f02bb6396f9e0bdeca08ac48b894fcc1 Mon Sep 17 00:00:00 2001 From: Kozlowski Mateusz Date: Fri, 14 May 2021 10:50:57 +0200 Subject: [PATCH 2/3] Fix OCF example build Signed-off-by: Kozlowski Mateusz --- example/simple/src/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/simple/src/main.c b/example/simple/src/main.c index 17c6bec..d5b7d62 100644 --- a/example/simple/src/main.c +++ b/example/simple/src/main.c @@ -126,7 +126,7 @@ int initialize_cache(ocf_ctx_t ctx, ocf_cache_t *cache) return -ENOMEM; /* Start cache */ - ret = ocf_mngt_cache_start(ctx, cache, &cache_cfg); + ret = ocf_mngt_cache_start(ctx, cache, &cache_cfg, NULL); if (ret) goto err_priv; From 9f1df6e3809c091cc7c5bcbb84416b64cd910c43 Mon Sep 17 00:00:00 2001 From: Jan Musial Date: Wed, 26 May 2021 07:50:53 +0200 Subject: [PATCH 3/3] Update pyOCF and tests Signed-off-by: Jan Musial --- tests/functional/pyocf/types/cache.py | 2 +- tests/functional/tests/management/test_start_stop.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/functional/pyocf/types/cache.py b/tests/functional/pyocf/types/cache.py index 139727f..a1bef30 100644 --- a/tests/functional/pyocf/types/cache.py +++ b/tests/functional/pyocf/types/cache.py @@ -205,7 +205,7 @@ class Cache: def start_cache(self, default_io_queue: Queue = None, mngt_queue: Queue = None): status = self.owner.lib.ocf_mngt_cache_start( - self.owner.ctx_handle, byref(self.cache_handle), byref(self.cfg) + self.owner.ctx_handle, byref(self.cache_handle), byref(self.cfg), None ) if status: raise OcfError("Creating cache instance failed", status) diff --git a/tests/functional/tests/management/test_start_stop.py b/tests/functional/tests/management/test_start_stop.py index 92fb02e..42149a8 100644 --- a/tests/functional/tests/management/test_start_stop.py +++ b/tests/functional/tests/management/test_start_stop.py @@ -394,7 +394,7 @@ def test_start_stop_noqueue(pyocf_ctx): cache_handle = c_void_p() status = pyocf_ctx.lib.ocf_mngt_cache_start( - pyocf_ctx.ctx_handle, byref(cache_handle), byref(_cache.cfg) + pyocf_ctx.ctx_handle, byref(cache_handle), byref(_cache.cfg), None ) assert not status, "Failed to start cache: {}".format(status)