diff --git a/inc/ocf_core.h b/inc/ocf_core.h index 4c75c556..842df71b 100644 --- a/inc/ocf_core.h +++ b/inc/ocf_core.h @@ -240,6 +240,10 @@ int ocf_core_visit(ocf_cache_t cache, ocf_core_visitor_t visitor, void *cntx, */ int ocf_core_get_info(ocf_core_t core, struct ocf_core_info *info); +void ocf_core_set_rotational(ocf_core_t core, uint8_t val); + +bool ocf_core_is_rotational(ocf_core_t core); + /** * @brief Set core private data * diff --git a/src/cleaning/alru.c b/src/cleaning/alru.c index 6b6f3545..4e0e8a10 100644 --- a/src/cleaning/alru.c +++ b/src/cleaning/alru.c @@ -817,7 +817,7 @@ void cleaning_alru_perform_cleaning(ocf_cache_t cache, ocf_cleaner_end_t cmpl) fctx->attribs.cmpl_fn = alru_clean_complete; fctx->attribs.lock_cacheline = true; fctx->attribs.lock_metadata = false; - fctx->attribs.do_sort = true; + fctx->attribs.do_sort = ocf_cache_is_any_core_rotational(cache); fctx->attribs.io_queue = cache->cleaner.io_queue; fctx->clines_no = config->flush_max_buffers; diff --git a/src/eviction/lru.c b/src/eviction/lru.c index 10f47f92..54bdc092 100644 --- a/src/eviction/lru.c +++ b/src/eviction/lru.c @@ -538,7 +538,7 @@ void evp_lru_clean(ocf_cache_t cache, struct ocf_user_part *part, struct ocf_cleaner_attribs attribs = { .lock_cacheline = false, .lock_metadata = true, - .do_sort = true, + .do_sort = ocf_cache_is_any_core_rotational(cache), .cmpl_context = &part->cleaning, .cmpl_fn = evp_lru_clean_end, diff --git a/src/mngt/ocf_mngt_flush.c b/src/mngt/ocf_mngt_flush.c index 5e5f0086..094e11e1 100644 --- a/src/mngt/ocf_mngt_flush.c +++ b/src/mngt/ocf_mngt_flush.c @@ -476,15 +476,18 @@ static void _ocf_mngt_flush_containers( struct flush_container *fctbl, uint32_t fcnum, ocf_flush_complete_t complete) { + ocf_cache_t cache; int i; if (fcnum == 0) { complete(context, 0); return; } - - /* Sort data. Smallest sectors first (0...n). */ - ocf_cleaner_sort_flush_containers(fctbl, fcnum); + cache = context->cache; + if (ocf_cache_is_any_core_rotational(cache)) { + /* Sort data. Smallest sectors first (0...n). */ + ocf_cleaner_sort_flush_containers(fctbl, fcnum); + } env_atomic_set(&context->fcs.error, 0); env_atomic_set(&context->fcs.count, 1); diff --git a/src/ocf_cache.c b/src/ocf_cache.c index f91253e5..e9fc3bd0 100644 --- a/src/ocf_cache.c +++ b/src/ocf_cache.c @@ -26,6 +26,21 @@ int ocf_cache_set_name(ocf_cache_t cache, const char *src, size_t src_size) src, src_size); } +bool ocf_cache_is_any_core_rotational(ocf_cache_t cache) +{ + ocf_core_t core; + ocf_core_id_t core_id; + uint8_t result = 0; + + for_each_core(cache, core, core_id){ + result = ocf_core_is_rotational(core); + if (result) + return result; + } + + return result; +} + const char *ocf_cache_get_name(ocf_cache_t cache) { OCF_CHECK_NULL(cache); diff --git a/src/ocf_cache_priv.h b/src/ocf_cache_priv.h index e80c8b47..7ecd7d20 100644 --- a/src/ocf_cache_priv.h +++ b/src/ocf_cache_priv.h @@ -191,4 +191,6 @@ static inline uint64_t ocf_get_cache_occupancy(ocf_cache_t cache) int ocf_cache_set_name(ocf_cache_t cache, const char *src, size_t src_size); +bool ocf_cache_is_any_core_rotational(ocf_cache_t cache); + #endif /* __OCF_CACHE_PRIV_H__ */ diff --git a/src/ocf_core.c b/src/ocf_core.c index 3983e5cc..b23f9187 100644 --- a/src/ocf_core.c +++ b/src/ocf_core.c @@ -569,6 +569,16 @@ int ocf_core_volume_type_init(ocf_ctx_t ctx) &ocf_core_volume_extended); } +void ocf_core_set_rotational(ocf_core_t core, uint8_t val) +{ + core->rotational = val; +} + +bool ocf_core_is_rotational(ocf_core_t core) +{ + return core->rotational; +} + int ocf_core_get_info(ocf_core_t core, struct ocf_core_info *info) { ocf_cache_t cache; diff --git a/src/ocf_core_priv.h b/src/ocf_core_priv.h index ad52771d..878b8995 100644 --- a/src/ocf_core_priv.h +++ b/src/ocf_core_priv.h @@ -91,6 +91,8 @@ struct ocf_core { /* This bit means that core is added into cache */ uint32_t added : 1; + uint32_t rotational : 1; + struct ocf_counters_core *counters; void *priv; diff --git a/src/utils/utils_cleaner.c b/src/utils/utils_cleaner.c index 3cc165d5..5f2730e4 100644 --- a/src/utils/utils_cleaner.c +++ b/src/utils/utils_cleaner.c @@ -774,9 +774,9 @@ static int _ocf_cleaner_cmp_private(const void *a, const void *b) * * @param req cleaning request * @param i_out number of already filled map requests (remaining to be filled - * with missed + * with missed) */ -static int _ocf_cleaner_do_fire(struct ocf_request *req, uint32_t i_out, +static int _ocf_cleaner_do_fire(struct ocf_request *req, uint32_t i_out, bool do_sort) { uint32_t i;