Merge pull request #193 from arutk/wo_improvements

Write-only cache mode improvements
This commit is contained in:
Michał Mielewczyk 2019-06-13 11:38:15 +02:00 committed by GitHub
commit aeaeafb639
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 26 additions and 35 deletions

View File

@ -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);

View File

@ -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_ */

View File

@ -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;
}

View File

@ -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);