From 9ea1fa4f09c71ae330f8e57ca266e4cdd4691491 Mon Sep 17 00:00:00 2001 From: Robert Baldyga Date: Fri, 5 Jul 2024 16:38:43 +0200 Subject: [PATCH] Add missing ocf_cache_mode_t to ocf_req_cache_mode_t conversions Signed-off-by: Robert Baldyga --- src/engine/cache_engine.c | 14 ++++++++++---- src/engine/cache_engine.h | 6 ++++++ src/mngt/ocf_mngt_cache.c | 12 ++++++++---- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/engine/cache_engine.c b/src/engine/cache_engine.c index 3cf318b8..c2465a97 100644 --- a/src/engine/cache_engine.c +++ b/src/engine/cache_engine.c @@ -1,5 +1,6 @@ /* * Copyright(c) 2012-2022 Intel Corporation + * Copyright(c) 2024 Huawei Technologies * SPDX-License-Identifier: BSD-3-Clause */ @@ -201,6 +202,8 @@ bool ocf_fallback_pt_is_on(ocf_cache_t cache) void ocf_resolve_effective_cache_mode(ocf_cache_t cache, ocf_core_t core, struct ocf_request *req) { + ocf_cache_mode_t cache_mode; + if (req->d2c) { req->cache_mode = ocf_req_cache_mode_d2c; return; @@ -228,10 +231,13 @@ void ocf_resolve_effective_cache_mode(ocf_cache_t cache, return; } - req->cache_mode = ocf_user_part_get_cache_mode(cache, - ocf_user_part_class2id(cache, req->part_id)); - if (!ocf_cache_mode_is_valid(req->cache_mode)) - req->cache_mode = cache->conf_meta->cache_mode; + cache_mode = ocf_user_part_get_cache_mode(cache, + ocf_user_part_class2id(cache, req->part_id)); + + if (!ocf_cache_mode_is_valid(cache_mode)) + cache_mode = cache->conf_meta->cache_mode; + + req->cache_mode = ocf_cache_mode_to_req_cache_mode(cache_mode); if (req->rw == OCF_WRITE && ocf_req_cache_mode_has_lazy_write(req->cache_mode) && diff --git a/src/engine/cache_engine.h b/src/engine/cache_engine.h index 61065fea..aa68dd61 100644 --- a/src/engine/cache_engine.h +++ b/src/engine/cache_engine.h @@ -32,6 +32,12 @@ typedef enum { ocf_req_cache_mode_max, } ocf_req_cache_mode_t; +static inline ocf_req_cache_mode_t ocf_cache_mode_to_req_cache_mode( + ocf_cache_mode_t mode) +{ + return (ocf_req_cache_mode_t)mode; +} + typedef int (*ocf_engine_cb)(struct ocf_request *req); struct ocf_io_if { diff --git a/src/mngt/ocf_mngt_cache.c b/src/mngt/ocf_mngt_cache.c index 9aed6f30..83ca25f0 100644 --- a/src/mngt/ocf_mngt_cache.c +++ b/src/mngt/ocf_mngt_cache.c @@ -3435,6 +3435,9 @@ static void _cache_mngt_update_initial_dirty_clines(ocf_cache_t cache) static int _cache_mngt_set_cache_mode(ocf_cache_t cache, ocf_cache_mode_t mode) { ocf_cache_mode_t mode_old = cache->conf_meta->cache_mode; + ocf_req_cache_mode_t req_mode = ocf_cache_mode_to_req_cache_mode(mode); + ocf_req_cache_mode_t req_mode_old = + ocf_cache_mode_to_req_cache_mode(mode_old); /* Check if IO interface type is valid */ if (!ocf_cache_mode_is_valid(mode)) @@ -3442,7 +3445,7 @@ static int _cache_mngt_set_cache_mode(ocf_cache_t cache, ocf_cache_mode_t mode) if (mode == mode_old) { ocf_cache_log(cache, log_info, "Cache mode '%s' is already set\n", - ocf_get_io_iface_name(mode)); + ocf_get_io_iface_name(req_mode)); return 0; } @@ -3454,14 +3457,15 @@ static int _cache_mngt_set_cache_mode(ocf_cache_t cache, ocf_cache_mode_t mode) } ocf_cache_log(cache, log_info, "Changing cache mode from '%s' to '%s' " - "successful\n", ocf_get_io_iface_name(mode_old), - ocf_get_io_iface_name(mode)); + "successful\n", ocf_get_io_iface_name(req_mode_old), + ocf_get_io_iface_name(req_mode)); return 0; } int ocf_mngt_cache_set_mode(ocf_cache_t cache, ocf_cache_mode_t mode) { + ocf_req_cache_mode_t req_mode = ocf_cache_mode_to_req_cache_mode(mode); int result; OCF_CHECK_NULL(cache); @@ -3478,7 +3482,7 @@ int ocf_mngt_cache_set_mode(ocf_cache_t cache, ocf_cache_mode_t mode) result = _cache_mngt_set_cache_mode(cache, mode); if (result) { - const char *name = ocf_get_io_iface_name(mode); + const char *name = ocf_get_io_iface_name(req_mode); ocf_cache_log(cache, log_err, "Setting cache mode '%s' " "failed\n", name);