diff --git a/src/mngt/ocf_mngt_cache.c b/src/mngt/ocf_mngt_cache.c index 6852f55..ca66e0a 100644 --- a/src/mngt/ocf_mngt_cache.c +++ b/src/mngt/ocf_mngt_cache.c @@ -401,8 +401,6 @@ static int _ocf_mngt_init_instance_add_cores( struct ocf_cache_attach_context *context) { ocf_cache_t cache = context->cache; - /* FIXME: This is temporary hack. Remove after storing name it meta. */ - char core_name[OCF_CORE_NAME_SIZE]; ocf_core_t core; ocf_core_id_t core_id; int ret = -1; @@ -427,14 +425,6 @@ static int _ocf_mngt_init_instance_add_cores( if (!core->volume.type) goto err; - ret = snprintf(core_name, sizeof(core_name), "core%d", core_id); - if (ret < 0 || ret >= sizeof(core_name)) - goto err; - - ret = ocf_core_set_name(core, core_name, sizeof(core_name)); - if (ret) - goto err; - tvolume = ocf_mngt_core_pool_lookup(ocf_cache_get_ctx(cache), &core->volume.uuid, core->volume.type); if (tvolume) { diff --git a/src/mngt/ocf_mngt_core.c b/src/mngt/ocf_mngt_core.c index 867886d..85eef77 100644 --- a/src/mngt/ocf_mngt_core.c +++ b/src/mngt/ocf_mngt_core.c @@ -21,6 +21,12 @@ static ocf_seq_no_t _ocf_mngt_get_core_seq_no(ocf_cache_t cache) return ++cache->conf_meta->curr_core_seq_no; } +static int ocf_mngt_core_set_name(ocf_core_t core, const char *name) +{ + return env_strncpy(core->conf_meta->name, OCF_CORE_NAME_SIZE, + name, OCF_CORE_NAME_SIZE); +} + static int _ocf_uuid_set(const struct ocf_volume_uuid *uuid, struct ocf_metadata_uuid *muuid) { @@ -482,8 +488,8 @@ static void ocf_mngt_cache_add_core_prepare(ocf_pipeline_t pipeline, if (!result && !context->cfg.try_add) OCF_PL_FINISH_RET(context->pipeline, -OCF_ERR_CORE_EXIST); - result = ocf_core_set_name(&cache->core[context->cfg.core_id], - context->cfg.name, OCF_CORE_NAME_SIZE); + result = ocf_mngt_core_set_name(&cache->core[context->cfg.core_id], + context->cfg.name); if (result) OCF_PL_FINISH_RET(context->pipeline, result); diff --git a/src/mngt/ocf_mngt_flush.c b/src/mngt/ocf_mngt_flush.c index a09f82c..4ddb7a8 100644 --- a/src/mngt/ocf_mngt_flush.c +++ b/src/mngt/ocf_mngt_flush.c @@ -179,13 +179,12 @@ static int _ocf_mngt_get_sectors(ocf_cache_t cache, ocf_core_id_t core_id, break; } - ocf_core_log(&cache->core[core_id], log_debug, + ocf_core_log(core, log_debug, "%u dirty cache lines to clean\n", j); if (dirty != j) { - ocf_cache_log(cache, log_debug, "Wrong number of dirty " - "blocks for flushing core %s (%u!=%u)\n", - cache->core[core_id].name, j, dirty); + ocf_core_log(core, log_debug, "Wrong number of dirty " + "blocks for flushing (%u!=%u)\n", j, dirty); } diff --git a/src/ocf_core.c b/src/ocf_core.c index eef361f..f337b69 100644 --- a/src/ocf_core.c +++ b/src/ocf_core.c @@ -66,19 +66,11 @@ int ocf_core_get_by_name(ocf_cache_t cache, const char *name, return -OCF_ERR_CORE_NOT_EXIST; } -int ocf_core_set_name(ocf_core_t core, const char *src, size_t src_size) -{ - OCF_CHECK_NULL(core); - OCF_CHECK_NULL(src); - - return env_strncpy(core->name, OCF_CORE_NAME_SIZE - 1, src, src_size); -} - const char *ocf_core_get_name(ocf_core_t core) { OCF_CHECK_NULL(core); - return core->name; + return core->conf_meta->name; } ocf_core_state_t ocf_core_get_state(ocf_core_t core) diff --git a/src/ocf_core_priv.h b/src/ocf_core_priv.h index e1407b4..6378ce2 100644 --- a/src/ocf_core_priv.h +++ b/src/ocf_core_priv.h @@ -26,6 +26,8 @@ struct ocf_metadata_uuid { #define OCF_CORE_USER_DATA_SIZE 64 struct ocf_core_meta_config { + char name[OCF_CORE_NAME_SIZE]; + uint8_t type; /* This bit means that object was added into cache */ @@ -69,8 +71,6 @@ struct ocf_core_meta_runtime { struct ocf_core { - char name[OCF_CORE_NAME_SIZE]; - struct ocf_volume front_volume; struct ocf_volume volume; @@ -91,8 +91,6 @@ struct ocf_core { struct ocf_counters_core *counters; }; -int ocf_core_set_name(ocf_core_t core, const char *src, size_t src_size); - bool ocf_core_is_valid(ocf_cache_t cache, ocf_core_id_t id); int ocf_core_volume_type_init(ocf_ctx_t ctx);