Merge pull request #787 from arutk/probe3

Check dirty status in case of metadata mismatch
This commit is contained in:
Robert Baldyga 2021-04-06 15:14:17 +02:00 committed by GitHub
commit 3f348cf5d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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;
}
if (!cmd_info.metadata_compatible) {
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 (!cmd_info.clean_shutdown) {
if (!force) {
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"

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->metadata_compatible = false;
*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->metadata_compatible = false;
*context->result = 0;
} else if (error == 0) {
cmd_info->is_cache_device = true;
cmd_info->metadata_compatible = true;
cmd_info->metadata_compatible = !error;
cmd_info->clean_shutdown = status->clean_shutdown;
cmd_info->cache_dirty = status->cache_dirty;
*context->result = 0;
}
complete(&context->cmpl);