Added a priority queue for the request instead of push front

Now the request can be pushed to a high priority queue (instead of ocf_queue_push_req_front)
and to a low priority queue (instead of ocf_queue_push_req_back).
Both functions were merged into one function (ocf_queue_push_req) and instead of the
allow_sync parameter there is now a flags parameter that can be an OR combination of
OCF_QUEUE_ALLOW_SYNC and OCF_QUEUE_PRIO_HIGH

Signed-off-by: Ian Levine <ian.levine@huawei.com>
Signed-off-by: Robert Baldyga <robert.baldyga@huawei.com>
This commit is contained in:
Ian Levine
2023-10-12 22:19:18 +03:00
committed by Robert Baldyga
parent 4f2d5c22d6
commit ac1b6b774a
23 changed files with 90 additions and 131 deletions

View File

@@ -233,7 +233,7 @@ int ocf_engine_hndl_req(struct ocf_request *req)
* to into OCF workers
*/
ocf_queue_push_req_back(req, true);
ocf_queue_push_req(req, OCF_QUEUE_ALLOW_SYNC);
return 0;
}
@@ -282,7 +282,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_queue_push_req_back(req, true);
ocf_queue_push_req(req, OCF_QUEUE_ALLOW_SYNC);
}
bool ocf_req_cache_mode_has_lazy_write(ocf_req_cache_mode_t mode)

View File

@@ -95,5 +95,6 @@ static int _ocf_backfill_do(struct ocf_request *req)
void ocf_engine_backfill(struct ocf_request *req)
{
backfill_queue_inc_block(req->cache);
ocf_queue_push_req_front_cb(req, _ocf_backfill_do, true);
ocf_queue_push_req_cb(req, _ocf_backfill_do,
OCF_QUEUE_ALLOW_SYNC | OCF_QUEUE_PRIO_HIGH);
}

View File

@@ -381,7 +381,8 @@ static void _ocf_engine_clean_end(void *private_data, int error)
} else {
req->info.dirty_any = 0;
req->info.dirty_all = 0;
ocf_queue_push_req_front(req, true);
ocf_queue_push_req(req,
OCF_QUEUE_ALLOW_SYNC | OCF_QUEUE_PRIO_HIGH);
}
}
@@ -643,5 +644,5 @@ void ocf_engine_on_resume(struct ocf_request *req)
OCF_DEBUG_RQ(req, "On resume");
ocf_queue_push_req_front_cb(req, _ocf_engine_refresh, false);
ocf_queue_push_req_cb(req, _ocf_engine_refresh, OCF_QUEUE_PRIO_HIGH);
}

View File

@@ -74,7 +74,7 @@ static void _ocf_discard_cache_flush_complete(struct ocf_io *io, int error)
}
req->engine_handler = _ocf_discard_core;
ocf_queue_push_req_front(req, true);
ocf_queue_push_req(req, OCF_QUEUE_ALLOW_SYNC | OCF_QUEUE_PRIO_HIGH);
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_queue_push_req_front(req, true);
ocf_queue_push_req(req, OCF_QUEUE_ALLOW_SYNC | OCF_QUEUE_PRIO_HIGH);
}
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_queue_push_req_front(req, true);
ocf_queue_push_req(req, OCF_QUEUE_ALLOW_SYNC | OCF_QUEUE_PRIO_HIGH);
}
static int _ocf_discard_step(struct ocf_request *req)

View File

@@ -46,7 +46,7 @@ static void _ocf_read_fast_complete(struct ocf_request *req, int error)
if (req->error) {
OCF_DEBUG_RQ(req, "ERROR");
ocf_queue_push_req_front_pt(req);
ocf_queue_push_req_pt(req);
} else {
ocf_req_unlock(ocf_cache_line_concurrency(req->cache), req);

View File

@@ -63,5 +63,6 @@ static int _ocf_invalidate_do(struct ocf_request *req)
void ocf_engine_invalidate(struct ocf_request *req)
{
ocf_queue_push_req_front_cb(req, _ocf_invalidate_do, true);
ocf_queue_push_req_cb(req, _ocf_invalidate_do,
OCF_QUEUE_ALLOW_SYNC | OCF_QUEUE_PRIO_HIGH);
}

View File

@@ -165,8 +165,9 @@ int ocf_read_pt(struct ocf_request *req)
return 0;
}
void ocf_queue_push_req_front_pt(struct ocf_request *req)
void ocf_queue_push_req_pt(struct ocf_request *req)
{
ocf_queue_push_req_front_cb(req, ocf_read_pt_do, true);
ocf_queue_push_req_cb(req, ocf_read_pt_do,
OCF_QUEUE_ALLOW_SYNC | OCF_QUEUE_PRIO_HIGH);
}

View File

@@ -11,6 +11,6 @@ int ocf_read_pt(struct ocf_request *req);
int ocf_read_pt_do(struct ocf_request *req);
void ocf_queue_push_req_front_pt(struct ocf_request *req);
void ocf_queue_push_req_pt(struct ocf_request *req);
#endif /* ENGINE_OFF_H_ */

View File

@@ -42,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_queue_push_req_front_pt(req);
ocf_queue_push_req_pt(req);
} else {
ocf_req_unlock(c, req);

View File

@@ -103,8 +103,8 @@ static void _ocf_write_wb_complete(struct ocf_request *req, int error)
ocf_engine_invalidate(req);
} else {
ocf_queue_push_req_front_cb(req,
ocf_write_wb_do_flush_metadata, true);
ocf_queue_push_req_cb(req, ocf_write_wb_do_flush_metadata,
OCF_QUEUE_ALLOW_SYNC | OCF_QUEUE_PRIO_HIGH);
}
}

View File

@@ -56,8 +56,8 @@ 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_queue_push_req_front_cb(req, _ocf_write_wi_next_pass,
true);
ocf_queue_push_req_cb(req, _ocf_write_wi_next_pass,
OCF_QUEUE_ALLOW_SYNC | OCF_QUEUE_PRIO_HIGH);
return;
}
@@ -123,8 +123,9 @@ static void _ocf_write_wi_core_complete(struct ocf_request *req, int error)
ocf_req_put(req);
} else {
ocf_queue_push_req_front_cb(req,
ocf_write_wi_update_and_flush_metadata, true);
ocf_queue_push_req_cb(req,
ocf_write_wi_update_and_flush_metadata,
OCF_QUEUE_ALLOW_SYNC | OCF_QUEUE_PRIO_HIGH);
}
}
@@ -155,7 +156,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_queue_push_req_front(req, true);
ocf_queue_push_req(req, OCF_QUEUE_ALLOW_SYNC | OCF_QUEUE_PRIO_HIGH);
}
int ocf_write_wi(struct ocf_request *req)

View File

@@ -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_queue_push_req_front(req, true);
ocf_queue_push_req(req, OCF_QUEUE_ALLOW_SYNC | OCF_QUEUE_PRIO_HIGH);
}
static int ocf_read_wo_do(struct ocf_request *req)

View File

@@ -113,8 +113,8 @@ 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_queue_push_req_front_cb(req,
ocf_write_wt_do_flush_metadata, true);
ocf_queue_push_req_cb(req, ocf_write_wt_do_flush_metadata,
OCF_QUEUE_ALLOW_SYNC | OCF_QUEUE_PRIO_HIGH);
} else {
ocf_req_unlock_wr(ocf_cache_line_concurrency(req->cache), req);

View File

@@ -51,7 +51,8 @@ static void _ocf_zero_io_flush_metadata(struct ocf_request *req, int error)
if (env_atomic_dec_return(&req->req_remaining))
return;
ocf_queue_push_req_front_cb(req, ocf_zero_purge, true);
ocf_queue_push_req_cb(req, ocf_zero_purge,
OCF_QUEUE_ALLOW_SYNC | OCF_QUEUE_PRIO_HIGH);
}
static inline void ocf_zero_map_info(struct ocf_request *req)
@@ -149,7 +150,8 @@ void ocf_engine_zero_line(struct ocf_request *req)
if (lock >= 0) {
ENV_BUG_ON(lock != OCF_LOCK_ACQUIRED);
ocf_queue_push_req_front_cb(req, _ocf_zero_do, true);
ocf_queue_push_req_cb(req, _ocf_zero_do,
OCF_QUEUE_ALLOW_SYNC | OCF_QUEUE_PRIO_HIGH);
} else {
OCF_DEBUG_RQ(req, "LOCK ERROR %d", lock);
req->complete(req, lock);