Merge pull request #680 from robertbaldyga/core-remove-err-recoverable

Make core remove error recoverable
This commit is contained in:
Robert Baldyga 2022-03-28 08:58:07 +02:00 committed by GitHub
commit e741160f8d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 8 deletions

View File

@ -146,7 +146,10 @@ typedef enum {
/** Operation invalid with cache drive atatched in failover standby */
OCF_ERR_STANDBY_ATTACHED,
OCF_ERR_MAX = OCF_ERR_STANDBY_ATTACHED,
/** Failed to remove the core */
OCF_ERR_CORE_NOT_REMOVED,
OCF_ERR_MAX = OCF_ERR_CORE_NOT_REMOVED,
} ocf_error_t;

View File

@ -632,15 +632,16 @@ static void ocf_mngt_cache_remove_core_finish(ocf_pipeline_t pipeline,
ocf_pipeline_destroy(context->pipeline);
}
static void ocf_mngt_cache_remove_core_flush_meta_complete(void *priv, int error)
static void ocf_mngt_cache_remove_core_flush_collision_complete(void *priv,
int error)
{
struct ocf_mngt_cache_remove_core_context *context = priv;
error = error ? -OCF_ERR_WRITE_CACHE : 0;
error = error ? -OCF_ERR_CORE_NOT_REMOVED : 0;
OCF_PL_NEXT_ON_SUCCESS_RET(context->pipeline, error);
}
static void _ocf_mngt_cache_remove_core_attached(ocf_pipeline_t pipeline,
static void _ocf_mngt_cache_remove_core_mapping(ocf_pipeline_t pipeline,
void *priv, ocf_pipeline_arg_t arg)
{
struct ocf_mngt_cache_remove_core_context *context = priv;
@ -651,16 +652,24 @@ static void _ocf_mngt_cache_remove_core_attached(ocf_pipeline_t pipeline,
OCF_PL_NEXT_RET(pipeline);
cache_mngt_core_deinit_attached_meta(core);
cache_mngt_core_remove_from_cleaning_pol(core);
if (env_atomic_read(&core->runtime_meta->dirty_clines) == 0)
OCF_PL_NEXT_RET(pipeline);
ocf_metadata_flush_collision(cache,
ocf_mngt_cache_remove_core_flush_meta_complete,
ocf_mngt_cache_remove_core_flush_collision_complete,
context);
}
static void ocf_mngt_cache_remove_core_flush_superblock_complete(void *priv,
int error)
{
struct ocf_mngt_cache_remove_core_context *context = priv;
error = error ? -OCF_ERR_WRITE_CACHE : 0;
OCF_PL_NEXT_ON_SUCCESS_RET(context->pipeline, error);
}
static void _ocf_mngt_cache_remove_core(ocf_pipeline_t pipeline, void *priv,
ocf_pipeline_arg_t arg)
{
@ -670,12 +679,15 @@ static void _ocf_mngt_cache_remove_core(ocf_pipeline_t pipeline, void *priv,
ocf_core_log(core, log_debug, "Removing core\n");
if (ocf_cache_is_device_attached(cache))
cache_mngt_core_remove_from_cleaning_pol(core);
cache_mngt_core_remove_from_meta(core);
cache_mngt_core_remove_from_cache(core);
cache_mngt_core_deinit(core);
ocf_metadata_flush_superblock(cache,
ocf_mngt_cache_remove_core_flush_meta_complete,
ocf_mngt_cache_remove_core_flush_superblock_complete,
context);
}
@ -705,7 +717,7 @@ struct ocf_pipeline_properties ocf_mngt_cache_remove_core_pipeline_props = {
.finish = ocf_mngt_cache_remove_core_finish,
.steps = {
OCF_PL_STEP(ocf_mngt_cache_remove_core_wait_cleaning),
OCF_PL_STEP(_ocf_mngt_cache_remove_core_attached),
OCF_PL_STEP(_ocf_mngt_cache_remove_core_mapping),
OCF_PL_STEP(_ocf_mngt_cache_remove_core),
OCF_PL_STEP_TERMINATOR(),
},

View File

@ -56,6 +56,7 @@ class OcfErrorCode(IntEnum):
OCF_ERR_CACHE_STANDBY = auto()
OCF_ERR_CORE_SIZE_MISMATCH = auto()
OCF_ERR_STANDBY_ATTACHED = auto()
OCF_ERR_CORE_NOT_REMOVED = auto()
class OcfCompletion: