From f8037cb34910c4d5d9807d478c19be72a6947f93 Mon Sep 17 00:00:00 2001 From: Michal Mielewczyk Date: Wed, 13 Feb 2019 11:46:40 -0500 Subject: [PATCH] Added function to hanlde single request from queue. --- inc/ocf_queue.h | 7 +++++++ src/ocf_queue.c | 33 +++++++++++++++++++-------------- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/inc/ocf_queue.h b/inc/ocf_queue.h index 2875ad1..1ce3a8d 100644 --- a/inc/ocf_queue.h +++ b/inc/ocf_queue.h @@ -11,6 +11,13 @@ * @brief OCF queues API */ +/** + * @brief Process single request from queue + * + * @param[in] q Queue to run + */ +void ocf_queue_run_single(ocf_queue_t q); + /** * @brief Run queue processing * diff --git a/src/ocf_queue.c b/src/ocf_queue.c index bd1ce34..2eea7ac 100644 --- a/src/ocf_queue.c +++ b/src/ocf_queue.c @@ -89,30 +89,35 @@ void ocf_io_handle(struct ocf_io *io, void *opaque) req->io_if->read(req); } -void ocf_queue_run(ocf_queue_t q) +void ocf_queue_run_single(ocf_queue_t q) { struct ocf_request *io_req = NULL; struct ocf_cache *cache; - unsigned char step = 0; OCF_CHECK_NULL(q); cache = q->cache; + io_req = ocf_engine_pop_req(cache, q); + + if (!io_req) + return; + + if (io_req->io && io_req->io->handle) + io_req->io->handle(io_req->io, io_req); + else + ocf_io_handle(io_req->io, io_req); +} + +void ocf_queue_run(ocf_queue_t q) +{ + unsigned char step = 0; + + OCF_CHECK_NULL(q); + while (env_atomic_read(&q->io_no) > 0) { - /* Make sure a request is dequeued. */ - io_req = ocf_engine_pop_req(cache, q); + ocf_queue_run_single(q); - if (!io_req) - continue; - - if (io_req->io && io_req->io->handle) - io_req->io->handle(io_req->io, io_req); - else - ocf_io_handle(io_req->io, io_req); - - /* Voluntary preemption every few requests. - * Prevents soft-lockups if preemption is disabled */ OCF_COND_RESCHED(step, 128); } }