From 038126e9abc99cfa7c8e037214d4d19ad4385e00 Mon Sep 17 00:00:00 2001 From: Ian Levine Date: Thu, 12 Oct 2023 15:00:06 +0300 Subject: [PATCH] Move and rename ocf_engine_push_req_* from engine_common to ocf_queue_push_req_* in ocf_queue Signed-off-by: Ian Levine Signed-off-by: Robert Baldyga --- src/engine/cache_engine.c | 4 +- src/engine/engine_bf.c | 3 +- src/engine/engine_common.c | 73 +----------------------- src/engine/engine_common.h | 32 ----------- src/engine/engine_discard.c | 6 +- src/engine/engine_fast.c | 3 +- src/engine/engine_inv.c | 3 +- src/engine/engine_pt.c | 6 +- src/engine/engine_pt.h | 3 +- src/engine/engine_rd.c | 3 +- src/engine/engine_wb.c | 3 +- src/engine/engine_wi.c | 6 +- src/engine/engine_wo.c | 2 +- src/engine/engine_wt.c | 3 +- src/engine/engine_zero.c | 5 +- src/metadata/metadata_io.c | 8 +-- src/metadata/metadata_passive_update.c | 3 +- src/metadata/metadata_raw_dynamic.c | 6 +- src/mngt/ocf_mngt_flush.c | 4 +- src/ocf_queue.c | 79 ++++++++++++++++++++++++++ src/ocf_queue_priv.h | 46 +++++++++++++++ src/utils/utils_cleaner.c | 12 ++-- src/utils/utils_parallelize.c | 4 +- src/utils/utils_pipeline.c | 8 +-- 24 files changed, 179 insertions(+), 146 deletions(-) diff --git a/src/engine/cache_engine.c b/src/engine/cache_engine.c index 6881b4c..014ba49 100644 --- a/src/engine/cache_engine.c +++ b/src/engine/cache_engine.c @@ -264,7 +264,7 @@ int ocf_engine_hndl_req(struct ocf_request *req) * to into OCF workers */ - ocf_engine_push_req_back(req, true); + ocf_queue_push_req_back(req, true); return 0; } @@ -313,7 +313,7 @@ void ocf_engine_hndl_ops_req(struct ocf_request *req) ocf_io_if_type_to_engine_cb(OCF_IO_D2C_IF, req->rw) : ocf_io_if_type_to_engine_cb(OCF_IO_OPS_IF, req->rw); - ocf_engine_push_req_back(req, true); + ocf_queue_push_req_back(req, true); } bool ocf_req_cache_mode_has_lazy_write(ocf_req_cache_mode_t mode) diff --git a/src/engine/engine_bf.c b/src/engine/engine_bf.c index 60d2cea..ab6bc6c 100644 --- a/src/engine/engine_bf.c +++ b/src/engine/engine_bf.c @@ -1,5 +1,6 @@ /* * Copyright(c) 2012-2022 Intel Corporation + * Copyright(c) 2024 Huawei Technologies * SPDX-License-Identifier: BSD-3-Clause */ @@ -94,5 +95,5 @@ static int _ocf_backfill_do(struct ocf_request *req) void ocf_engine_backfill(struct ocf_request *req) { backfill_queue_inc_block(req->cache); - ocf_engine_push_req_front_cb(req, _ocf_backfill_do, true); + ocf_queue_push_req_front_cb(req, _ocf_backfill_do, true); } diff --git a/src/engine/engine_common.c b/src/engine/engine_common.c index fab760c..4f21c33 100644 --- a/src/engine/engine_common.c +++ b/src/engine/engine_common.c @@ -381,7 +381,7 @@ static void _ocf_engine_clean_end(void *private_data, int error) } else { req->info.dirty_any = 0; req->info.dirty_all = 0; - ocf_engine_push_req_front(req, true); + ocf_queue_push_req_front(req, true); } } @@ -584,75 +584,6 @@ void ocf_engine_update_request_stats(struct ocf_request *req) req->info.hit_no, req->core_line_count); } -void ocf_engine_push_req_back(struct ocf_request *req, bool allow_sync) -{ - ocf_cache_t cache = req->cache; - ocf_queue_t q = NULL; - unsigned long lock_flags = 0; - - INIT_LIST_HEAD(&req->list); - - ENV_BUG_ON(!req->io_queue); - q = req->io_queue; - - if (!req->info.internal) { - env_atomic_set(&cache->last_access_ms, - env_ticks_to_msecs(env_get_tick_count())); - } - - env_spinlock_lock_irqsave(&q->io_list_lock, lock_flags); - - list_add_tail(&req->list, &q->io_list); - env_atomic_inc(&q->io_no); - - env_spinlock_unlock_irqrestore(&q->io_list_lock, lock_flags); - - /* NOTE: do not dereference @req past this line, it might - * be picked up by concurrent io thread and deallocated - * at this point */ - - ocf_queue_kick(q, allow_sync); -} - -void ocf_engine_push_req_front(struct ocf_request *req, bool allow_sync) -{ - ocf_cache_t cache = req->cache; - ocf_queue_t q = NULL; - unsigned long lock_flags = 0; - - ENV_BUG_ON(!req->io_queue); - INIT_LIST_HEAD(&req->list); - - q = req->io_queue; - - if (!req->info.internal) { - env_atomic_set(&cache->last_access_ms, - env_ticks_to_msecs(env_get_tick_count())); - } - - env_spinlock_lock_irqsave(&q->io_list_lock, lock_flags); - - list_add(&req->list, &q->io_list); - env_atomic_inc(&q->io_no); - - env_spinlock_unlock_irqrestore(&q->io_list_lock, lock_flags); - - /* NOTE: do not dereference @req past this line, it might - * be picked up by concurrent io thread and deallocated - * at this point */ - - ocf_queue_kick(q, allow_sync); -} - -void ocf_engine_push_req_front_cb(struct ocf_request *req, - ocf_req_cb req_cb, - bool allow_sync) -{ - req->error = 0; /* Please explain why!!! */ - req->engine_handler = req_cb; - ocf_engine_push_req_front(req, allow_sync); -} - void inc_fallback_pt_error_counter(ocf_cache_t cache) { ENV_BUG_ON(env_atomic_read(&cache->fallback_pt_error_counter) < 0); @@ -712,5 +643,5 @@ void ocf_engine_on_resume(struct ocf_request *req) OCF_DEBUG_RQ(req, "On resume"); - ocf_engine_push_req_front_cb(req, _ocf_engine_refresh, false); + ocf_queue_push_req_front_cb(req, _ocf_engine_refresh, false); } diff --git a/src/engine/engine_common.h b/src/engine/engine_common.h index fa30f2a..6c6946e 100644 --- a/src/engine/engine_common.h +++ b/src/engine/engine_common.h @@ -281,38 +281,6 @@ void ocf_engine_update_block_stats(struct ocf_request *req); */ void ocf_engine_update_request_stats(struct ocf_request *req); -/** - * @brief Push front OCF request to the OCF thread worker queue - * - * @param req OCF request - * @param allow_sync caller allows for request from queue to be ran immediately - from push function in caller context - */ -void ocf_engine_push_req_back(struct ocf_request *req, - bool allow_sync); - -/** - * @brief Push back OCF request to the OCF thread worker queue - * - * @param req OCF request - * @param allow_sync caller allows for request from queue to be ran immediately - from push function in caller context - */ -void ocf_engine_push_req_front(struct ocf_request *req, - bool allow_sync); - -/** - * @brief Set interface and push from request to the OCF thread worker queue - * - * @param req OCF request - * @param engine_cb IO engine handler callback - * @param allow_sync caller allows for request from queue to be ran immediately - from push function in caller context - */ -void ocf_engine_push_req_front_cb(struct ocf_request *req, - ocf_req_cb req_cb, - bool allow_sync); - void inc_fallback_pt_error_counter(ocf_cache_t cache); void ocf_engine_on_resume(struct ocf_request *req); diff --git a/src/engine/engine_discard.c b/src/engine/engine_discard.c index 38532de..9298099 100644 --- a/src/engine/engine_discard.c +++ b/src/engine/engine_discard.c @@ -74,7 +74,7 @@ static void _ocf_discard_cache_flush_complete(struct ocf_io *io, int error) } req->engine_handler = _ocf_discard_core; - ocf_engine_push_req_front(req, true); + ocf_queue_push_req_front(req, true); ocf_io_put(io); } @@ -111,7 +111,7 @@ static void _ocf_discard_finish_step(struct ocf_request *req) else req->engine_handler = _ocf_discard_core; - ocf_engine_push_req_front(req, true); + ocf_queue_push_req_front(req, true); } static void _ocf_discard_step_complete(struct ocf_request *req, int error) @@ -182,7 +182,7 @@ static int _ocf_discard_step_do(struct ocf_request *req) static void _ocf_discard_on_resume(struct ocf_request *req) { OCF_DEBUG_RQ(req, "On resume"); - ocf_engine_push_req_front(req, true); + ocf_queue_push_req_front(req, true); } static int _ocf_discard_step(struct ocf_request *req) diff --git a/src/engine/engine_fast.c b/src/engine/engine_fast.c index fc7e608..5676e0b 100644 --- a/src/engine/engine_fast.c +++ b/src/engine/engine_fast.c @@ -1,5 +1,6 @@ /* * Copyright(c) 2012-2022 Intel Corporation + * Copyright(c) 2024 Huawei Technologies * SPDX-License-Identifier: BSD-3-Clause */ @@ -45,7 +46,7 @@ static void _ocf_read_fast_complete(struct ocf_request *req, int error) if (req->error) { OCF_DEBUG_RQ(req, "ERROR"); - ocf_engine_push_req_front_pt(req); + ocf_queue_push_req_front_pt(req); } else { ocf_req_unlock(ocf_cache_line_concurrency(req->cache), req); diff --git a/src/engine/engine_inv.c b/src/engine/engine_inv.c index 4b60b2b..fa84d66 100644 --- a/src/engine/engine_inv.c +++ b/src/engine/engine_inv.c @@ -1,5 +1,6 @@ /* * Copyright(c) 2012-2022 Intel Corporation + * Copyright(c) 2024 Huawei Technologies * SPDX-License-Identifier: BSD-3-Clause */ @@ -62,5 +63,5 @@ static int _ocf_invalidate_do(struct ocf_request *req) void ocf_engine_invalidate(struct ocf_request *req) { - ocf_engine_push_req_front_cb(req, _ocf_invalidate_do, true); + ocf_queue_push_req_front_cb(req, _ocf_invalidate_do, true); } diff --git a/src/engine/engine_pt.c b/src/engine/engine_pt.c index 6d3c53d..4223160 100644 --- a/src/engine/engine_pt.c +++ b/src/engine/engine_pt.c @@ -1,6 +1,6 @@ /* * Copyright(c) 2012-2022 Intel Corporation - * Copyright(c) 2023 Huawei Technologies + * Copyright(c) 2023-2024 Huawei Technologies * SPDX-License-Identifier: BSD-3-Clause */ #include "ocf/ocf.h" @@ -165,8 +165,8 @@ int ocf_read_pt(struct ocf_request *req) return 0; } -void ocf_engine_push_req_front_pt(struct ocf_request *req) +void ocf_queue_push_req_front_pt(struct ocf_request *req) { - ocf_engine_push_req_front_cb(req, ocf_read_pt_do, true); + ocf_queue_push_req_front_cb(req, ocf_read_pt_do, true); } diff --git a/src/engine/engine_pt.h b/src/engine/engine_pt.h index 59da6ce..01e34d1 100644 --- a/src/engine/engine_pt.h +++ b/src/engine/engine_pt.h @@ -1,5 +1,6 @@ /* * Copyright(c) 2012-2021 Intel Corporation + * Copyright(c) 2024 Huawei Technologies * SPDX-License-Identifier: BSD-3-Clause */ @@ -10,6 +11,6 @@ int ocf_read_pt(struct ocf_request *req); int ocf_read_pt_do(struct ocf_request *req); -void ocf_engine_push_req_front_pt(struct ocf_request *req); +void ocf_queue_push_req_front_pt(struct ocf_request *req); #endif /* ENGINE_OFF_H_ */ diff --git a/src/engine/engine_rd.c b/src/engine/engine_rd.c index 52fd4d3..2d3f201 100644 --- a/src/engine/engine_rd.c +++ b/src/engine/engine_rd.c @@ -1,5 +1,6 @@ /* * Copyright(c) 2012-2022 Intel Corporation + * Copyright(c) 2024 Huawei Technologies * SPDX-License-Identifier: BSD-3-Clause */ @@ -41,7 +42,7 @@ static void _ocf_read_generic_hit_complete(struct ocf_request *req, int error) OCF_DEBUG_RQ(req, "HIT completion"); if (req->error) { - ocf_engine_push_req_front_pt(req); + ocf_queue_push_req_front_pt(req); } else { ocf_req_unlock(c, req); diff --git a/src/engine/engine_wb.c b/src/engine/engine_wb.c index 9343360..4012f32 100644 --- a/src/engine/engine_wb.c +++ b/src/engine/engine_wb.c @@ -1,5 +1,6 @@ /* * Copyright(c) 2012-2022 Intel Corporation + * Copyright(c) 2024 Huawei Technologies * SPDX-License-Identifier: BSD-3-Clause */ @@ -102,7 +103,7 @@ static void _ocf_write_wb_complete(struct ocf_request *req, int error) ocf_engine_invalidate(req); } else { - ocf_engine_push_req_front_cb(req, + ocf_queue_push_req_front_cb(req, ocf_write_wb_do_flush_metadata, true); } } diff --git a/src/engine/engine_wi.c b/src/engine/engine_wi.c index 6db17a4..aed03bf 100644 --- a/src/engine/engine_wi.c +++ b/src/engine/engine_wi.c @@ -56,7 +56,7 @@ static void _ocf_write_wi_io_flush_metadata(struct ocf_request *req, int error) if (!req->error && !req->wi_second_pass && ocf_engine_is_miss(req)) { /* need another pass */ - ocf_engine_push_req_front_cb(req, _ocf_write_wi_next_pass, + ocf_queue_push_req_front_cb(req, _ocf_write_wi_next_pass, true); return; } @@ -123,7 +123,7 @@ static void _ocf_write_wi_core_complete(struct ocf_request *req, int error) ocf_req_put(req); } else { - ocf_engine_push_req_front_cb(req, + ocf_queue_push_req_front_cb(req, ocf_write_wi_update_and_flush_metadata, true); } } @@ -155,7 +155,7 @@ static int _ocf_write_wi_core_write(struct ocf_request *req) static void _ocf_write_wi_on_resume(struct ocf_request *req) { OCF_DEBUG_RQ(req, "On resume"); - ocf_engine_push_req_front(req, true); + ocf_queue_push_req_front(req, true); } int ocf_write_wi(struct ocf_request *req) diff --git a/src/engine/engine_wo.c b/src/engine/engine_wo.c index 1b6afee..4104f55 100644 --- a/src/engine/engine_wo.c +++ b/src/engine/engine_wo.c @@ -171,7 +171,7 @@ static void _ocf_read_wo_core_complete(struct ocf_request *req, int error) } req->engine_handler = ocf_read_wo_cache_do; - ocf_engine_push_req_front(req, true); + ocf_queue_push_req_front(req, true); } static int ocf_read_wo_do(struct ocf_request *req) diff --git a/src/engine/engine_wt.c b/src/engine/engine_wt.c index 95a2321..13e2edc 100644 --- a/src/engine/engine_wt.c +++ b/src/engine/engine_wt.c @@ -1,5 +1,6 @@ /* * Copyright(c) 2012-2022 Intel Corporation + * Copyright(c) 2024 Huawei Technologies * SPDX-License-Identifier: BSD-3-Clause */ @@ -112,7 +113,7 @@ static void _ocf_write_wt_req_complete(struct ocf_request *req) if (req->info.dirty_any) { /* Some of the request's cachelines changed its state to clean */ - ocf_engine_push_req_front_cb(req, + ocf_queue_push_req_front_cb(req, ocf_write_wt_do_flush_metadata, true); } else { ocf_req_unlock_wr(ocf_cache_line_concurrency(req->cache), req); diff --git a/src/engine/engine_zero.c b/src/engine/engine_zero.c index 5d6352b..49b5843 100644 --- a/src/engine/engine_zero.c +++ b/src/engine/engine_zero.c @@ -1,5 +1,6 @@ /* * Copyright(c) 2012-2022 Intel Corporation + * Copyright(c) 2024 Huawei Technologies * SPDX-License-Identifier: BSD-3-Clause */ @@ -50,7 +51,7 @@ static void _ocf_zero_io_flush_metadata(struct ocf_request *req, int error) if (env_atomic_dec_return(&req->req_remaining)) return; - ocf_engine_push_req_front_cb(req, ocf_zero_purge, true); + ocf_queue_push_req_front_cb(req, ocf_zero_purge, true); } static inline void ocf_zero_map_info(struct ocf_request *req) @@ -148,7 +149,7 @@ void ocf_engine_zero_line(struct ocf_request *req) if (lock >= 0) { ENV_BUG_ON(lock != OCF_LOCK_ACQUIRED); - ocf_engine_push_req_front_cb(req, _ocf_zero_do, true); + ocf_queue_push_req_front_cb(req, _ocf_zero_do, true); } else { OCF_DEBUG_RQ(req, "LOCK ERROR %d", lock); req->complete(req, lock); diff --git a/src/metadata/metadata_io.c b/src/metadata/metadata_io.c index 65a4778..87a774b 100644 --- a/src/metadata/metadata_io.c +++ b/src/metadata/metadata_io.c @@ -93,7 +93,7 @@ static void metadata_io_read_i_atomic_step_end(struct ocf_io *io, int error) context->curr_offset += context->curr_count; if (context->count > 0) - ocf_engine_push_req_front(context->req, true); + ocf_queue_push_req_front(context->req, true); else metadata_io_read_i_atomic_complete(context, 0); } @@ -181,7 +181,7 @@ int metadata_io_read_i_atomic(ocf_cache_t cache, ocf_queue_t queue, void *priv, context->compl_hndl = compl_hndl; context->priv = priv; - ocf_engine_push_req_front(context->req, true); + ocf_queue_push_req_front(context->req, true); return 0; } @@ -269,7 +269,7 @@ static void metadata_io_req_finalize(struct metadata_io_request *m_req) static void metadata_io_page_lock_acquired(struct ocf_request *req) { - ocf_engine_push_req_front(req, true); + ocf_queue_push_req_front(req, true); } static int metadata_io_restart_req(struct ocf_request *req) @@ -401,7 +401,7 @@ void metadata_io_req_complete(struct metadata_io_request *m_req) } m_req->req.engine_handler = metadata_io_restart_req; - ocf_engine_push_req_front(&m_req->req, true); + ocf_queue_push_req_front(&m_req->req, true); } /* diff --git a/src/metadata/metadata_passive_update.c b/src/metadata/metadata_passive_update.c index 8e84a6a..709738e 100644 --- a/src/metadata/metadata_passive_update.c +++ b/src/metadata/metadata_passive_update.c @@ -1,5 +1,6 @@ /* * Copyright(c) 2012-2022 Intel Corporation + * Copyright(c) 2024 Huawei Technologies * SPDX-License-Identifier: BSD-3-Clause */ @@ -70,7 +71,7 @@ static int passive_io_resume(struct ocf_request *req) static void passive_io_page_lock_acquired(struct ocf_request *req) { - ocf_engine_push_req_front(req, true); + ocf_queue_push_req_front(req, true); } int ocf_metadata_passive_update(ocf_cache_t cache, struct ocf_io *io, diff --git a/src/metadata/metadata_raw_dynamic.c b/src/metadata/metadata_raw_dynamic.c index fc06418..d25fad9 100644 --- a/src/metadata/metadata_raw_dynamic.c +++ b/src/metadata/metadata_raw_dynamic.c @@ -389,7 +389,7 @@ static void raw_dynamic_load_all_read_end(struct ocf_io *io, int error) } context->req->engine_handler = raw_dynamic_load_all_update; - ocf_engine_push_req_front(context->req, true); + ocf_queue_push_req_front(context->req, true); } static int raw_dynamic_load_all_read(struct ocf_request *req) @@ -455,7 +455,7 @@ static int raw_dynamic_load_all_update(struct ocf_request *req) } context->req->engine_handler = raw_dynamic_load_all_read; - ocf_engine_push_req_front(context->req, true); + ocf_queue_push_req_front(context->req, true); return 0; } @@ -501,7 +501,7 @@ void raw_dynamic_load_all(ocf_cache_t cache, struct ocf_metadata_raw *raw, context->req->priv = context; context->req->engine_handler = raw_dynamic_load_all_read; - ocf_engine_push_req_front(context->req, true); + ocf_queue_push_req_front(context->req, true); return; err_req: diff --git a/src/mngt/ocf_mngt_flush.c b/src/mngt/ocf_mngt_flush.c index 2cfc565..4473b59 100644 --- a/src/mngt/ocf_mngt_flush.c +++ b/src/mngt/ocf_mngt_flush.c @@ -402,7 +402,7 @@ static void _ocf_mngt_flush_portion_end(void *private_data, int error) return; } - ocf_engine_push_req_back(fc->req, false); + ocf_queue_push_req_back(fc->req, false); } @@ -452,7 +452,7 @@ static void _ocf_mngt_flush_container( fc->ticks1 = 0; fc->ticks2 = UINT_MAX; - ocf_engine_push_req_back(fc->req, true); + ocf_queue_push_req_back(fc->req, true); return; finish: diff --git a/src/ocf_queue.c b/src/ocf_queue.c index 120ed75..22ae93e 100644 --- a/src/ocf_queue.c +++ b/src/ocf_queue.c @@ -1,5 +1,6 @@ /* * Copyright(c) 2012-2022 Intel Corporation + * Copyright(c) 2024 Huawei Technologies * SPDX-License-Identifier: BSD-3-Clause */ #include "ocf/ocf.h" @@ -141,3 +142,81 @@ ocf_cache_t ocf_queue_get_cache(ocf_queue_t q) OCF_CHECK_NULL(q); return q->cache; } + +void ocf_queue_push_req_back(struct ocf_request *req, bool allow_sync) +{ + ocf_cache_t cache = req->cache; + ocf_queue_t q = NULL; + unsigned long lock_flags = 0; + + INIT_LIST_HEAD(&req->list); + + ENV_BUG_ON(!req->io_queue); + q = req->io_queue; + + if (!req->info.internal) { + env_atomic_set(&cache->last_access_ms, + env_ticks_to_msecs(env_get_tick_count())); + } + + env_spinlock_lock_irqsave(&q->io_list_lock, lock_flags); + + list_add_tail(&req->list, &q->io_list); + env_atomic_inc(&q->io_no); + + env_spinlock_unlock_irqrestore(&q->io_list_lock, lock_flags); + + /* NOTE: do not dereference @req past this line, it might + * be picked up by concurrent io thread and deallocated + * at this point */ + + ocf_queue_kick(q, allow_sync); +} + +void ocf_queue_push_req_front(struct ocf_request *req, bool allow_sync) +{ + ocf_cache_t cache = req->cache; + ocf_queue_t q = NULL; + unsigned long lock_flags = 0; + + ENV_BUG_ON(!req->io_queue); + INIT_LIST_HEAD(&req->list); + + q = req->io_queue; + + if (!req->info.internal) { + env_atomic_set(&cache->last_access_ms, + env_ticks_to_msecs(env_get_tick_count())); + } + + env_spinlock_lock_irqsave(&q->io_list_lock, lock_flags); + + list_add(&req->list, &q->io_list); + env_atomic_inc(&q->io_no); + + env_spinlock_unlock_irqrestore(&q->io_list_lock, lock_flags); + + /* NOTE: do not dereference @req past this line, it might + * be picked up by concurrent io thread and deallocated + * at this point */ + + ocf_queue_kick(q, allow_sync); +} + +void ocf_queue_push_req_front_cb(struct ocf_request *req, + ocf_req_cb req_cb, + bool allow_sync) +{ + req->error = 0; /* Please explain why!!! */ + req->engine_handler = req_cb; + ocf_queue_push_req_front(req, allow_sync); +} + +void ocf_queue_push_req_back_cb(struct ocf_request *req, + ocf_req_cb req_cb, + bool allow_sync) +{ + req->error = 0; /* Please explain why!!! */ + req->engine_handler = req_cb; + ocf_queue_push_req_back(req, allow_sync); +} diff --git a/src/ocf_queue_priv.h b/src/ocf_queue_priv.h index 50160c3..cebfe16 100644 --- a/src/ocf_queue_priv.h +++ b/src/ocf_queue_priv.h @@ -1,5 +1,6 @@ /* * Copyright(c) 2012-2021 Intel Corporation + * Copyright(c) 2024 Huawei Technologies * SPDX-License-Identifier: BSD-3-Clause */ @@ -7,6 +8,7 @@ #define OCF_QUEUE_PRIV_H_ #include "ocf_env.h" +#include "ocf_request.h" struct ocf_queue { ocf_cache_t cache; @@ -46,4 +48,48 @@ static inline void ocf_queue_kick(ocf_queue_t queue, bool allow_sync) queue->ops->kick(queue); } +/** + * @brief Push front OCF request to the OCF thread worker queue + * + * @param req OCF request + * @param allow_sync caller allows for request from queue to be ran immediately + from push function in caller context + */ +void ocf_queue_push_req_back(struct ocf_request *req, + bool allow_sync); + +/** + * @brief Push back OCF request to the OCF thread worker queue + * + * @param req OCF request + * @param allow_sync caller allows for request from queue to be ran immediately + from push function in caller context + */ +void ocf_queue_push_req_front(struct ocf_request *req, + bool allow_sync); + +/** + * @brief Set interface and push from request to the OCF thread worker queue front + * + * @param req OCF request + * @param engine_cb IO engine handler callback + * @param allow_sync caller allows for request from queue to be ran immediately + from push function in caller context + */ +void ocf_queue_push_req_front_cb(struct ocf_request *req, + ocf_req_cb req_cb, + bool allow_sync); + +/** + * @brief Set interface and push from request to the OCF thread worker queue back + * + * @param req OCF request + * @param engine_cb IO engine handler callback + * @param allow_sync caller allows for request from queue to be ran immediately + from push function in caller context + */ +void ocf_queue_push_req_back_cb(struct ocf_request *req, + ocf_req_cb req_cb, + bool allow_sync); + #endif diff --git a/src/utils/utils_cleaner.c b/src/utils/utils_cleaner.c index 65112e5..ee97eba 100644 --- a/src/utils/utils_cleaner.c +++ b/src/utils/utils_cleaner.c @@ -217,7 +217,7 @@ static void _ocf_cleaner_complete_req(struct ocf_request *req) if (master->complete_queue) { ocf_req_get(master); - ocf_engine_push_req_front_cb(master, + ocf_queue_push_req_front_cb(master, _ocf_cleaner_complete, true); } else { /* Only master contains completion function and priv */ @@ -232,7 +232,7 @@ static void _ocf_cleaner_complete_req(struct ocf_request *req) static void _ocf_cleaner_on_resume(struct ocf_request *req) { OCF_DEBUG_TRACE(req->cache); - ocf_engine_push_req_front(req, true); + ocf_queue_push_req_front(req, true); } /* @@ -336,7 +336,7 @@ static void _ocf_cleaner_metadata_io_end(struct ocf_request *req, int error) OCF_DEBUG_MSG(req->cache, "Metadata flush finished"); req->engine_handler = _ocf_cleaner_fire_flush_cache; - ocf_engine_push_req_front(req, true); + ocf_queue_push_req_front(req, true); } static int _ocf_cleaner_update_metadata(struct ocf_request *req) @@ -415,7 +415,7 @@ static void _ocf_cleaner_flush_cores_io_end(struct ocf_map_info *map, * All core writes done, switch to post cleaning activities */ req->engine_handler = _ocf_cleaner_update_metadata; - ocf_engine_push_req_front(req, true); + ocf_queue_push_req_front(req, true); } static void _ocf_cleaner_flush_cores_io_cmpl(struct ocf_io *io, int error) @@ -487,7 +487,7 @@ static void _ocf_cleaner_core_io_end(struct ocf_request *req) * Move processing to thread, where IO will be (and can be) submitted */ req->engine_handler = _ocf_cleaner_fire_flush_cores; - ocf_engine_push_req_front(req, true); + ocf_queue_push_req_front(req, true); } static void _ocf_cleaner_core_io_cmpl(struct ocf_io *io, int error) @@ -645,7 +645,7 @@ static void _ocf_cleaner_cache_io_end(struct ocf_request *req) * Move processing to thread, where IO will be (and can be) submitted */ req->engine_handler = _ocf_cleaner_fire_core; - ocf_engine_push_req_front(req, true); + ocf_queue_push_req_front(req, true); OCF_DEBUG_MSG(req->cache, "Cache reads finished"); } diff --git a/src/utils/utils_parallelize.c b/src/utils/utils_parallelize.c index a7dd383..91d6233 100644 --- a/src/utils/utils_parallelize.c +++ b/src/utils/utils_parallelize.c @@ -1,6 +1,6 @@ /* * Copyright(c) 2012-2022 Intel Corporation - * Copyright(c) 2023 Huawei Technologies + * Copyright(c) 2023-2024 Huawei Technologies * SPDX-License-Identifier: BSD-3-Clause */ @@ -142,5 +142,5 @@ void ocf_parallelize_run(ocf_parallelize_t parallelize) int i; for (i = 0; i < parallelize->shards_cnt; i++) - ocf_engine_push_req_front(parallelize->reqs[i], false); + ocf_queue_push_req_front(parallelize->reqs[i], false); } diff --git a/src/utils/utils_pipeline.c b/src/utils/utils_pipeline.c index c2a263a..e9428fe 100644 --- a/src/utils/utils_pipeline.c +++ b/src/utils/utils_pipeline.c @@ -1,6 +1,6 @@ /* * Copyright(c) 2019-2022 Intel Corporation - * Copyright(c) 2023 Huawei Technologies + * Copyright(c) 2023-2024 Huawei Technologies * SPDX-License-Identifier: BSD-3-Clause */ @@ -47,7 +47,7 @@ static int _ocf_pipeline_run_step(struct ocf_request *req) if (step->pred(pipeline, pipeline->priv, &step->arg)) { step->hndl(pipeline, pipeline->priv, &step->arg); return 0; - } + } continue; case ocf_pipeline_step_foreach: arg = &step->args[pipeline->next_arg++]; @@ -126,12 +126,12 @@ void *ocf_pipeline_get_priv(ocf_pipeline_t pipeline) void ocf_pipeline_next(ocf_pipeline_t pipeline) { - ocf_engine_push_req_front(pipeline->req, false); + ocf_queue_push_req_front(pipeline->req, false); } void ocf_pipeline_finish(ocf_pipeline_t pipeline, int error) { pipeline->finish = true; pipeline->error = error; - ocf_engine_push_req_front(pipeline->req, false); + ocf_queue_push_req_front(pipeline->req, false); }