Separate engine map/evict (refactoring)
This temporarily increases amount of boiler-plate code, but this is going to be mitigated in the following commits. Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
This commit is contained in:
@@ -215,6 +215,7 @@ int ocf_read_generic(struct ocf_request *req)
|
||||
bool mapped;
|
||||
int lock = OCF_LOCK_NOT_ACQUIRED;
|
||||
struct ocf_cache *cache = req->cache;
|
||||
bool promote = true;
|
||||
|
||||
ocf_io_start(&req->ioi.io);
|
||||
|
||||
@@ -252,21 +253,25 @@ int ocf_read_generic(struct ocf_request *req)
|
||||
}
|
||||
}
|
||||
|
||||
if (!mapped) {
|
||||
promote = ocf_promotion_req_should_promote(
|
||||
cache->promotion_policy, req);
|
||||
}
|
||||
|
||||
OCF_METADATA_UNLOCK_RD();
|
||||
|
||||
/*- END Metadata RD access -------------------------------------------*/
|
||||
|
||||
if (!mapped) {
|
||||
|
||||
if (!mapped && promote) {
|
||||
/*- Metadata WR access ---------------------------------------*/
|
||||
|
||||
OCF_METADATA_LOCK_WR();
|
||||
|
||||
/* Now there is exclusive access for metadata. May traverse once
|
||||
* again. If there are misses need to call eviction. This
|
||||
* process is called 'mapping'.
|
||||
*/
|
||||
ocf_engine_map(req);
|
||||
if (ocf_engine_evict(req) == LOOKUP_MAPPED)
|
||||
ocf_engine_map(req);
|
||||
|
||||
if (!req->info.mapping_error) {
|
||||
if (ocf_engine_is_hit(req)) {
|
||||
@@ -288,7 +293,7 @@ int ocf_read_generic(struct ocf_request *req)
|
||||
/*- END Metadata WR access -----------------------------------*/
|
||||
}
|
||||
|
||||
if (!req->info.mapping_error) {
|
||||
if (promote && !req->info.mapping_error) {
|
||||
if (lock >= 0) {
|
||||
if (lock != OCF_LOCK_ACQUIRED) {
|
||||
/* Lock was not acquired, need to wait for resume */
|
||||
|
Reference in New Issue
Block a user