diff --git a/src/mngt/ocf_mngt_cache.c b/src/mngt/ocf_mngt_cache.c index 7da5964..7a112cc 100644 --- a/src/mngt/ocf_mngt_cache.c +++ b/src/mngt/ocf_mngt_cache.c @@ -1661,6 +1661,29 @@ static void _ocf_mngt_load_superblock(ocf_pipeline_t pipeline, } } +static void _ocf_mngt_attach_update_cores_atomic(ocf_pipeline_t pipeline, + void *priv, ocf_pipeline_arg_t arg) +{ + struct ocf_cache_attach_context *context = priv; + ocf_cache_t cache = context->cache; + ocf_core_t core; + ocf_core_id_t core_id; + ocf_seq_no_t core_sequence_no = 0; + + cache->conf_meta->curr_core_seq_no = 0; + + if (!ocf_volume_is_atomic(ocf_cache_get_volume(cache))) + OCF_PL_NEXT_RET(pipeline); + + for_each_core_metadata(cache, core, core_id) { + core_sequence_no = ocf_mngt_get_core_seq_no(cache); + if (core_sequence_no == OCF_SEQ_NO_INVALID) + OCF_PL_FINISH_RET(pipeline, -OCF_ERR_TOO_MANY_CORES); + + core->conf_meta->seq_no = core_sequence_no; + } +} + static void _ocf_mngt_init_cleaner(ocf_pipeline_t pipeline, void *priv, ocf_pipeline_arg_t arg) { @@ -1927,6 +1950,7 @@ struct ocf_pipeline_properties _ocf_mngt_cache_attach_pipeline_properties = { OCF_PL_STEP(_ocf_mngt_attach_check_ram), OCF_PL_STEP(_ocf_mngt_attach_prepare_metadata), OCF_PL_STEP(_ocf_mngt_test_volume), + OCF_PL_STEP(_ocf_mngt_attach_update_cores_atomic), OCF_PL_STEP(_ocf_mngt_init_cleaner), OCF_PL_STEP(_ocf_mngt_init_promotion), OCF_PL_STEP(_ocf_mngt_attach_init_metadata), diff --git a/src/mngt/ocf_mngt_core.c b/src/mngt/ocf_mngt_core.c index afdc6e9..6986e8d 100644 --- a/src/mngt/ocf_mngt_core.c +++ b/src/mngt/ocf_mngt_core.c @@ -1,5 +1,6 @@ /* * Copyright(c) 2012-2022 Intel Corporation + * Copyright(c) 2024 Huawei Technologies * SPDX-License-Identifier: BSD-3-Clause */ @@ -14,7 +15,7 @@ #include "../ocf_def_priv.h" #include "../cleaning/cleaning_ops.h" -static ocf_seq_no_t _ocf_mngt_get_core_seq_no(ocf_cache_t cache) +ocf_seq_no_t ocf_mngt_get_core_seq_no(ocf_cache_t cache) { if (cache->conf_meta->curr_core_seq_no == OCF_SEQ_NO_MAX) return OCF_SEQ_NO_INVALID; @@ -482,7 +483,7 @@ static void ocf_mngt_cache_add_core_insert(ocf_pipeline_t pipeline, /* Add core sequence number for atomic metadata matching */ if (ocf_volume_is_atomic(&cache->device->volume)) { - core_sequence_no = _ocf_mngt_get_core_seq_no(cache); + core_sequence_no = ocf_mngt_get_core_seq_no(cache); if (core_sequence_no == OCF_SEQ_NO_INVALID) OCF_PL_FINISH_RET(pipeline, -OCF_ERR_TOO_MANY_CORES); } diff --git a/src/mngt/ocf_mngt_core_priv.h b/src/mngt/ocf_mngt_core_priv.h index 1784ad0..edecc19 100644 --- a/src/mngt/ocf_mngt_core_priv.h +++ b/src/mngt/ocf_mngt_core_priv.h @@ -1,5 +1,6 @@ /* * Copyright(c) 2012-2021 Intel Corporation + * Copyright(c) 2024 Huawei Technologies * SPDX-License-Identifier: BSD-3-Clause */ @@ -12,4 +13,6 @@ int ocf_mngt_core_init_front_volume(ocf_core_t core); void ocf_mngt_core_clear_uuid_metadata(ocf_core_t core); +ocf_seq_no_t ocf_mngt_get_core_seq_no(ocf_cache_t cache); + #endif /* __OCF_MNGT_CORE_PRIV_H__ */