From c4b5b0bc553cd037eb1ca43b69c37a319e18fcfa Mon Sep 17 00:00:00 2001 From: Robert Baldyga Date: Tue, 3 Nov 2026 23:49:56 +0100 Subject: [PATCH] Add ocf_forward helpers to determine cache/core io Signed-off-by: Robert Baldyga --- inc/ocf_io.h | 19 +++++++++++++++++++ src/ocf_request.c | 10 ++++++++++ 2 files changed, 29 insertions(+) diff --git a/inc/ocf_io.h b/inc/ocf_io.h index b9c98256b..03cc3e652 100644 --- a/inc/ocf_io.h +++ b/inc/ocf_io.h @@ -1,6 +1,7 @@ /* * Copyright(c) 2012-2021 Intel Corporation * Copyright(c) 2024 Huawei Technologies + * Copyright(c) 2026 Unvertical * SPDX-License-Identifier: BSD-3-Clause */ @@ -153,6 +154,24 @@ uint8_t ocf_forward_get_io_class(ocf_forward_token_t token); */ uint64_t ocf_forward_get_flags(ocf_forward_token_t token); +/** + * @brief Check if forwarded io goes to the core volume + * + * @param[in] token Forward token + * + * @retval true io forwarded to the core volume, otherwise false + */ +bool ocf_forward_is_core(ocf_forward_token_t token); + +/** + * @brief Check if forwarded io goes to the cache volume + * + * @param[in] token Forward token + * + * @retval true io forwarded to the cache volume, otherwise false + */ +bool ocf_forward_is_cache(ocf_forward_token_t token); + /** * @brief Forward io to another subvolume * diff --git a/src/ocf_request.c b/src/ocf_request.c index 0aa867fa6..ecf77b03c 100644 --- a/src/ocf_request.c +++ b/src/ocf_request.c @@ -630,6 +630,16 @@ uint64_t ocf_forward_get_flags(ocf_forward_token_t token) return (token & 1) ? 0 : req->flags; } +bool ocf_forward_is_core(ocf_forward_token_t token) +{ + return !(token & 1); +} + +bool ocf_forward_is_cache(ocf_forward_token_t token) +{ + return !!(token & 1); +} + static inline void _ocf_forward_get(ocf_forward_token_t token) { struct ocf_request *req = (struct ocf_request *)(token & ~1);