diff --git a/src/engine/engine_rd.c b/src/engine/engine_rd.c index ed9a5aa..0a58a9e 100644 --- a/src/engine/engine_rd.c +++ b/src/engine/engine_rd.c @@ -101,7 +101,7 @@ static void _ocf_read_generic_miss_complete(struct ocf_request *req, int error) } } -static inline void _ocf_read_generic_submit_hit(struct ocf_request *req) +void ocf_read_generic_submit_hit(struct ocf_request *req) { env_atomic_set(&req->req_remaining, ocf_engine_io_count(req)); @@ -135,7 +135,7 @@ err_alloc: _ocf_read_generic_miss_complete(req, -OCF_ERR_NO_MEM); } -int ocf_read_generic_do(struct ocf_request *req) +static int _ocf_read_generic_do(struct ocf_request *req) { struct ocf_cache *cache = req->cache; @@ -191,7 +191,7 @@ int ocf_read_generic_do(struct ocf_request *req) /* Submit IO */ if (ocf_engine_is_hit(req)) - _ocf_read_generic_submit_hit(req); + ocf_read_generic_submit_hit(req); else _ocf_read_generic_submit_miss(req); @@ -206,8 +206,8 @@ int ocf_read_generic_do(struct ocf_request *req) } static const struct ocf_io_if _io_if_read_generic_resume = { - .read = ocf_read_generic_do, - .write = ocf_read_generic_do, + .read = _ocf_read_generic_do, + .write = _ocf_read_generic_do, .resume = ocf_engine_on_resume, }; @@ -294,7 +294,7 @@ int ocf_read_generic(struct ocf_request *req) OCF_DEBUG_RQ(req, "NO LOCK"); } else { /* Lock was acquired can perform IO */ - ocf_read_generic_do(req); + _ocf_read_generic_do(req); } } else { OCF_DEBUG_RQ(req, "LOCK ERROR %d", lock); diff --git a/src/engine/engine_rd.h b/src/engine/engine_rd.h index 4881bf3..56373b5 100644 --- a/src/engine/engine_rd.h +++ b/src/engine/engine_rd.h @@ -8,6 +8,6 @@ int ocf_read_generic(struct ocf_request *req); -int ocf_read_generic_do(struct ocf_request *req); +void ocf_read_generic_submit_hit(struct ocf_request *req); #endif /* ENGINE_RD_H_ */ diff --git a/src/engine/engine_wo.c b/src/engine/engine_wo.c index 764d3c6..13f09fa 100644 --- a/src/engine/engine_wo.c +++ b/src/engine/engine_wo.c @@ -167,38 +167,30 @@ static void _ocf_read_wo_core_complete(struct ocf_request *req, int error) int ocf_read_wo_do(struct ocf_request *req) { - ocf_cache_t cache = req->cache; - - if (ocf_engine_is_hit(req)) { - /* read hit - just fetch the data from cache using standard read path - */ - ocf_read_generic_do(req); - return 0; - } - ocf_req_get(req); - if (req->info.re_part) { - OCF_DEBUG_RQ(req, "Re-Part"); + /* Lack of cacheline repartitioning here is deliberate. WO cache mode + * reads should not affect cacheline status as reading data from the + * cache is just an internal optimization. Also WO cache mode is + * designed to be used with partitioning based on write life-time hints + * and read requests do not carry write lifetime hint by definition. + */ - OCF_METADATA_LOCK_WR(); + if (ocf_engine_is_hit(req)) { + /* read hit - just fetch the data from cache */ + OCF_DEBUG_RQ(req, "Submit cache hit"); + ocf_read_generic_submit_hit(req); + } else { - /* Probably some cache lines are assigned into wrong - * partition. Need to move it to new one - */ - ocf_part_move(req); - - OCF_METADATA_UNLOCK_WR(); + OCF_DEBUG_RQ(req, "Submit core"); + ocf_submit_volume_req(&req->core->volume, req, + _ocf_read_wo_core_complete); } - OCF_DEBUG_RQ(req, "Submit core"); - ocf_submit_volume_req(&req->core->volume, req, _ocf_read_wo_core_complete); - ocf_engine_update_request_stats(req); ocf_engine_update_block_stats(req); ocf_req_put(req); - return 0; } diff --git a/src/utils/utils_io.c b/src/utils/utils_io.c index 719fd22..ff405c8 100644 --- a/src/utils/utils_io.c +++ b/src/utils/utils_io.c @@ -236,12 +236,11 @@ void ocf_submit_cache_reqs(struct ocf_cache *cache, struct ocf_io *io; int err; uint32_t i; - uint32_t entry = ocf_bytes_2_lines(cache, req->byte_position + offset) - - ocf_bytes_2_lines(cache, req->byte_position); - struct ocf_map_info *map_info = &req->map[entry]; + uint32_t first_cl = ocf_bytes_2_lines(cache, req->byte_position + + offset) - ocf_bytes_2_lines(cache, req->byte_position); ENV_BUG_ON(req->byte_length < offset + size); - ENV_BUG_ON(entry + reqs > req->core_line_count); + ENV_BUG_ON(first_cl + reqs > req->core_line_count); cache_stats = &req->core->counters->cache_blocks; @@ -253,7 +252,7 @@ void ocf_submit_cache_reqs(struct ocf_cache *cache, } addr = ocf_metadata_map_lg2phy(cache, - map_info[0].coll_idx); + req->map[first_cl].coll_idx); addr *= ocf_line_size(cache); addr += cache->device->metadata_offset; addr += ((req->byte_position + offset) % ocf_line_size(cache)); @@ -288,7 +287,7 @@ void ocf_submit_cache_reqs(struct ocf_cache *cache, } addr = ocf_metadata_map_lg2phy(cache, - map_info[i].coll_idx); + req->map[first_cl + i].coll_idx); addr *= ocf_line_size(cache); addr += cache->device->metadata_offset; bytes = ocf_line_size(cache);