diff --git a/src/engine/engine_common.c b/src/engine/engine_common.c index 6eb50837..190e1a9e 100644 --- a/src/engine/engine_common.c +++ b/src/engine/engine_common.c @@ -36,6 +36,12 @@ void ocf_engine_error(struct ocf_request *req, } } +static inline void ocf_req_force_pt(struct ocf_request *req) +{ + ocf_req_set_mapping_error(req); + req->force_pt = true; +} + void ocf_engine_lookup_map_entry(struct ocf_cache *cache, struct ocf_map_info *entry, ocf_core_id_t core_id, uint64_t core_line) @@ -449,7 +455,7 @@ static inline int ocf_prepare_clines_hit(struct ocf_request *req, /* Since target part is empty and disabled, request should be submited in * pass-through */ if (res == OCF_PART_IS_DISABLED) - ocf_req_set_mapping_error(req); + ocf_req_force_pt(req); ocf_req_hash_unlock_rd(req); @@ -461,14 +467,14 @@ static inline int ocf_prepare_clines_hit(struct ocf_request *req, if (space_managment_evict_do(req->cache, req, clines_to_evict) == LOOKUP_MISS) { - ocf_req_set_mapping_error(req); + ocf_req_force_pt(req); goto unlock; } if (!ocf_part_is_enabled(&req->cache->user_parts[req->part_id])) { /* Target part is disabled but had some cachelines assigned. Submit * request in pass-through after eviction has been made */ - ocf_req_set_mapping_error(req); + ocf_req_force_pt(req); goto unlock; } @@ -495,7 +501,7 @@ static inline int ocf_prepare_clines_miss(struct ocf_request *req, * is not out of free cachelines */ res = ocf_part_check_space(req, &clines_to_evict); if (res == OCF_PART_IS_DISABLED) { - ocf_req_set_mapping_error(req); + ocf_req_force_pt(req); ocf_req_hash_unlock_wr(req); return lock_status; } @@ -510,7 +516,7 @@ static inline int ocf_prepare_clines_miss(struct ocf_request *req, if (lock_status < 0) { /* Mapping succeeded, but we failed to acquire cacheline lock. * Don't try to evict, just return error to caller */ - ocf_req_set_mapping_error(req); + ocf_req_force_pt(req); } ocf_req_hash_unlock_wr(req); @@ -525,7 +531,7 @@ static inline int ocf_prepare_clines_miss(struct ocf_request *req, if (space_managment_evict_do(req->cache, req, clines_to_evict) == LOOKUP_MISS) { - ocf_req_set_mapping_error(req); + ocf_req_force_pt(req); goto unlock; } @@ -534,7 +540,7 @@ static inline int ocf_prepare_clines_miss(struct ocf_request *req, * are evicted, don't try to map cachelines - we don't want to insert * new cachelines - the request should be submited in pass through mode * instead */ - ocf_req_set_mapping_error(req); + ocf_req_force_pt(req); goto unlock; } @@ -544,7 +550,7 @@ static inline int ocf_prepare_clines_miss(struct ocf_request *req, lock_status = lock_clines(req, engine_cbs); if (lock_status < 0) - ocf_req_set_mapping_error(req); + ocf_req_force_pt(req); unlock: ocf_metadata_end_exclusive_access(metadata_lock); @@ -578,7 +584,7 @@ int ocf_engine_prepare_clines(struct ocf_request *req, promote = ocf_promotion_req_should_promote( req->cache->promotion_policy, req); if (!promote) { - ocf_req_set_mapping_error(req); + ocf_req_force_pt(req); ocf_req_hash_unlock_rd(req); return lock; } diff --git a/src/engine/engine_pt.c b/src/engine/engine_pt.c index 9144d84a..9e832e16 100644 --- a/src/engine/engine_pt.c +++ b/src/engine/engine_pt.c @@ -99,6 +99,17 @@ static const struct ocf_io_if _io_if_pt_resume = { .write = ocf_read_pt_do, }; +static inline bool ocf_req_can_use_cache(struct ocf_request *req) +{ + if (req->force_pt) + return false; + + if (!req->seq_cutoff || !ocf_engine_is_dirty_all(req)) + return false; + + return true; +} + int ocf_read_pt(struct ocf_request *req) { bool use_cache = false; @@ -120,7 +131,7 @@ int ocf_read_pt(struct ocf_request *req) /* Traverse request to check if there are mapped cache lines */ ocf_engine_traverse(req); - if (req->seq_cutoff && ocf_engine_is_dirty_all(req)) { + if (ocf_req_can_use_cache(req)) { use_cache = true; } else { if (ocf_engine_mapped_count(req)) { diff --git a/src/ocf_request.h b/src/ocf_request.h index 08431dc5..30d732bc 100644 --- a/src/ocf_request.h +++ b/src/ocf_request.h @@ -184,6 +184,9 @@ struct ocf_request { uint8_t seq_cutoff : 1; /*!< Sequential cut off set for this request */ + uint8_t force_pt : 1; + /*!< Froce request to be submitted in pass-through mode */ + uint8_t wi_second_pass : 1; /*!< Set after first pass of WI write is completed */ diff --git a/tests/unit/tests/engine/engine_common.c/prepare_clines_hit.c b/tests/unit/tests/engine/engine_common.c/prepare_clines_hit.c index d66bc8ae..4609c671 100644 --- a/tests/unit/tests/engine/engine_common.c/prepare_clines_hit.c +++ b/tests/unit/tests/engine/engine_common.c/prepare_clines_hit.c @@ -2,8 +2,7 @@ * src/engine/engine_common.c * ocf_prepare_clines_hit * - * INSERT HERE LIST OF FUNCTIONS YOU WANT TO LEAVE - * ONE FUNCTION PER LINE + ocf_req_force_pt * */ diff --git a/tests/unit/tests/engine/engine_common.c/prepare_clines_miss.c b/tests/unit/tests/engine/engine_common.c/prepare_clines_miss.c index 81fec823..00b70dbc 100644 --- a/tests/unit/tests/engine/engine_common.c/prepare_clines_miss.c +++ b/tests/unit/tests/engine/engine_common.c/prepare_clines_miss.c @@ -2,8 +2,7 @@ * src/engine/engine_common.c * ocf_prepare_clines_miss * - * INSERT HERE LIST OF FUNCTIONS YOU WANT TO LEAVE - * ONE FUNCTION PER LINE + ocf_req_force_pt * */