Skip to content

Commit

Permalink
Add rotational field to ocf_core struct
Browse files Browse the repository at this point in the history
This property is necessary if we don't want to sort cache lines
or flush containers when the backend device is not an HDD.
Sorting cache lines or flush containers on non-HDDs is a waste of time.
Add functions to work with rotational property.
Make the cleaner's cache line sorting dependent on the core volume type.
If any of the core volumes is HDD, sort cache lines, otherwise do not.
Minor typos fix

Signed-off-by: Slawomir Jankowski <[email protected]>
  • Loading branch information
Ostrokrzew committed Jun 10, 2021
1 parent 68fccaf commit b856931
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 7 deletions.
4 changes: 4 additions & 0 deletions inc/ocf_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down
2 changes: 1 addition & 1 deletion src/cleaning/alru.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/eviction/lru.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 6 additions & 3 deletions src/mngt/ocf_mngt_flush.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
15 changes: 15 additions & 0 deletions src/ocf_cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions src/ocf_cache_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -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__ */
10 changes: 10 additions & 0 deletions src/ocf_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/ocf_core_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/utils/utils_cleaner.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit b856931

Please sign in to comment.