diff --git a/src/metadata/metadata.c b/src/metadata/metadata.c index ddcd247..3050d0c 100644 --- a/src/metadata/metadata.c +++ b/src/metadata/metadata.c @@ -290,6 +290,7 @@ static void ocf_metadata_load_properties_cmpl( properties.cache_mode = superblock->cache_mode; properties.shutdown_status = superblock->clean_shutdown; properties.dirty_flushed = superblock->dirty_flushed; + properties.cache_name = superblock->name; OCF_CMPL_RET(priv, 0, &properties); } diff --git a/src/metadata/metadata.h b/src/metadata/metadata.h index 5c75b89..f776c1d 100644 --- a/src/metadata/metadata.h +++ b/src/metadata/metadata.h @@ -206,6 +206,7 @@ struct ocf_metadata_load_properties { ocf_metadata_layout_t layout; ocf_cache_line_size_t line_size; ocf_cache_mode_t cache_mode; + char *cache_name; }; typedef void (*ocf_metadata_load_properties_end_t)(void *priv, int error, diff --git a/src/mngt/ocf_mngt_cache.c b/src/mngt/ocf_mngt_cache.c index 150ef6d..65f1656 100644 --- a/src/mngt/ocf_mngt_cache.c +++ b/src/mngt/ocf_mngt_cache.c @@ -892,7 +892,6 @@ err_buffer: /** * Prepare metadata accordingly to mode (for load/recovery read from disk) */ - static void _ocf_mngt_attach_load_properties_end(void *priv, int error, struct ocf_metadata_load_properties *properties) { @@ -919,6 +918,14 @@ static void _ocf_mngt_attach_load_properties_end(void *priv, int error, OCF_PL_FINISH_RET(context->pipeline, -OCF_ERR_METADATA_FOUND); } + /* + * Check if name loaded from disk is the same as present one. + */ + if (env_strncmp(cache->conf_meta->name, properties->cache_name, + OCF_CACHE_NAME_SIZE)) { + OCF_PL_FINISH_RET(context->pipeline, -OCF_ERR_CACHE_NAME_MISMATCH); + } + context->metadata.shutdown_status = properties->shutdown_status; context->metadata.dirty_flushed = properties->dirty_flushed;