Skip to content

Commit

Permalink
Added a priority queue for the request instead of push front
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Ian Levine authored and robertbaldyga committed Jul 30, 2024
1 parent 8941051 commit d96f8ea
Show file tree
Hide file tree
Showing 23 changed files with 90 additions and 131 deletions.
4 changes: 2 additions & 2 deletions src/engine/cache_engine.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion src/engine/engine_bf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
5 changes: 3 additions & 2 deletions src/engine/engine_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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);
}
6 changes: 3 additions & 3 deletions src/engine/engine_discard.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/engine/engine_fast.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
3 changes: 2 additions & 1 deletion src/engine/engine_inv.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
5 changes: 3 additions & 2 deletions src/engine/engine_pt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

2 changes: 1 addition & 1 deletion src/engine/engine_pt.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_ */
2 changes: 1 addition & 1 deletion src/engine/engine_rd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
4 changes: 2 additions & 2 deletions src/engine/engine_wb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
11 changes: 6 additions & 5 deletions src/engine/engine_wi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/engine/engine_wo.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/engine/engine_wt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
6 changes: 4 additions & 2 deletions src/engine/engine_zero.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand Down
11 changes: 7 additions & 4 deletions src/metadata/metadata_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ 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_queue_push_req_front(context->req, true);
ocf_queue_push_req(context->req,
OCF_QUEUE_ALLOW_SYNC | OCF_QUEUE_PRIO_HIGH);
else
metadata_io_read_i_atomic_complete(context, 0);
}
Expand Down Expand Up @@ -181,7 +182,8 @@ 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_queue_push_req_front(context->req, true);
ocf_queue_push_req(context->req,
OCF_QUEUE_ALLOW_SYNC | OCF_QUEUE_PRIO_HIGH);

return 0;
}
Expand Down Expand Up @@ -269,7 +271,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_queue_push_req_front(req, true);
ocf_queue_push_req(req, OCF_QUEUE_ALLOW_SYNC | OCF_QUEUE_PRIO_HIGH);
}

static int metadata_io_restart_req(struct ocf_request *req)
Expand Down Expand Up @@ -401,7 +403,8 @@ void metadata_io_req_complete(struct metadata_io_request *m_req)
}

m_req->req.engine_handler = metadata_io_restart_req;
ocf_queue_push_req_front(&m_req->req, true);
ocf_queue_push_req(&m_req->req,
OCF_QUEUE_ALLOW_SYNC | OCF_QUEUE_PRIO_HIGH);
}

/*
Expand Down
2 changes: 1 addition & 1 deletion src/metadata/metadata_passive_update.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ static int passive_io_resume(struct ocf_request *req)

static void passive_io_page_lock_acquired(struct ocf_request *req)
{
ocf_queue_push_req_front(req, true);
ocf_queue_push_req(req, OCF_QUEUE_ALLOW_SYNC | OCF_QUEUE_PRIO_HIGH);
}

int ocf_metadata_passive_update(ocf_cache_t cache, struct ocf_io *io,
Expand Down
9 changes: 6 additions & 3 deletions src/metadata/metadata_raw_dynamic.c
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,8 @@ static void raw_dynamic_load_all_read_end(struct ocf_io *io, int error)
}

context->req->engine_handler = raw_dynamic_load_all_update;
ocf_queue_push_req_front(context->req, true);
ocf_queue_push_req(context->req,
OCF_QUEUE_ALLOW_SYNC | OCF_QUEUE_PRIO_HIGH);
}

static int raw_dynamic_load_all_read(struct ocf_request *req)
Expand Down Expand Up @@ -455,7 +456,8 @@ static int raw_dynamic_load_all_update(struct ocf_request *req)
}

context->req->engine_handler = raw_dynamic_load_all_read;
ocf_queue_push_req_front(context->req, true);
ocf_queue_push_req(context->req,
OCF_QUEUE_ALLOW_SYNC | OCF_QUEUE_PRIO_HIGH);

return 0;
}
Expand Down Expand Up @@ -501,7 +503,8 @@ 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_queue_push_req_front(context->req, true);
ocf_queue_push_req(context->req,
OCF_QUEUE_ALLOW_SYNC | OCF_QUEUE_PRIO_HIGH);
return;

err_req:
Expand Down
4 changes: 2 additions & 2 deletions src/mngt/ocf_mngt_flush.c
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ static void _ocf_mngt_flush_portion_end(void *private_data, int error)
return;
}

ocf_queue_push_req_back(fc->req, false);
ocf_queue_push_req(fc->req, 0);
}


Expand Down Expand Up @@ -452,7 +452,7 @@ static void _ocf_mngt_flush_container(
fc->ticks1 = 0;
fc->ticks2 = UINT_MAX;

ocf_queue_push_req_back(fc->req, true);
ocf_queue_push_req(fc->req, OCF_QUEUE_ALLOW_SYNC);
return;

finish:
Expand Down
Loading

0 comments on commit d96f8ea

Please sign in to comment.