Merge pull request #614 from robertbaldyga/redesign-standby
Redesign failover standby API
This commit is contained in:
@@ -1171,79 +1171,6 @@ void ocf_metadata_load_all(ocf_cache_t cache,
|
||||
ocf_pipeline_next(pipeline);
|
||||
}
|
||||
|
||||
static void ocf_metadata_load_unsafe_finish(ocf_pipeline_t pipeline,
|
||||
void *priv, int error)
|
||||
{
|
||||
struct ocf_metadata_context *context = priv;
|
||||
ocf_cache_t cache = context->cache;
|
||||
|
||||
if (error) {
|
||||
ocf_cache_log(cache, log_err, "Metadata read FAILURE\n");
|
||||
ocf_metadata_error(cache);
|
||||
goto out;
|
||||
}
|
||||
|
||||
ocf_cache_log(cache, log_info, "Done loading cache state\n");
|
||||
|
||||
out:
|
||||
context->cmpl(context->priv, error);
|
||||
ocf_pipeline_destroy(pipeline);
|
||||
}
|
||||
|
||||
struct ocf_pipeline_arg ocf_metadata_load_unsafe_args[] = {
|
||||
OCF_PL_ARG_INT(metadata_segment_sb_config),
|
||||
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_runtime),
|
||||
OCF_PL_ARG_INT(metadata_segment_core_uuid),
|
||||
OCF_PL_ARG_INT(metadata_segment_cleaning),
|
||||
OCF_PL_ARG_INT(metadata_segment_lru),
|
||||
OCF_PL_ARG_INT(metadata_segment_collision),
|
||||
OCF_PL_ARG_INT(metadata_segment_list_info),
|
||||
OCF_PL_ARG_INT(metadata_segment_hash),
|
||||
OCF_PL_ARG_TERMINATOR(),
|
||||
};
|
||||
|
||||
struct ocf_pipeline_properties ocf_metadata_load_unsafe_pipeline_props = {
|
||||
.priv_size = sizeof(struct ocf_metadata_context),
|
||||
.finish = ocf_metadata_load_unsafe_finish,
|
||||
.steps = {
|
||||
OCF_PL_STEP_FOREACH(ocf_metadata_load_segment,
|
||||
ocf_metadata_load_unsafe_args),
|
||||
OCF_PL_STEP_TERMINATOR(),
|
||||
},
|
||||
};
|
||||
|
||||
/*
|
||||
* Load metadata unsafe
|
||||
*/
|
||||
void ocf_metadata_load_unsafe(ocf_cache_t cache,
|
||||
ocf_metadata_end_t cmpl, void *priv)
|
||||
{
|
||||
struct ocf_metadata_context *context;
|
||||
ocf_pipeline_t pipeline;
|
||||
int result;
|
||||
|
||||
OCF_DEBUG_TRACE(cache);
|
||||
|
||||
result = ocf_pipeline_create(&pipeline, cache,
|
||||
&ocf_metadata_load_unsafe_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_load_recovery_legacy_finish(
|
||||
ocf_pipeline_t pipeline, void *priv, int error)
|
||||
{
|
||||
|
@@ -165,16 +165,6 @@ void ocf_metadata_flush_do_asynch(struct ocf_cache *cache,
|
||||
void ocf_metadata_load_all(ocf_cache_t cache,
|
||||
ocf_metadata_end_t cmpl, void *priv);
|
||||
|
||||
/**
|
||||
* @brief Load metadata unsafe
|
||||
*
|
||||
* @param cache - Cache instance
|
||||
* @param cmpl - Completion callback
|
||||
* @param priv - Completion context
|
||||
*/
|
||||
void ocf_metadata_load_unsafe(ocf_cache_t cache,
|
||||
ocf_metadata_end_t cmpl, void *priv);
|
||||
|
||||
/**
|
||||
* @brief Load metadata required for recovery procedure
|
||||
*
|
||||
|
@@ -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,47 +80,20 @@ 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,
|
||||
segment_id);
|
||||
|
||||
if (crc != superblock_crc) {
|
||||
/* Checksum does not match */
|
||||
if (!clean_shutdown) {
|
||||
ocf_cache_log(cache, log_warn,
|
||||
"Loading %s WARNING, invalid checksum\n",
|
||||
ocf_metadata_segment_names[segment_id]);
|
||||
} else {
|
||||
ocf_cache_log(cache, log_err,
|
||||
"Loading %s ERROR, invalid checksum\n",
|
||||
ocf_metadata_segment_names[segment_id]);
|
||||
OCF_PL_FINISH_RET(pipeline, -OCF_ERR_INVAL);
|
||||
}
|
||||
ocf_cache_log(cache, log_err,
|
||||
"Loading %s ERROR, invalid checksum\n",
|
||||
ocf_metadata_segment_names[segment_id]);
|
||||
OCF_PL_FINISH_RET(pipeline, -OCF_ERR_INVAL);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
@@ -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);
|
||||
|
||||
|
@@ -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)
|
||||
{
|
||||
|
@@ -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);
|
||||
|
||||
|
Reference in New Issue
Block a user