Initialize partitions during cache start

Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
This commit is contained in:
Adam Rutkowski 2021-06-18 12:02:52 +02:00
parent dca93964e3
commit 36107fd528
3 changed files with 14 additions and 5 deletions

View File

@ -577,10 +577,8 @@ static int ocf_metadata_init_fixed_size(struct ocf_cache *cache,
cache->user_parts[i].clean_pol = &part_runtime_meta[i].clean_pol;
cache->user_parts[i].part.runtime =
&part_runtime_meta[i].runtime;
cache->user_parts[i].part.id = i;
}
cache->free.runtime= &part_runtime_meta[PARTITION_FREELIST].runtime;
cache->free.id = PARTITION_FREELIST;
/* Set core metadata */
core_meta_config = METADATA_MEM_POOL(ctrl,

View File

@ -190,7 +190,7 @@ static void __init_parts_attached(ocf_cache_t cache)
ocf_lru_init(cache, &cache->free);
}
static void __init_free(ocf_cache_t cache)
static void __populate_free(ocf_cache_t cache)
{
uint64_t free_clines = ocf_metadata_collision_table_entries(cache) -
ocf_get_cache_occupancy(cache);
@ -245,6 +245,11 @@ static void __deinit_promotion_policy(ocf_cache_t cache)
cache->promotion_policy = NULL;
}
static void __init_free(ocf_cache_t cache)
{
cache->free.id = PARTITION_FREELIST;
}
static void __init_cores(ocf_cache_t cache)
{
/* No core devices yet */
@ -287,7 +292,7 @@ static ocf_error_t init_attached_data_structures(ocf_cache_t cache)
ocf_metadata_init_hash_table(cache);
ocf_metadata_init_collision(cache);
__init_parts_attached(cache);
__init_free(cache);
__populate_free(cache);
result = __init_cleaning_policy(cache);
if (result) {
@ -462,7 +467,7 @@ void _ocf_mngt_load_init_instance_complete(void *priv, int error)
}
if (context->metadata.shutdown_status != ocf_metadata_clean_shutdown)
__init_free(cache);
__populate_free(cache);
cleaning_policy = cache->conf_meta->cleaning_policy_type;
if (!cleaning_policy_ops[cleaning_policy].initialize)
@ -1148,6 +1153,7 @@ static void _ocf_mngt_cache_init(ocf_cache_t cache,
/* Init Partitions */
ocf_user_part_init(cache);
__init_free(cache);
__init_cores(cache);
__init_metadata_version(cache);

View File

@ -82,9 +82,14 @@ static int ocf_user_part_lst_cmp_valid(struct ocf_cache *cache,
void ocf_user_part_init(struct ocf_cache *cache)
{
unsigned i;
ocf_lst_init(cache, &cache->user_part_list, OCF_USER_IO_CLASS_MAX,
ocf_user_part_lst_getter_valid,
ocf_user_part_lst_cmp_valid);
for (i = 0; i < OCF_USER_IO_CLASS_MAX + 1; i++)
cache->user_parts[i].part.id = i;
}
void ocf_user_part_move(struct ocf_request *req)