Merge pull request #59 from mmichal10/run-queue-single-request

Added function to hanlde single request from queue.
This commit is contained in:
Michal Rakowski 2019-02-14 12:58:52 +01:00 committed by GitHub
commit 276d91fcd7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 14 deletions

View File

@ -11,6 +11,13 @@
* @brief OCF queues API * @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 * @brief Run queue processing
* *

View File

@ -89,30 +89,35 @@ void ocf_io_handle(struct ocf_io *io, void *opaque)
req->io_if->read(req); 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_request *io_req = NULL;
struct ocf_cache *cache; struct ocf_cache *cache;
unsigned char step = 0;
OCF_CHECK_NULL(q); OCF_CHECK_NULL(q);
cache = q->cache; 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) { while (env_atomic_read(&q->io_no) > 0) {
/* Make sure a request is dequeued. */ ocf_queue_run_single(q);
io_req = ocf_engine_pop_req(cache, 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); OCF_COND_RESCHED(step, 128);
} }
} }