engine_rd: Refactor

Code beautification only, no functional changes.

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
This commit is contained in:
Michal Mielewczyk 2024-08-28 14:10:54 +02:00
parent 5531b9cc79
commit a3bccbba6c

View File

@ -28,54 +28,39 @@ static void _ocf_read_generic_hit_complete(struct ocf_request *req, int error)
struct ocf_alock *c = ocf_cache_line_concurrency( struct ocf_alock *c = ocf_cache_line_concurrency(
req->cache); req->cache);
OCF_DEBUG_RQ(req, "HIT completion");
if (error) { if (error) {
req->error |= error; req->error |= error;
ocf_core_stats_cache_error_update(req->core, OCF_READ); ocf_core_stats_cache_error_update(req->core, OCF_READ);
inc_fallback_pt_error_counter(req->cache); inc_fallback_pt_error_counter(req->cache);
} }
/* Handle callback-caller race to let only one of the two complete the if (env_atomic_dec_return(&req->req_remaining) > 0)
* request. Also, complete original request only if this is the last return;
* sub-request to complete
*/
if (env_atomic_dec_return(&req->req_remaining) == 0) {
OCF_DEBUG_RQ(req, "HIT completion");
if (req->error) { if (req->error) {
ocf_queue_push_req_pt(req); ocf_queue_push_req_pt(req);
} else { } else {
ocf_req_unlock(c, req); ocf_req_unlock(c, req);
/* Complete request */
req->complete(req, req->error); req->complete(req, req->error);
/* Free the request at the last point
* of the completion path
*/
ocf_req_put(req); ocf_req_put(req);
} }
} }
}
static void _ocf_read_generic_miss_complete(struct ocf_request *req, int error) static void _ocf_read_generic_miss_complete(struct ocf_request *req, int error)
{ {
struct ocf_cache *cache = req->cache; struct ocf_cache *cache = req->cache;
OCF_DEBUG_RQ(req, "MISS completion");
if (error) if (error)
req->error = error; req->error = error;
/* Handle callback-caller race to let only one of the two complete the if (env_atomic_dec_return(&req->req_remaining) > 0)
* request. Also, complete original request only if this is the last return;
* sub-request to complete
*/
if (env_atomic_dec_return(&req->req_remaining) == 0) {
OCF_DEBUG_RQ(req, "MISS completion");
if (req->error) { if (req->error) {
/*
* --- Do not submit this request to write-back-thread.
* Stop it here ---
*/
req->complete(req, req->error); req->complete(req, req->error);
ocf_core_stats_core_error_update(req->core, OCF_READ); ocf_core_stats_core_error_update(req->core, OCF_READ);
@ -89,18 +74,17 @@ static void _ocf_read_generic_miss_complete(struct ocf_request *req, int error)
return; return;
} }
/* Copy pages to copy vec, since this is the one needed /* Copy data to the backfill buffer */
* by the above layer if (req->cp_data) {
*/
ctx_data_cpy(cache->owner, req->cp_data, req->data, 0, 0, ctx_data_cpy(cache->owner, req->cp_data, req->data, 0, 0,
req->byte_length); req->byte_length);
}
/* Complete request */ /* Complete request */
req->complete(req, req->error); req->complete(req, req->error);
ocf_engine_backfill(req); ocf_engine_backfill(req);
} }
}
void ocf_read_generic_submit_hit(struct ocf_request *req) void ocf_read_generic_submit_hit(struct ocf_request *req)
{ {