Remove "unsafe" path from standby load

Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
This commit is contained in:
Robert Baldyga 2022-01-03 20:10:40 +01:00
parent 86a2896bcf
commit 4aa3d8f9df
3 changed files with 16 additions and 34 deletions

View File

@ -215,19 +215,12 @@ static void __init_parts_attached(ocf_cache_t cache)
ocf_lru_init(cache, &cache->free); ocf_lru_init(cache, &cache->free);
} }
static void __populate_free_unsafe(ocf_cache_t cache) static void __populate_free(ocf_cache_t cache)
{
uint64_t free_clines = ocf_metadata_collision_table_entries(cache);
ocf_lru_populate(cache, free_clines, false);
}
static void __populate_free_safe(ocf_cache_t cache)
{ {
uint64_t free_clines = ocf_metadata_collision_table_entries(cache) - uint64_t free_clines = ocf_metadata_collision_table_entries(cache) -
ocf_get_cache_occupancy(cache); ocf_get_cache_occupancy(cache);
ocf_lru_populate(cache, free_clines, true); ocf_lru_populate(cache, free_clines);
} }
static ocf_error_t __init_cleaning_policy(ocf_cache_t cache) static ocf_error_t __init_cleaning_policy(ocf_cache_t cache)
@ -316,7 +309,7 @@ static ocf_error_t init_attached_data_structures(ocf_cache_t cache)
ocf_metadata_init_hash_table(cache); ocf_metadata_init_hash_table(cache);
ocf_metadata_init_collision(cache); ocf_metadata_init_collision(cache);
__init_parts_attached(cache); __init_parts_attached(cache);
__populate_free_safe(cache); __populate_free(cache);
result = __init_cleaning_policy(cache); result = __init_cleaning_policy(cache);
if (result) { if (result) {
@ -502,7 +495,7 @@ static void _recovery_reset_cline_metadata(struct ocf_cache *cache,
ocf_cleaning_init_cache_block(cache, cline); ocf_cleaning_init_cache_block(cache, cline);
} }
static void _ocf_mngt_rebuild_metadata(ocf_cache_t cache, bool initialized) static void _ocf_mngt_rebuild_metadata(ocf_cache_t cache)
{ {
ocf_cache_line_t cline; ocf_cache_line_t cline;
ocf_core_id_t core_id; ocf_core_id_t core_id;
@ -519,8 +512,7 @@ static void _ocf_mngt_rebuild_metadata(ocf_cache_t cache, bool initialized)
OCF_COND_RESCHED(step, 128); OCF_COND_RESCHED(step, 128);
ocf_metadata_get_core_info(cache, cline, &core_id, &core_line); ocf_metadata_get_core_info(cache, cline, &core_id, &core_line);
if (!initialized) metadata_clear_dirty_if_invalid(cache, cline);
metadata_clear_dirty_if_invalid(cache, cline);
any_valid = metadata_clear_valid_if_clean(cache, cline); any_valid = metadata_clear_valid_if_clean(cache, cline);
if (!any_valid || core_id >= OCF_CORE_MAX) { if (!any_valid || core_id >= OCF_CORE_MAX) {
@ -538,12 +530,7 @@ static void _ocf_mngt_rebuild_metadata(ocf_cache_t cache, bool initialized)
static void _ocf_mngt_recovery_rebuild_metadata(ocf_cache_t cache) static void _ocf_mngt_recovery_rebuild_metadata(ocf_cache_t cache)
{ {
_ocf_mngt_rebuild_metadata(cache, false); _ocf_mngt_rebuild_metadata(cache);
}
static void _ocf_mngt_standby_rebuild_metadata(ocf_cache_t cache)
{
_ocf_mngt_rebuild_metadata(cache, true);
} }
static inline ocf_error_t _ocf_init_cleaning_policy(ocf_cache_t cache, static inline ocf_error_t _ocf_init_cleaning_policy(ocf_cache_t cache,
@ -572,7 +559,7 @@ static void _ocf_mngt_load_post_metadata_load(ocf_pipeline_t pipeline,
if (context->metadata.shutdown_status != ocf_metadata_clean_shutdown) { if (context->metadata.shutdown_status != ocf_metadata_clean_shutdown) {
_ocf_mngt_recovery_rebuild_metadata(cache); _ocf_mngt_recovery_rebuild_metadata(cache);
__populate_free_safe(cache); __populate_free(cache);
} }
result = _ocf_init_cleaning_policy(cache, cache->cleaner.policy, result = _ocf_init_cleaning_policy(cache, cache->cleaner.policy,
@ -2064,7 +2051,7 @@ static void _ocf_mngt_standby_init_structures_attach(ocf_pipeline_t pipeline,
ocf_cache_t cache = context->cache; ocf_cache_t cache = context->cache;
init_attached_data_structures_recovery(cache, true); init_attached_data_structures_recovery(cache, true);
__populate_free_safe(cache); __populate_free(cache);
ocf_pipeline_next(pipeline); ocf_pipeline_next(pipeline);
} }
@ -2094,14 +2081,14 @@ static void _ocf_mngt_standby_init_pio_concurrency(ocf_pipeline_t pipeline,
OCF_PL_NEXT_ON_SUCCESS_RET(context->pipeline, result); OCF_PL_NEXT_ON_SUCCESS_RET(context->pipeline, result);
} }
static void _ocf_mngt_standby_recovery_unsafe(ocf_pipeline_t pipeline, static void _ocf_mngt_standby_recovery(ocf_pipeline_t pipeline,
void *priv, ocf_pipeline_arg_t arg) void *priv, ocf_pipeline_arg_t arg)
{ {
struct ocf_cache_attach_context *context = priv; struct ocf_cache_attach_context *context = priv;
ocf_cache_t cache = context->cache; ocf_cache_t cache = context->cache;
_ocf_mngt_standby_rebuild_metadata(cache); _ocf_mngt_recovery_rebuild_metadata(cache);
__populate_free_unsafe(cache); __populate_free(cache);
ocf_pipeline_next(pipeline); ocf_pipeline_next(pipeline);
} }
@ -2178,7 +2165,7 @@ struct ocf_pipeline_properties _ocf_mngt_cache_standby_load_pipeline_properties
OCF_PL_STEP(_ocf_mngt_standby_init_cleaning), OCF_PL_STEP(_ocf_mngt_standby_init_cleaning),
OCF_PL_STEP(_ocf_mngt_standby_preapre_mempool), OCF_PL_STEP(_ocf_mngt_standby_preapre_mempool),
OCF_PL_STEP(_ocf_mngt_standby_init_pio_concurrency), OCF_PL_STEP(_ocf_mngt_standby_init_pio_concurrency),
OCF_PL_STEP(_ocf_mngt_standby_recovery_unsafe), OCF_PL_STEP(_ocf_mngt_standby_recovery),
OCF_PL_STEP(_ocf_mngt_standby_post_init), OCF_PL_STEP(_ocf_mngt_standby_post_init),
OCF_PL_STEP_TERMINATOR(), OCF_PL_STEP_TERMINATOR(),
}, },

View File

@ -891,8 +891,7 @@ static ocf_cache_line_t next_phys_invalid(ocf_cache_t cache,
} }
/* put invalid cachelines on freelist partition lru list */ /* put invalid cachelines on freelist partition lru list */
void ocf_lru_populate(ocf_cache_t cache, ocf_cache_line_t num_free_clines, void ocf_lru_populate(ocf_cache_t cache, ocf_cache_line_t num_free_clines)
bool safe)
{ {
ocf_cache_line_t phys, cline; ocf_cache_line_t phys, cline;
ocf_cache_line_t collision_table_entries = ocf_cache_line_t collision_table_entries =
@ -906,10 +905,7 @@ void ocf_lru_populate(ocf_cache_t cache, ocf_cache_line_t num_free_clines,
for (i = 0; i < num_free_clines; i++) { for (i = 0; i < num_free_clines; i++) {
/* find first invalid cacheline */ /* find first invalid cacheline */
phys = next_phys_invalid(cache, phys); phys = next_phys_invalid(cache, phys);
if (safe) ENV_BUG_ON(phys == collision_table_entries);
ENV_BUG_ON(phys == collision_table_entries);
else if (phys == collision_table_entries)
break;
cline = ocf_metadata_map_phy2lg(cache, phys); cline = ocf_metadata_map_phy2lg(cache, phys);
++phys; ++phys;
@ -925,7 +921,7 @@ void ocf_lru_populate(ocf_cache_t cache, ocf_cache_line_t num_free_clines,
/* we should have reached the last invalid cache line */ /* we should have reached the last invalid cache line */
phys = next_phys_invalid(cache, phys); phys = next_phys_invalid(cache, phys);
ENV_BUG_ON(safe && phys != collision_table_entries); ENV_BUG_ON(phys != collision_table_entries);
env_atomic_set(&cache->free.runtime->curr_size, i); env_atomic_set(&cache->free.runtime->curr_size, i);
} }

View File

@ -31,8 +31,7 @@ void ocf_lru_clean(ocf_cache_t cache, struct ocf_user_part *user_part,
void ocf_lru_repart(ocf_cache_t cache, ocf_cache_line_t cline, void ocf_lru_repart(ocf_cache_t cache, ocf_cache_line_t cline,
struct ocf_part *src_upart, struct ocf_part *dst_upart); struct ocf_part *src_upart, struct ocf_part *dst_upart);
uint32_t ocf_lru_num_free(ocf_cache_t cache); uint32_t ocf_lru_num_free(ocf_cache_t cache);
void ocf_lru_populate(ocf_cache_t cache, ocf_cache_line_t num_free_clines, void ocf_lru_populate(ocf_cache_t cache, ocf_cache_line_t num_free_clines);
bool safe);
struct ocf_lru_list *ocf_lru_get_list(struct ocf_part *part, struct ocf_lru_list *ocf_lru_get_list(struct ocf_part *part,
uint32_t lru_idx, bool clean); uint32_t lru_idx, bool clean);
void ocf_lru_remove_locked(ocf_cache_t cache, struct ocf_lru_list *list, void ocf_lru_remove_locked(ocf_cache_t cache, struct ocf_lru_list *list,