Add cache line recovery utils to OCF internal API
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
This commit is contained in:
parent
a7bdaa751d
commit
ccd0abfea5
@ -481,43 +481,6 @@ err:
|
|||||||
OCF_PL_FINISH_RET(pipeline, -OCF_ERR_START_CACHE_FAIL);
|
OCF_PL_FINISH_RET(pipeline, -OCF_ERR_START_CACHE_FAIL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _recovery_rebuild_cline_metadata(ocf_cache_t cache,
|
|
||||||
ocf_core_id_t core_id, uint64_t core_line,
|
|
||||||
ocf_cache_line_t cache_line)
|
|
||||||
{
|
|
||||||
ocf_core_t core = ocf_cache_get_core(cache, core_id);
|
|
||||||
ocf_part_id_t part_id;
|
|
||||||
ocf_cache_line_t hash_index;
|
|
||||||
struct ocf_part_runtime *part;
|
|
||||||
|
|
||||||
part_id = PARTITION_DEFAULT;
|
|
||||||
part = cache->user_parts[part_id].part.runtime;
|
|
||||||
|
|
||||||
ocf_metadata_set_partition_id(cache, cache_line, part_id);
|
|
||||||
env_atomic_inc(&part->curr_size);
|
|
||||||
|
|
||||||
hash_index = ocf_metadata_hash_func(cache, core_line, core_id);
|
|
||||||
ocf_metadata_add_to_collision(cache, core_id, core_line, hash_index,
|
|
||||||
cache_line);
|
|
||||||
|
|
||||||
ocf_lru_init_cline(cache, cache_line);
|
|
||||||
|
|
||||||
ocf_lru_add(cache, cache_line);
|
|
||||||
|
|
||||||
env_atomic_inc(&core->runtime_meta->cached_clines);
|
|
||||||
env_atomic_inc(&core->runtime_meta->
|
|
||||||
part_counters[part_id].cached_clines);
|
|
||||||
|
|
||||||
if (metadata_test_dirty(cache, cache_line)) {
|
|
||||||
env_atomic_inc(&core->runtime_meta->dirty_clines);
|
|
||||||
env_atomic_inc(&core->runtime_meta->
|
|
||||||
part_counters[part_id].dirty_clines);
|
|
||||||
if (!env_atomic64_read(&core->runtime_meta->dirty_since))
|
|
||||||
env_atomic64_cmpxchg(&core->runtime_meta->dirty_since, 0,
|
|
||||||
env_ticks_to_secs(env_get_tick_count()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void _recovery_reset_cline_metadata(struct ocf_cache *cache,
|
static void _recovery_reset_cline_metadata(struct ocf_cache *cache,
|
||||||
ocf_cache_line_t cline)
|
ocf_cache_line_t cline)
|
||||||
{
|
{
|
||||||
@ -546,7 +509,7 @@ static void _ocf_mngt_recovery_rebuild_metadata(ocf_cache_t cache)
|
|||||||
(!dirty_only || metadata_test_dirty(cache,
|
(!dirty_only || metadata_test_dirty(cache,
|
||||||
cline))) {
|
cline))) {
|
||||||
/* Rebuild metadata for mapped cache line */
|
/* Rebuild metadata for mapped cache line */
|
||||||
_recovery_rebuild_cline_metadata(cache, core_id,
|
ocf_cline_rebuild_metadata(cache, core_id,
|
||||||
core_line, cline);
|
core_line, cline);
|
||||||
if (dirty_only)
|
if (dirty_only)
|
||||||
metadata_clear_valid_if_clean(cache, cline);
|
metadata_clear_valid_if_clean(cache, cline);
|
||||||
|
@ -167,3 +167,40 @@ void set_cache_line_dirty(struct ocf_cache *cache, uint8_t start_bit,
|
|||||||
|
|
||||||
ocf_cleaning_set_hot_cache_line(cache, line);
|
ocf_cleaning_set_hot_cache_line(cache, line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ocf_cline_rebuild_metadata(ocf_cache_t cache,
|
||||||
|
ocf_core_id_t core_id, uint64_t core_line,
|
||||||
|
ocf_cache_line_t cache_line)
|
||||||
|
{
|
||||||
|
ocf_core_t core = ocf_cache_get_core(cache, core_id);
|
||||||
|
ocf_part_id_t part_id;
|
||||||
|
ocf_cache_line_t hash_index;
|
||||||
|
struct ocf_part_runtime *part;
|
||||||
|
|
||||||
|
part_id = PARTITION_DEFAULT;
|
||||||
|
part = cache->user_parts[part_id].part.runtime;
|
||||||
|
|
||||||
|
ocf_metadata_set_partition_id(cache, cache_line, part_id);
|
||||||
|
env_atomic_inc(&part->curr_size);
|
||||||
|
|
||||||
|
hash_index = ocf_metadata_hash_func(cache, core_line, core_id);
|
||||||
|
ocf_metadata_add_to_collision(cache, core_id, core_line, hash_index,
|
||||||
|
cache_line);
|
||||||
|
|
||||||
|
ocf_lru_init_cline(cache, cache_line);
|
||||||
|
|
||||||
|
ocf_lru_add(cache, cache_line);
|
||||||
|
|
||||||
|
env_atomic_inc(&core->runtime_meta->cached_clines);
|
||||||
|
env_atomic_inc(&core->runtime_meta->
|
||||||
|
part_counters[part_id].cached_clines);
|
||||||
|
|
||||||
|
if (metadata_test_dirty(cache, cache_line)) {
|
||||||
|
env_atomic_inc(&core->runtime_meta->dirty_clines);
|
||||||
|
env_atomic_inc(&core->runtime_meta->
|
||||||
|
part_counters[part_id].dirty_clines);
|
||||||
|
if (!env_atomic64_read(&core->runtime_meta->dirty_since))
|
||||||
|
env_atomic64_cmpxchg(&core->runtime_meta->dirty_since, 0,
|
||||||
|
env_ticks_to_secs(env_get_tick_count()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -123,6 +123,10 @@ void set_cache_line_clean(struct ocf_cache *cache, uint8_t start_bit,
|
|||||||
void set_cache_line_dirty(struct ocf_cache *cache, uint8_t start_bit,
|
void set_cache_line_dirty(struct ocf_cache *cache, uint8_t start_bit,
|
||||||
uint8_t end_bit, struct ocf_request *req, uint32_t map_idx);
|
uint8_t end_bit, struct ocf_request *req, uint32_t map_idx);
|
||||||
|
|
||||||
|
void ocf_cline_rebuild_metadata(ocf_cache_t cache,
|
||||||
|
ocf_core_id_t core_id, uint64_t core_line,
|
||||||
|
ocf_cache_line_t cache_line);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Remove cache line from cleaning policy
|
* @brief Remove cache line from cleaning policy
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user