Store core name in metadata

Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
This commit is contained in:
Robert Baldyga 2019-07-20 14:23:30 +02:00
parent eb4272afa9
commit 259df7ace9
5 changed files with 14 additions and 29 deletions

View File

@ -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) {

View File

@ -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);

View File

@ -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);
}

View File

@ -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)

View File

@ -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);