Check dirty status in case of metadata mismatch

Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
This commit is contained in:
Adam Rutkowski 2021-01-25 13:12:08 -06:00
parent f6c1438dee
commit 048f25379b
2 changed files with 4 additions and 17 deletions

View File

@ -2988,17 +2988,7 @@ int zero_md(const char *cache_device, bool force)
return FAILURE; return FAILURE;
} }
if (!cmd_info.metadata_compatible) { if (!cmd_info.clean_shutdown) {
if (!force) {
cas_printf(LOG_ERR, "Unable to determine whether cache contains dirty data due to metadata mismatch.\n"
"Clearing metadata might result in loss of dirty data. In order to inspect cache content\n"
"please load cache instance using matching OpenCAS version. Alternatively, if you wish to clear\n"
"metadata anyway, please use '--force' option.\n");
return FAILURE;
} else {
cas_printf(LOG_WARNING, "Clearing metadata with unknown version - potential loss of dirty data.\n");
}
} else if (!cmd_info.clean_shutdown) {
if (!force) { if (!force) {
cas_printf(LOG_ERR, "Cache instance did not shut down cleanly. It might contain dirty data. \n" cas_printf(LOG_ERR, "Cache instance did not shut down cleanly. It might contain dirty data. \n"
"Clearing metadata might result in loss of dirty data. Please recover cache instance\n" "Clearing metadata might result in loss of dirty data. Please recover cache instance\n"

View File

@ -1016,15 +1016,12 @@ static void cache_mngt_metadata_probe_end(void *priv, int error,
cmd_info->is_cache_device = false; cmd_info->is_cache_device = false;
cmd_info->metadata_compatible = false; cmd_info->metadata_compatible = false;
*context->result = 0; *context->result = 0;
} else if (error == -OCF_ERR_METADATA_VER) { } else if (error == -OCF_ERR_METADATA_VER || error == 0) {
cmd_info->is_cache_device = true; cmd_info->is_cache_device = true;
cmd_info->metadata_compatible = false; cmd_info->metadata_compatible = !error;
*context->result = 0;
} else if (error == 0) {
cmd_info->is_cache_device = true;
cmd_info->metadata_compatible = true;
cmd_info->clean_shutdown = status->clean_shutdown; cmd_info->clean_shutdown = status->clean_shutdown;
cmd_info->cache_dirty = status->cache_dirty; cmd_info->cache_dirty = status->cache_dirty;
*context->result = 0;
} }
complete(&context->cmpl); complete(&context->cmpl);