Skip to content

Commit

Permalink
Merge pull request #447 from mmichal10/v20.12-force-pt
Browse files Browse the repository at this point in the history
`Force pass through` flag
  • Loading branch information
Robert Baldyga authored Feb 1, 2021
2 parents 7f72a94 + 4bdc3db commit 6af1cf8
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 14 deletions.
24 changes: 15 additions & 9 deletions src/engine/engine_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);

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

Expand All @@ -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;
}
Expand All @@ -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);
Expand All @@ -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;
}

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

Expand All @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down
13 changes: 12 additions & 1 deletion src/engine/engine_pt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)) {
Expand Down
3 changes: 3 additions & 0 deletions src/ocf_request.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

Expand Down
3 changes: 1 addition & 2 deletions tests/unit/tests/engine/engine_common.c/prepare_clines_hit.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
* <tested_file_path>src/engine/engine_common.c</tested_file_path>
* <tested_function>ocf_prepare_clines_hit</tested_function>
* <functions_to_leave>
* INSERT HERE LIST OF FUNCTIONS YOU WANT TO LEAVE
* ONE FUNCTION PER LINE
ocf_req_force_pt
* </functions_to_leave>
*/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
* <tested_file_path>src/engine/engine_common.c</tested_file_path>
* <tested_function>ocf_prepare_clines_miss</tested_function>
* <functions_to_leave>
* INSERT HERE LIST OF FUNCTIONS YOU WANT TO LEAVE
* ONE FUNCTION PER LINE
ocf_req_force_pt
* </functions_to_leave>
*/

Expand Down

0 comments on commit 6af1cf8

Please sign in to comment.