Merge pull request #445 from arutk/probe
probe: return dirty and shutdown status despite metadata mismatch
This commit is contained in:
commit
73415c6349
@ -2121,9 +2121,6 @@ static void ocf_metadata_probe_cmpl(struct ocf_metadata_read_sb_ctx *context)
|
||||
if (superblock->magic_number != CACHE_MAGIC_NUMBER)
|
||||
OCF_CMPL_RET(priv, -OCF_ERR_NO_METADATA, NULL);
|
||||
|
||||
if (METADATA_VERSION() != superblock->metadata_version)
|
||||
OCF_CMPL_RET(priv, -OCF_ERR_METADATA_VER, NULL);
|
||||
|
||||
if (superblock->clean_shutdown > ocf_metadata_clean_shutdown)
|
||||
OCF_CMPL_RET(priv, -OCF_ERR_INVAL, NULL);
|
||||
|
||||
@ -2133,6 +2130,10 @@ static void ocf_metadata_probe_cmpl(struct ocf_metadata_read_sb_ctx *context)
|
||||
status.clean_shutdown = (superblock->clean_shutdown !=
|
||||
ocf_metadata_dirty_shutdown);
|
||||
status.cache_dirty = (superblock->dirty_flushed == DIRTY_NOT_FLUSHED);
|
||||
|
||||
if (METADATA_VERSION() != superblock->metadata_version)
|
||||
OCF_CMPL_RET(priv, -OCF_ERR_METADATA_VER, &status);
|
||||
|
||||
env_strncpy(status.cache_name, OCF_CACHE_NAME_SIZE, superblock->name,
|
||||
OCF_CACHE_NAME_SIZE);
|
||||
|
||||
|
@ -1635,6 +1635,25 @@ static void ocf_mngt_cache_stop_wait_metadata_io(ocf_pipeline_t pipeline,
|
||||
ocf_mngt_cache_stop_wait_metadata_io_finish, context);
|
||||
}
|
||||
|
||||
static void ocf_mngt_cache_stop_check_dirty(ocf_pipeline_t pipeline,
|
||||
void *priv, ocf_pipeline_arg_t arg)
|
||||
{
|
||||
struct ocf_mngt_cache_stop_context *context = priv;
|
||||
ocf_cache_t cache = context->cache;
|
||||
|
||||
if (ocf_mngt_cache_is_dirty(cache)) {
|
||||
cache->conf_meta->dirty_flushed = DIRTY_NOT_FLUSHED;
|
||||
|
||||
ocf_cache_log(cache, log_warn, "Cache is still dirty. "
|
||||
"DO NOT USE your core devices until flushing "
|
||||
"dirty data!\n");
|
||||
} else {
|
||||
cache->conf_meta->dirty_flushed = DIRTY_FLUSHED;
|
||||
}
|
||||
|
||||
ocf_pipeline_next(context->pipeline);
|
||||
}
|
||||
|
||||
static void _ocf_mngt_cache_stop_remove_cores(ocf_cache_t cache, bool attached)
|
||||
{
|
||||
ocf_core_t core;
|
||||
@ -1786,6 +1805,7 @@ struct ocf_pipeline_properties ocf_mngt_cache_stop_pipeline_properties = {
|
||||
.finish = ocf_mngt_cache_stop_finish,
|
||||
.steps = {
|
||||
OCF_PL_STEP(ocf_mngt_cache_stop_wait_metadata_io),
|
||||
OCF_PL_STEP(ocf_mngt_cache_stop_check_dirty),
|
||||
OCF_PL_STEP(ocf_mngt_cache_stop_remove_cores),
|
||||
OCF_PL_STEP(ocf_mngt_cache_stop_unplug),
|
||||
OCF_PL_STEP(ocf_mngt_cache_stop_put_io_queues),
|
||||
@ -2050,18 +2070,6 @@ static void _ocf_mngt_cache_unplug(ocf_cache_t cache, bool stop,
|
||||
__deinit_cleaning_policy(cache);
|
||||
__deinit_promotion_policy(cache);
|
||||
|
||||
if (ocf_mngt_cache_is_dirty(cache)) {
|
||||
ENV_BUG_ON(!stop);
|
||||
|
||||
cache->conf_meta->dirty_flushed = DIRTY_NOT_FLUSHED;
|
||||
|
||||
ocf_cache_log(cache, log_warn, "Cache is still dirty. "
|
||||
"DO NOT USE your core devices until flushing "
|
||||
"dirty data!\n");
|
||||
} else {
|
||||
cache->conf_meta->dirty_flushed = DIRTY_FLUSHED;
|
||||
}
|
||||
|
||||
if (!stop) {
|
||||
/* Just set correct shutdown status */
|
||||
ocf_metadata_set_shutdown_status(cache, ocf_metadata_detached,
|
||||
@ -2540,9 +2548,11 @@ static void ocf_mngt_cache_detach_unplug(ocf_pipeline_t pipeline,
|
||||
struct ocf_mngt_cache_detach_context *context = priv;
|
||||
ocf_cache_t cache = context->cache;
|
||||
|
||||
ENV_BUG_ON(cache->conf_meta->dirty_flushed == DIRTY_NOT_FLUSHED);
|
||||
|
||||
/* Do the actual detach - deinit cacheline metadata,
|
||||
* stop cleaner thread and close cache bottom device */
|
||||
_ocf_mngt_cache_unplug(cache, false, &context->unplug_context,
|
||||
_ocf_mngt_cache_unplug(cache, false, &context->unplug_context,
|
||||
ocf_mngt_cache_detach_unplug_complete, context);
|
||||
}
|
||||
|
||||
@ -2581,6 +2591,7 @@ struct ocf_pipeline_properties ocf_mngt_cache_detach_pipeline_properties = {
|
||||
OCF_PL_STEP(ocf_mngt_cache_detach_flush),
|
||||
OCF_PL_STEP(ocf_mngt_cache_detach_stop_cache_io),
|
||||
OCF_PL_STEP(ocf_mngt_cache_detach_stop_cleaner_io),
|
||||
OCF_PL_STEP(ocf_mngt_cache_stop_check_dirty),
|
||||
OCF_PL_STEP(ocf_mngt_cache_detach_update_metadata),
|
||||
OCF_PL_STEP(ocf_mngt_cache_detach_unplug),
|
||||
OCF_PL_STEP_TERMINATOR(),
|
||||
|
Loading…
Reference in New Issue
Block a user