Do not modify core_count on cache load / activate

Increment core_count only on core addition, and decrement it only on core
removal.

Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
This commit is contained in:
Robert Baldyga 2022-03-31 10:00:24 +02:00
parent 25434cb8d1
commit 9ebb0de878
2 changed files with 1 additions and 11 deletions

View File

@ -328,8 +328,6 @@ static void _ocf_mngt_close_all_uninitialized_cores(
cache->core[i].counters = NULL; cache->core[i].counters = NULL;
cache->core[i].added = false; cache->core[i].added = false;
} }
cache->conf_meta->core_count = 0;
} }
/** /**
@ -350,9 +348,6 @@ static void _ocf_mngt_load_add_cores(ocf_pipeline_t pipeline,
OCF_ASSERT_PLUGGED(cache); OCF_ASSERT_PLUGGED(cache);
/* Count value will be re-calculated on the basis of 'valid' flag */
cache->conf_meta->core_count = 0;
/* Check in metadata which cores were saved in cache metadata */ /* Check in metadata which cores were saved in cache metadata */
for_each_core_metadata(cache, core, core_id) { for_each_core_metadata(cache, core, core_id) {
struct ocf_metadata_uuid *muuid; struct ocf_metadata_uuid *muuid;
@ -401,7 +396,6 @@ static void _ocf_mngt_load_add_cores(ocf_pipeline_t pipeline,
} }
core->added = true; core->added = true;
cache->conf_meta->core_count++;
core->volume.cache = cache; core->volume.cache = cache;
if (ocf_mngt_core_init_front_volume(core)) if (ocf_mngt_core_init_front_volume(core))
@ -1969,7 +1963,6 @@ static void _ocf_mngt_cache_stop_remove_cores(ocf_cache_t cache, bool attached)
if (--no == 0) if (--no == 0)
break; break;
} }
ENV_BUG_ON(cache->conf_meta->core_count != 0);
} }
static void ocf_mngt_cache_stop_remove_cores(ocf_pipeline_t pipeline, static void ocf_mngt_cache_stop_remove_cores(ocf_pipeline_t pipeline,
@ -2995,8 +2988,6 @@ static void _ocf_mngt_cache_unplug(ocf_cache_t cache, bool stop,
struct _ocf_mngt_cache_unplug_context *context, struct _ocf_mngt_cache_unplug_context *context,
_ocf_mngt_cache_unplug_end_t cmpl, void *priv) _ocf_mngt_cache_unplug_end_t cmpl, void *priv)
{ {
ENV_BUG_ON(stop && cache->conf_meta->core_count != 0);
context->cmpl = cmpl; context->cmpl = cmpl;
context->priv = priv; context->priv = priv;
context->cache = cache; context->cache = cache;

View File

@ -118,6 +118,7 @@ void cache_mngt_core_remove_from_meta(ocf_core_t core)
core->conf_meta->seq_no = OCF_SEQ_NO_INVALID; core->conf_meta->seq_no = OCF_SEQ_NO_INVALID;
env_bit_clear(core_id, cache->conf_meta->valid_core_bitmap); env_bit_clear(core_id, cache->conf_meta->valid_core_bitmap);
cache->conf_meta->core_count--;
ocf_metadata_end_exclusive_access(&cache->metadata.lock); ocf_metadata_end_exclusive_access(&cache->metadata.lock);
} }
@ -134,8 +135,6 @@ void cache_mngt_core_remove_from_cache(ocf_core_t core)
if (!core->opened && --cache->ocf_core_inactive_count == 0) if (!core->opened && --cache->ocf_core_inactive_count == 0)
env_bit_clear(ocf_cache_state_incomplete, &cache->cache_state); env_bit_clear(ocf_cache_state_incomplete, &cache->cache_state);
cache->conf_meta->core_count--;
} }
void ocf_mngt_cache_put(ocf_cache_t cache) void ocf_mngt_cache_put(ocf_cache_t cache)