Avoid loading runtime metadata sections during recovery

Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
This commit is contained in:
Robert Baldyga 2021-12-29 09:10:51 +01:00
parent 4625763df5
commit 4cabc60d40
5 changed files with 86 additions and 34 deletions

View File

@ -71,8 +71,8 @@ static void ocf_metadata_generic_complete(void *priv, int error)
OCF_PL_NEXT_ON_SUCCESS_RET(context->pipeline, error);
}
static void ocf_metadata_check_crc_skip(ocf_pipeline_t pipeline,
void *priv, ocf_pipeline_arg_t arg, bool skip_on_dirty_shutdown)
void ocf_metadata_check_crc(ocf_pipeline_t pipeline,
void *priv, ocf_pipeline_arg_t arg)
{
struct ocf_metadata_context *context = priv;
int segment_id = ocf_pipeline_arg_get_int(arg);
@ -80,12 +80,6 @@ static void ocf_metadata_check_crc_skip(ocf_pipeline_t pipeline,
ocf_cache_t cache = context->cache;
uint32_t crc;
uint32_t superblock_crc;
bool clean_shutdown;
clean_shutdown = ocf_metadata_superblock_get_clean_shutdown(
segment->superblock);
if (!clean_shutdown && skip_on_dirty_shutdown)
OCF_PL_NEXT_RET(pipeline);
crc = ocf_metadata_raw_checksum(cache, segment->raw);
superblock_crc = ocf_metadata_superblock_get_checksum(segment->superblock,
@ -100,19 +94,6 @@ static void ocf_metadata_check_crc_skip(ocf_pipeline_t pipeline,
ocf_pipeline_next(pipeline);
}
void ocf_metadata_check_crc(ocf_pipeline_t pipeline,
void *priv, ocf_pipeline_arg_t arg)
{
ocf_metadata_check_crc_skip(pipeline, priv, arg, false);
}
void ocf_metadata_check_crc_if_clean(ocf_pipeline_t pipeline,
void *priv, ocf_pipeline_arg_t arg)
{
ocf_metadata_check_crc_skip(pipeline, priv, arg, true);
}
void ocf_metadata_calculate_crc(ocf_pipeline_t pipeline,
void *priv, ocf_pipeline_arg_t arg)
{

View File

@ -27,9 +27,6 @@ int ocf_metadata_segment_init(
void ocf_metadata_segment_destroy(struct ocf_cache *cache,
struct ocf_metadata_segment *self);
void ocf_metadata_check_crc_if_clean(ocf_pipeline_t pipeline,
void *priv, ocf_pipeline_arg_t arg);
void ocf_metadata_check_crc(ocf_pipeline_t pipeline,
void *priv, ocf_pipeline_arg_t arg);

View File

@ -216,18 +216,14 @@ struct ocf_pipeline_arg ocf_metadata_load_sb_load_segment_args[] = {
};
struct ocf_pipeline_arg ocf_metadata_load_sb_check_crc_args[] = {
OCF_PL_ARG_INT(metadata_segment_sb_runtime),
OCF_PL_ARG_INT(metadata_segment_part_config),
OCF_PL_ARG_INT(metadata_segment_part_runtime),
OCF_PL_ARG_INT(metadata_segment_core_config),
OCF_PL_ARG_INT(metadata_segment_core_uuid),
OCF_PL_ARG_TERMINATOR(),
};
struct ocf_pipeline_arg ocf_metadata_load_sb_check_crc_args_clean[] = {
OCF_PL_ARG_INT(metadata_segment_sb_runtime),
OCF_PL_ARG_INT(metadata_segment_part_runtime),
OCF_PL_ARG_TERMINATOR(),
};
struct ocf_pipeline_properties ocf_metadata_load_sb_pipeline_props = {
.priv_size = sizeof(struct ocf_metadata_context),
.finish = ocf_metadata_load_superblock_finish,
@ -239,8 +235,6 @@ struct ocf_pipeline_properties ocf_metadata_load_sb_pipeline_props = {
OCF_PL_STEP(ocf_metadata_check_crc_sb_config),
OCF_PL_STEP_FOREACH(ocf_metadata_check_crc,
ocf_metadata_load_sb_check_crc_args),
OCF_PL_STEP_FOREACH(ocf_metadata_check_crc_if_clean,
ocf_metadata_load_sb_check_crc_args_clean),
OCF_PL_STEP(ocf_metadata_load_superblock_post),
OCF_PL_STEP_TERMINATOR(),
},
@ -287,6 +281,78 @@ void ocf_metadata_load_superblock(ocf_cache_t cache, ocf_metadata_end_t cmpl,
ocf_pipeline_next(pipeline);
}
struct ocf_pipeline_arg ocf_metadata_load_sb_recov_load_segment_args[] = {
OCF_PL_ARG_INT(metadata_segment_sb_config),
OCF_PL_ARG_INT(metadata_segment_part_config),
OCF_PL_ARG_INT(metadata_segment_core_config),
OCF_PL_ARG_INT(metadata_segment_core_uuid),
OCF_PL_ARG_TERMINATOR(),
};
struct ocf_pipeline_arg ocf_metadata_load_sb_recov_check_crc_args[] = {
OCF_PL_ARG_INT(metadata_segment_part_config),
OCF_PL_ARG_INT(metadata_segment_core_config),
OCF_PL_ARG_INT(metadata_segment_core_uuid),
OCF_PL_ARG_TERMINATOR(),
};
struct ocf_pipeline_properties ocf_metadata_load_sb_recov_pipeline_props = {
.priv_size = sizeof(struct ocf_metadata_context),
.finish = ocf_metadata_load_superblock_finish,
.steps = {
OCF_PL_STEP_FOREACH(ocf_metadata_store_segment,
ocf_metadata_load_sb_store_segment_args),
OCF_PL_STEP_FOREACH(ocf_metadata_load_segment,
ocf_metadata_load_sb_recov_load_segment_args),
OCF_PL_STEP(ocf_metadata_check_crc_sb_config),
OCF_PL_STEP_FOREACH(ocf_metadata_check_crc,
ocf_metadata_load_sb_recov_check_crc_args),
OCF_PL_STEP(ocf_metadata_load_superblock_post),
OCF_PL_STEP_TERMINATOR(),
},
};
/*
* Super Block - Recovery load
*/
void ocf_metadata_load_superblock_recovery(ocf_cache_t cache,
ocf_metadata_end_t cmpl, void *priv)
{
struct ocf_metadata_context *context;
ocf_pipeline_t pipeline;
struct ocf_metadata_ctrl *ctrl;
struct ocf_superblock_config *sb_config;
struct ocf_superblock_runtime *sb_runtime;
int result;
OCF_DEBUG_TRACE(cache);
/* TODO: get ctrl from args rather than from cache */
ctrl = cache->metadata.priv;
ENV_BUG_ON(!ctrl);
sb_config = METADATA_MEM_POOL(ctrl, metadata_segment_sb_config);
ENV_BUG_ON(!sb_config);
sb_runtime = METADATA_MEM_POOL(ctrl, metadata_segment_sb_runtime);
ENV_BUG_ON(!sb_runtime);
result = ocf_pipeline_create(&pipeline, cache,
&ocf_metadata_load_sb_recov_pipeline_props);
if (result)
OCF_CMPL_RET(priv, result);
context = ocf_pipeline_get_priv(pipeline);
context->cmpl = cmpl;
context->priv = priv;
context->pipeline = pipeline;
context->cache = cache;
context->ctrl = cache->metadata.priv;
ocf_pipeline_next(pipeline);
}
static void ocf_metadata_flush_superblock_prepare(ocf_pipeline_t pipeline,
void *priv, ocf_pipeline_arg_t arg)
{

View File

@ -75,6 +75,9 @@ void ocf_metadata_set_shutdown_status(ocf_cache_t cache,
void ocf_metadata_load_superblock(ocf_cache_t cache,
ocf_metadata_end_t cmpl, void *priv);
void ocf_metadata_load_superblock_recovery(ocf_cache_t cache,
ocf_metadata_end_t cmpl, void *priv);
void ocf_metadata_flush_superblock(ocf_cache_t cache,
ocf_metadata_end_t cmpl, void *priv);

View File

@ -1443,8 +1443,13 @@ static void _ocf_mngt_load_superblock(ocf_pipeline_t pipeline,
ocf_cache_t cache = context->cache;
ocf_cache_log(cache, log_info, "Loading cache state...\n");
ocf_metadata_load_superblock(cache,
_ocf_mngt_load_superblock_complete, context);
if (context->metadata.shutdown_status == ocf_metadata_clean_shutdown) {
ocf_metadata_load_superblock(cache,
_ocf_mngt_load_superblock_complete, context);
} else {
ocf_metadata_load_superblock_recovery(cache,
_ocf_mngt_load_superblock_complete, context);
}
}
static void _ocf_mngt_init_cleaner(ocf_pipeline_t pipeline,