From 718dc743c8a72477ec3cad452009c48b0cf2f4ea Mon Sep 17 00:00:00 2001 From: Michal Mielewczyk Date: Thu, 15 Oct 2020 18:19:13 -0400 Subject: [PATCH] Enable particular ioclass eviction If partition's occupancy limit is reached, cachelines should be evicted from request's target partition. Information whether particular partition eviction should be triggered is carried as a flag by request which triggered eviction. Signed-off-by: Michal Mielewczyk --- src/eviction/eviction.c | 32 +++++++++++++++++++++++++++----- src/ocf_request.h | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 5 deletions(-) diff --git a/src/eviction/eviction.c b/src/eviction/eviction.c index 5a41935..bf73447 100644 --- a/src/eviction/eviction.c +++ b/src/eviction/eviction.c @@ -40,6 +40,22 @@ static uint32_t ocf_evict_calculate(struct ocf_user_part *part, return to_evict; } +static inline uint32_t ocf_evict_part_do(ocf_cache_t cache, + ocf_queue_t io_queue, const uint32_t evict_cline_no, + struct ocf_user_part *target_part) +{ + uint32_t to_evict = 0; + + if (!evp_lru_can_evict(cache)) + return 0; + + to_evict = ocf_evict_calculate(&cache->user_parts[target_part_id], + evict_cline_no); + + return ocf_eviction_need_space(cache, io_queue, + target_part, to_evict); +} + static inline uint32_t ocf_evict_do(ocf_cache_t cache, ocf_queue_t io_queue, const uint32_t evict_cline_no, struct ocf_user_part *target_part) @@ -109,12 +125,18 @@ int space_managment_evict_do(struct ocf_cache *cache, uint32_t free; struct ocf_user_part *req_part = &cache->user_parts[req->part_id]; - free = ocf_freelist_num_free(cache->freelist); - if (evict_cline_no <= free) - return LOOKUP_MAPPED; + if (ocf_req_part_evict(req)) { + evicted = ocf_evict_part_do(cache, req->io_queue, evict_cline_no, + req_part); + } else { + free = ocf_freelist_num_free(cache->freelist); + if (evict_cline_no <= free) + return LOOKUP_MAPPED; - evict_cline_no -= free; - evicted = ocf_evict_do(cache, req->io_queue, evict_cline_no, req_part); + evict_cline_no -= free; + + evicted = ocf_evict_do(cache, req->io_queue, evict_cline_no, req_part); + } if (evict_cline_no <= evicted) return LOOKUP_MAPPED; diff --git a/src/ocf_request.h b/src/ocf_request.h index 2d9c7f8..21885b2 100644 --- a/src/ocf_request.h +++ b/src/ocf_request.h @@ -191,6 +191,9 @@ struct ocf_request { uint8_t wi_second_pass : 1; /*!< Set after first pass of WI write is completed */ + uint8_t part_evict : 1; + /* !< Some cachelines from request's partition must be evicted */ + log_sid_t sid; /*!< Tracing sequence ID */ @@ -332,6 +335,40 @@ void ocf_req_clear_map(struct ocf_request *req); */ void ocf_req_hash(struct ocf_request *req); +/** + * @brief Request should trigger eviction from it's target partition + * + * @param req - OCF request + */ +static inline void ocf_req_set_part_evict(struct ocf_request *req) +{ + req->part_evict = true; +} + +/** + * @brief Request shouldn't trigger eviction from it's target partition + * + * @param req - OCF request + */ +static inline void ocf_req_clear_part_evict(struct ocf_request *req) +{ + req->part_evict = false; +} + +/** + * @brief Check wheter request shouldn't trigger eviction from it's target + * partition or any partition + * + * @param req - OCF request + * @return true - Eviciton should be triggered from request's target partition + * @return false - Eviction should be triggered with respect to eviction + * priority + */ +static inline bool ocf_req_part_evict(struct ocf_request *req) +{ + return req->part_evict; +} + int ocf_req_set_dirty(struct ocf_request *req); /**