engine_rd: Refactor
Code beautification only, no functional changes. Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
This commit is contained in:
parent
5531b9cc79
commit
a3bccbba6c
@ -28,32 +28,23 @@ 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);
|
||||||
|
req->complete(req, req->error);
|
||||||
/* Complete request */
|
ocf_req_put(req);
|
||||||
req->complete(req, req->error);
|
|
||||||
|
|
||||||
/* Free the request at the last point
|
|
||||||
* of the completion path
|
|
||||||
*/
|
|
||||||
ocf_req_put(req);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,45 +52,38 @@ 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);
|
|
||||||
|
|
||||||
ocf_core_stats_core_error_update(req->core, OCF_READ);
|
|
||||||
|
|
||||||
ctx_data_free(cache->owner, req->cp_data);
|
|
||||||
req->cp_data = NULL;
|
|
||||||
|
|
||||||
/* Invalidate metadata */
|
|
||||||
ocf_engine_invalidate(req);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Copy pages to copy vec, since this is the one needed
|
|
||||||
* by the above layer
|
|
||||||
*/
|
|
||||||
ctx_data_cpy(cache->owner, req->cp_data, req->data, 0, 0,
|
|
||||||
req->byte_length);
|
|
||||||
|
|
||||||
/* Complete request */
|
|
||||||
req->complete(req, req->error);
|
req->complete(req, req->error);
|
||||||
|
|
||||||
ocf_engine_backfill(req);
|
ocf_core_stats_core_error_update(req->core, OCF_READ);
|
||||||
|
|
||||||
|
ctx_data_free(cache->owner, req->cp_data);
|
||||||
|
req->cp_data = NULL;
|
||||||
|
|
||||||
|
/* Invalidate metadata */
|
||||||
|
ocf_engine_invalidate(req);
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Copy data to the backfill buffer */
|
||||||
|
if (req->cp_data) {
|
||||||
|
ctx_data_cpy(cache->owner, req->cp_data, req->data, 0, 0,
|
||||||
|
req->byte_length);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Complete request */
|
||||||
|
req->complete(req, req->error);
|
||||||
|
|
||||||
|
ocf_engine_backfill(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ocf_read_generic_submit_hit(struct ocf_request *req)
|
void ocf_read_generic_submit_hit(struct ocf_request *req)
|
||||||
|
Loading…
Reference in New Issue
Block a user