From a9718eeab1e9bfaadcb98a2006e21f0f08842546 Mon Sep 17 00:00:00 2001 From: Robert Baldyga Date: Mon, 14 Oct 2024 21:26:38 +0200 Subject: [PATCH 1/5] Simplify fastpath handling Signed-off-by: Robert Baldyga --- src/ocf_core.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/ocf_core.c b/src/ocf_core.c index d78f982..217312e 100644 --- a/src/ocf_core.c +++ b/src/ocf_core.c @@ -261,7 +261,7 @@ static void ocf_core_volume_submit_io(ocf_io_t io) struct ocf_request *req = ocf_io_to_req(io); ocf_core_t core; ocf_cache_t cache; - int ret; + int ret, fastpath; OCF_CHECK_NULL(io); @@ -303,15 +303,15 @@ static void ocf_core_volume_submit_io(ocf_io_t io) * sequential cutoff info */ ocf_req_get(req); - if (ocf_core_submit_io_fast(req, cache) == OCF_FAST_PATH_YES) { - ocf_core_seq_cutoff_update(core, req); - ocf_req_put(req); - return; - } + fastpath = ocf_core_submit_io_fast(req, cache); - ocf_req_put(req); - ocf_req_clear_map(req); ocf_core_seq_cutoff_update(core, req); + ocf_req_put(req); + + if (fastpath == OCF_FAST_PATH_YES) + return; + + ocf_req_clear_map(req); ret = ocf_engine_hndl_req(req); if (ret) { From 85513332d745daf3ad71dc043d8a3fd6dbff9ca9 Mon Sep 17 00:00:00 2001 From: Robert Baldyga Date: Mon, 14 Oct 2024 21:27:08 +0200 Subject: [PATCH 2/5] Remove ocf_io_get() Signed-off-by: Robert Baldyga --- inc/ocf_io.h | 9 --------- src/ocf_core.c | 11 +++++------ src/ocf_io.c | 7 ------- tests/functional/pyocf/types/io.py | 3 --- 4 files changed, 5 insertions(+), 25 deletions(-) diff --git a/inc/ocf_io.h b/inc/ocf_io.h index 89a82cf..b9c9825 100644 --- a/inc/ocf_io.h +++ b/inc/ocf_io.h @@ -45,15 +45,6 @@ typedef void (*ocf_handle_io_t)(ocf_io_t io, void *opaque); */ typedef void (*ocf_end_io_t)(ocf_io_t io, void *priv1, void *priv2, int error); -/** - * @brief Increase reference counter in OCF IO - * - * @note Wrapper for get IO operation - * - * @param[in] io OCF IO - */ -void ocf_io_get(ocf_io_t io); - /** * @brief Decrease reference counter in OCF IO * diff --git a/src/ocf_core.c b/src/ocf_core.c index 217312e..bdf7378 100644 --- a/src/ocf_core.c +++ b/src/ocf_core.c @@ -213,8 +213,7 @@ static void ocf_req_complete(struct ocf_request *req, int error) dec_counter_if_req_was_dirty(req); - /* Invalidate OCF IO, it is not valid after completion */ - ocf_io_put(req); + ocf_req_put(req); } static inline ocf_req_cache_mode_t _ocf_core_req_resolve_fast_mode( @@ -281,7 +280,7 @@ static void ocf_core_volume_submit_io(ocf_io_t io) req->complete = ocf_req_complete; - ocf_io_get(io); + ocf_req_get(req); if (unlikely(req->d2c)) { ocf_core_update_stats(core, io); @@ -323,7 +322,7 @@ static void ocf_core_volume_submit_io(ocf_io_t io) err: ocf_io_end_func(io, ret); - ocf_io_put(req); + ocf_req_put(req); } static void ocf_core_volume_submit_flush(ocf_io_t io) @@ -349,7 +348,7 @@ static void ocf_core_volume_submit_flush(ocf_io_t io) req->complete = ocf_req_complete; - ocf_io_get(io); + ocf_req_get(req); if (unlikely(req->d2c)) { ocf_d2c_flush_fast(req); @@ -387,7 +386,7 @@ static void ocf_core_volume_submit_discard(ocf_io_t io) req->complete = ocf_req_complete; - ocf_io_get(io); + ocf_req_get(req); if (unlikely(req->d2c)) { ocf_d2c_discard_fast(req); diff --git a/src/ocf_io.c b/src/ocf_io.c index c8a801e..69d4e0f 100644 --- a/src/ocf_io.c +++ b/src/ocf_io.c @@ -125,13 +125,6 @@ uint32_t ocf_io_get_offset(ocf_io_t io) return req->offset; } -void ocf_io_get(ocf_io_t io) -{ - struct ocf_request *req = ocf_io_to_req(io); - - env_atomic_inc_return(&req->io.ref_count); -} - void ocf_io_put(ocf_io_t io) { struct ocf_request *req = ocf_io_to_req(io); diff --git a/tests/functional/pyocf/types/io.py b/tests/functional/pyocf/types/io.py index 92dff06..0e51afd 100644 --- a/tests/functional/pyocf/types/io.py +++ b/tests/functional/pyocf/types/io.py @@ -81,9 +81,6 @@ class Io(Structure): def put(self): OcfLib.getInstance().ocf_io_put(byref(self)) - def get(self): - OcfLib.getInstance().ocf_io_get(byref(self)) - @staticmethod @END def c_end(io, priv1, priv2, err): From 0cf4e8124bc6c8b4659f69eff98613d98d5d166e Mon Sep 17 00:00:00 2001 From: Robert Baldyga Date: Mon, 14 Oct 2024 21:29:03 +0200 Subject: [PATCH 3/5] Remove io.ref_count There is already refcounting on the request. No need for additional one. Signed-off-by: Robert Baldyga --- src/ocf_io.c | 8 +------- src/ocf_request.h | 5 ----- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/src/ocf_io.c b/src/ocf_io.c index 69d4e0f..6ca76f9 100644 --- a/src/ocf_io.c +++ b/src/ocf_io.c @@ -89,7 +89,6 @@ ocf_io_t ocf_io_new(ocf_volume_t volume, ocf_queue_t queue, return NULL; } - env_atomic_set(&req->io.ref_count, 1); req->io.volume = volume; req->io.io_class = io_class; req->flags = flags; @@ -128,12 +127,7 @@ uint32_t ocf_io_get_offset(ocf_io_t io) void ocf_io_put(ocf_io_t io) { struct ocf_request *req = ocf_io_to_req(io); - struct ocf_volume *volume; - - if (env_atomic_dec_return(&req->io.ref_count)) - return; - - volume = req->io.volume; + struct ocf_volume *volume = req->io.volume; ocf_io_allocator_del(&volume->type->allocator, (void *)req); diff --git a/src/ocf_request.h b/src/ocf_request.h index 36ab4d8..d2a9604 100644 --- a/src/ocf_request.h +++ b/src/ocf_request.h @@ -129,11 +129,6 @@ struct ocf_request_io { */ uint8_t io_class; - /** - * @brief OCF IO reference count - */ - env_atomic ref_count; - /** * @brief Front volume handle */ From b3332793bb5b7e44e20c5bfad164097f9997d158 Mon Sep 17 00:00:00 2001 From: Robert Baldyga Date: Tue, 15 Oct 2024 16:15:02 +0200 Subject: [PATCH 4/5] Remove unused request field Signed-off-by: Robert Baldyga --- src/ocf_request.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/ocf_request.h b/src/ocf_request.h index d2a9604..9c71ee6 100644 --- a/src/ocf_request.h +++ b/src/ocf_request.h @@ -295,9 +295,6 @@ struct ocf_request { ocf_req_cache_mode_t cache_mode; - uint64_t timestamp; - /*!< Tracing timestamp */ - ocf_queue_t io_queue; /*!< I/O queue handle for which request should be submitted */ From c029f78e951e639a989b4f8c93da568374ef0c61 Mon Sep 17 00:00:00 2001 From: Robert Baldyga Date: Tue, 15 Oct 2024 16:15:30 +0200 Subject: [PATCH 5/5] Make alock_rw a bit field Signed-off-by: Robert Baldyga --- src/ocf_request.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ocf_request.h b/src/ocf_request.h index 9c71ee6..76e34b8 100644 --- a/src/ocf_request.h +++ b/src/ocf_request.h @@ -1,6 +1,6 @@ /* * Copyright(c) 2012-2022 Intel Corporation - * Copyright(c) 2024 Huawei Technologies + * Copyright(c) 2024-2025 Huawei Technologies * SPDX-License-Identifier: BSD-3-Clause */ @@ -254,6 +254,9 @@ struct ocf_request { uint8_t rw : 1; /*!< Indicator of IO direction - Read/Write */ + uint8_t alock_rw: 1; + /*!< Read/Write mode for alock*/ + uint8_t d2c : 1; /**!< request affects metadata cachelines (is not direct-to-core) */ @@ -309,9 +312,6 @@ struct ocf_request { struct ocf_req_discard_info discard; - uint32_t alock_rw; - /*!< Read/Write mode for alock*/ - uint8_t *alock_status; /*!< Mapping for locked/unlocked alock entries */