ocf_reqest: Store core handle instead of core_id

Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
This commit is contained in:
Robert Baldyga
2019-05-20 17:01:03 +02:00
parent eccd4a0163
commit 0490dd8bd4
26 changed files with 78 additions and 108 deletions

View File

@@ -51,25 +51,23 @@ static void _ocf_backfill_complete(struct ocf_request *req, int error)
* request. Also, complete original request only if this is the last
* sub-request to complete
*/
if (env_atomic_dec_return(&req->req_remaining) == 0) {
/* We must free the pages we have allocated */
ctx_data_secure_erase(cache->owner, req->data);
ctx_data_munlock(cache->owner, req->data);
ctx_data_free(cache->owner, req->data);
req->data = NULL;
if (env_atomic_dec_return(&req->req_remaining))
return;
if (req->error) {
env_atomic_inc(&cache->core[req->core_id].
counters->cache_errors.write);
ocf_engine_invalidate(req);
} else {
ocf_req_unlock(req);
/* We must free the pages we have allocated */
ctx_data_secure_erase(cache->owner, req->data);
ctx_data_munlock(cache->owner, req->data);
ctx_data_free(cache->owner, req->data);
req->data = NULL;
/* always free the request at the last point
* of the completion path
*/
ocf_req_put(req);
}
if (req->error) {
env_atomic_inc(&req->core->counters->cache_errors.write);
ocf_engine_invalidate(req);
} else {
ocf_req_unlock(req);
/* put the request at the last point of the completion path */
ocf_req_put(req);
}
}

View File

@@ -24,7 +24,7 @@ void ocf_engine_error(struct ocf_request *req,
if (stop_cache)
env_bit_clear(ocf_cache_state_running, &cache->cache_state);
ocf_core_log(&cache->core[req->core_id], log_err,
ocf_core_log(req->core, log_err,
"%s sector: %" ENV_PRIu64 ", bytes: %u\n", msg,
BYTES_TO_SECTORS(req->byte_position), req->byte_length);
}
@@ -158,7 +158,7 @@ void ocf_engine_traverse(struct ocf_request *req)
uint64_t core_line;
struct ocf_cache *cache = req->cache;
ocf_core_id_t core_id = req->core_id;
ocf_core_id_t core_id = ocf_core_get_id(req->core);
OCF_DEBUG_TRACE(req->cache);
@@ -201,6 +201,7 @@ int ocf_engine_check(struct ocf_request *req)
uint64_t core_line;
struct ocf_cache *cache = req->cache;
ocf_core_id_t core_id = ocf_core_get_id(req->core);
OCF_DEBUG_TRACE(req->cache);
@@ -217,7 +218,7 @@ int ocf_engine_check(struct ocf_request *req)
continue;
}
if (_ocf_engine_check_map_entry(cache, entry, req->core_id)) {
if (_ocf_engine_check_map_entry(cache, entry, core_id)) {
/* Mapping is invalid */
entry->invalid = true;
req->info.seq_req = false;
@@ -247,6 +248,7 @@ static void ocf_engine_map_cache_line(struct ocf_request *req,
ocf_cache_line_t *cache_line)
{
struct ocf_cache *cache = req->cache;
ocf_core_id_t core_id = ocf_core_get_id(req->core);
ocf_part_id_t part_id = req->part_id;
ocf_cleaning_t clean_policy_type;
@@ -266,7 +268,7 @@ static void ocf_engine_map_cache_line(struct ocf_request *req,
ocf_metadata_add_to_partition(cache, part_id, *cache_line);
/* Add the block to the corresponding collision list */
ocf_metadata_add_to_collision(cache, req->core_id, core_line, hash_index,
ocf_metadata_add_to_collision(cache, core_id, core_line, hash_index,
*cache_line);
ocf_eviction_init_cache_line(cache, *cache_line, part_id);
@@ -320,7 +322,7 @@ void ocf_engine_map(struct ocf_request *req)
struct ocf_map_info *entry;
uint64_t core_line;
int status = LOOKUP_MAPPED;
ocf_core_id_t core_id = req->core_id;
ocf_core_id_t core_id = ocf_core_get_id(req->core);
if (ocf_engine_unmapped_count(req))
status = space_managment_evict_do(cache, req,
@@ -442,12 +444,10 @@ void ocf_engine_clean(struct ocf_request *req)
void ocf_engine_update_block_stats(struct ocf_request *req)
{
struct ocf_cache *cache = req->cache;
ocf_core_id_t core_id = req->core_id;
ocf_part_id_t part_id = req->part_id;
struct ocf_counters_block *blocks;
blocks = &cache->core[core_id].counters->
blocks = &req->core->counters->
part_counters[part_id].blocks;
if (req->rw == OCF_READ)
@@ -460,19 +460,15 @@ void ocf_engine_update_block_stats(struct ocf_request *req)
void ocf_engine_update_request_stats(struct ocf_request *req)
{
struct ocf_cache *cache = req->cache;
ocf_core_id_t core_id = req->core_id;
ocf_part_id_t part_id = req->part_id;
struct ocf_counters_req *reqs;
switch (req->rw) {
case OCF_READ:
reqs = &cache->core[core_id].counters->
part_counters[part_id].read_reqs;
reqs = &req->core->counters->part_counters[part_id].read_reqs;
break;
case OCF_WRITE:
reqs = &cache->core[core_id].counters->
part_counters[part_id].write_reqs;
reqs = &req->core->counters->part_counters[part_id].write_reqs;
break;
default:
ENV_BUG();

View File

@@ -16,7 +16,7 @@
static void _ocf_d2c_completion(struct ocf_request *req, int error)
{
ocf_core_t core = &req->cache->core[req->core_id];
ocf_core_t core = req->core;
req->error = error;
OCF_DEBUG_RQ(req, "Completion");
@@ -38,8 +38,7 @@ static void _ocf_d2c_completion(struct ocf_request *req, int error)
int ocf_io_d2c(struct ocf_request *req)
{
ocf_cache_t cache = req->cache;
ocf_core_t core = &cache->core[req->core_id];
ocf_core_t core = req->core;
OCF_DEBUG_TRACE(req->cache);

View File

@@ -62,10 +62,9 @@ static void _ocf_discard_core_complete(struct ocf_io *io, int error)
static int _ocf_discard_core(struct ocf_request *req)
{
struct ocf_cache *cache = req->cache;
struct ocf_io *io;
io = ocf_volume_new_io(&cache->core[req->core_id].volume);
io = ocf_volume_new_io(&req->core->volume);
if (!io) {
_ocf_discard_complete_req(req, -ENOMEM);
return -ENOMEM;

View File

@@ -43,8 +43,7 @@ static void _ocf_read_fast_complete(struct ocf_request *req, int error)
if (req->error) {
OCF_DEBUG_RQ(req, "ERROR");
env_atomic_inc(&req->cache->core[req->core_id].counters->
cache_errors.read);
env_atomic_inc(&req->core->counters->cache_errors.read);
ocf_engine_push_req_front_pt(req);
} else {
ocf_req_unlock(req);

View File

@@ -20,8 +20,7 @@ static void _ocf_invalidate_req(struct ocf_request *req, int error)
{
if (error) {
req->error = error;
env_atomic_inc(&req->cache->core[req->core_id].counters->
cache_errors.write);
env_atomic_inc(&req->core->counters->cache_errors.write);
}
if (env_atomic_dec_return(&req->req_remaining))

View File

@@ -48,7 +48,7 @@ int ocf_engine_ops(struct ocf_request *req)
env_atomic_set(&req->req_remaining, 2);
/* Submit operation into core device */
ocf_submit_volume_req(&cache->core[req->core_id].volume, req,
ocf_submit_volume_req(&req->core->volume, req,
_ocf_engine_ops_complete);
ocf_submit_cache_reqs(cache, req->map, req, req->rw,

View File

@@ -28,8 +28,7 @@ static void _ocf_read_pt_complete(struct ocf_request *req, int error)
if (req->error) {
req->info.core_error = 1;
env_atomic_inc(&req->cache->core[req->core_id].counters->
core_errors.read);
env_atomic_inc(&req->core->counters->core_errors.read);
}
/* Complete request */
@@ -43,15 +42,12 @@ static void _ocf_read_pt_complete(struct ocf_request *req, int error)
static inline void _ocf_read_pt_submit(struct ocf_request *req)
{
struct ocf_cache *cache = req->cache;
env_atomic_set(&req->req_remaining, 1); /* Core device IO */
OCF_DEBUG_RQ(req, "Submit");
/* Core read */
ocf_submit_volume_req(&cache->core[req->core_id].volume, req,
_ocf_read_pt_complete);
ocf_submit_volume_req(&req->core->volume, req, _ocf_read_pt_complete);
}
int ocf_read_pt_do(struct ocf_request *req)
@@ -91,7 +87,7 @@ int ocf_read_pt_do(struct ocf_request *req)
/* Update statistics */
ocf_engine_update_block_stats(req);
env_atomic64_inc(&cache->core[req->core_id].counters->
env_atomic64_inc(&req->core->counters->
part_counters[req->part_id].read_reqs.pass_through);
/* Put OCF request - decrease reference counter */

View File

@@ -38,8 +38,7 @@ static void _ocf_read_generic_hit_complete(struct ocf_request *req, int error)
OCF_DEBUG_RQ(req, "HIT completion");
if (req->error) {
env_atomic_inc(&req->cache->core[req->core_id].
counters->cache_errors.read);
env_atomic_inc(&req->core->counters->cache_errors.read);
ocf_engine_push_req_front_pt(req);
} else {
@@ -78,8 +77,7 @@ static void _ocf_read_generic_miss_complete(struct ocf_request *req, int error)
req->complete(req, req->error);
req->info.core_error = 1;
env_atomic_inc(&cache->core[req->core_id].
counters->core_errors.read);
env_atomic_inc(&req->core->counters->core_errors.read);
ctx_data_free(cache->owner, req->cp_data);
req->cp_data = NULL;
@@ -128,7 +126,7 @@ static inline void _ocf_read_generic_submit_miss(struct ocf_request *req)
goto err_alloc;
/* Submit read request to core device. */
ocf_submit_volume_req(&cache->core[req->core_id].volume, req,
ocf_submit_volume_req(&req->core->volume, req,
_ocf_read_generic_miss_complete);
return;

View File

@@ -24,8 +24,7 @@ static void _ocf_read_wa_complete(struct ocf_request *req, int error)
if (req->error) {
req->info.core_error = 1;
env_atomic_inc(&req->cache->core[req->core_id].counters->
core_errors.write);
env_atomic_inc(&req->core->counters->core_errors.write);
}
/* Complete request */
@@ -72,12 +71,12 @@ int ocf_write_wa(struct ocf_request *req)
/* Submit write IO to the core */
env_atomic_set(&req->req_remaining, 1);
ocf_submit_volume_req(&cache->core[req->core_id].volume, req,
ocf_submit_volume_req(&req->core->volume, req,
_ocf_read_wa_complete);
/* Update statistics */
ocf_engine_update_block_stats(req);
env_atomic64_inc(&cache->core[req->core_id].counters->
env_atomic64_inc(&req->core->counters->
part_counters[req->part_id].write_reqs.pass_through);
}

View File

@@ -88,8 +88,7 @@ static const struct ocf_io_if _io_if_wb_flush_metadata = {
static void _ocf_write_wb_complete(struct ocf_request *req, int error)
{
if (error) {
env_atomic_inc(&req->cache->core[req->core_id].counters->
cache_errors.write);
env_atomic_inc(&req->core->counters->cache_errors.write);
req->error |= error;
}

View File

@@ -26,8 +26,7 @@ static const struct ocf_io_if _io_if_wi_flush_metadata = {
static void _ocf_write_wi_io_flush_metadata(struct ocf_request *req, int error)
{
if (error) {
env_atomic_inc(&req->cache->core[req->core_id].counters->
cache_errors.write);
env_atomic_inc(&req->core->counters->cache_errors.write);
req->error |= error;
}
@@ -78,8 +77,7 @@ static void _ocf_write_wi_core_complete(struct ocf_request *req, int error)
if (error) {
req->error = error;
req->info.core_error = 1;
env_atomic_inc(&req->cache->core[req->core_id].counters->
core_errors.write);
env_atomic_inc(&req->core->counters->core_errors.write);
}
if (env_atomic_dec_return(&req->req_remaining))
@@ -101,8 +99,6 @@ static void _ocf_write_wi_core_complete(struct ocf_request *req, int error)
static int _ocf_write_wi_do(struct ocf_request *req)
{
struct ocf_cache *cache = req->cache;
/* Get OCF request - increase reference counter */
ocf_req_get(req);
@@ -111,12 +107,12 @@ static int _ocf_write_wi_do(struct ocf_request *req)
OCF_DEBUG_RQ(req, "Submit");
/* Submit write IO to the core */
ocf_submit_volume_req(&cache->core[req->core_id].volume, req,
ocf_submit_volume_req(&req->core->volume, req,
_ocf_write_wi_core_complete);
/* Update statistics */
ocf_engine_update_block_stats(req);
env_atomic64_inc(&cache->core[req->core_id].counters->
env_atomic64_inc(&req->core->counters->
part_counters[req->part_id].write_reqs.pass_through);
/* Put OCF request - decrease reference counter */

View File

@@ -48,8 +48,7 @@ static void _ocf_write_wt_cache_complete(struct ocf_request *req, int error)
{
if (error) {
req->error = req->error ?: error;
env_atomic_inc(&req->cache->core[req->core_id].counters->
cache_errors.write);
env_atomic_inc(&req->core->counters->cache_errors.write);
if (req->error)
inc_fallback_pt_error_counter(req->cache);
@@ -63,8 +62,7 @@ static void _ocf_write_wt_core_complete(struct ocf_request *req, int error)
if (error) {
req->error = error;
req->info.core_error = 1;
env_atomic_inc(&req->cache->core[req->core_id].counters->
core_errors.write);
env_atomic_inc(&req->core->counters->core_errors.write);
}
_ocf_write_wt_req_complete(req);
@@ -93,7 +91,7 @@ static inline void _ocf_write_wt_submit(struct ocf_request *req)
ocf_engine_io_count(req), _ocf_write_wt_cache_complete);
/* To core */
ocf_submit_volume_req(&cache->core[req->core_id].volume, req,
ocf_submit_volume_req(&req->core->volume, req,
_ocf_write_wt_core_complete);
}

View File

@@ -50,8 +50,7 @@ static const struct ocf_io_if _io_if_zero_purge = {
static void _ocf_zero_io_flush_metadata(struct ocf_request *req, int error)
{
if (error) {
env_atomic_inc(&req->cache->core[req->core_id].counters->
cache_errors.write);
env_atomic_inc(&req->core->counters->cache_errors.write);
req->error = error;
}