Merge pull request #201 from mmichal10/fix-load-error-handling
Fix error handling in case of failed load
This commit is contained in:
commit
e7e0ad957d
@ -1200,6 +1200,7 @@ struct ocf_metadata_hash_context {
|
|||||||
void *priv;
|
void *priv;
|
||||||
ocf_pipeline_t pipeline;
|
ocf_pipeline_t pipeline;
|
||||||
ocf_cache_t cache;
|
ocf_cache_t cache;
|
||||||
|
struct ocf_metadata_raw segment_copy[metadata_segment_fixed_size_max];
|
||||||
};
|
};
|
||||||
|
|
||||||
static void ocf_metadata_hash_generic_complete(void *priv, int error)
|
static void ocf_metadata_hash_generic_complete(void *priv, int error)
|
||||||
@ -1223,6 +1224,34 @@ static void ocf_medatata_hash_load_segment(ocf_pipeline_t pipeline,
|
|||||||
ocf_metadata_hash_generic_complete, context);
|
ocf_metadata_hash_generic_complete, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void ocf_medatata_hash_store_segment(ocf_pipeline_t pipeline,
|
||||||
|
void *priv, ocf_pipeline_arg_t arg)
|
||||||
|
{
|
||||||
|
struct ocf_metadata_hash_context *context = priv;
|
||||||
|
int segment = ocf_pipeline_arg_get_int(arg);
|
||||||
|
struct ocf_metadata_hash_ctrl *ctrl;
|
||||||
|
ocf_cache_t cache = context->cache;
|
||||||
|
int error;
|
||||||
|
|
||||||
|
ctrl = (struct ocf_metadata_hash_ctrl *)cache->metadata.iface_priv;
|
||||||
|
|
||||||
|
context->segment_copy[segment].mem_pool =
|
||||||
|
env_malloc(ctrl->raw_desc[segment].mem_pool_limit, ENV_MEM_NORMAL);
|
||||||
|
if (!context->segment_copy[segment].mem_pool)
|
||||||
|
OCF_PL_FINISH_RET(pipeline, -OCF_ERR_NO_MEM);
|
||||||
|
|
||||||
|
error = env_memcpy(context->segment_copy[segment].mem_pool,
|
||||||
|
ctrl->raw_desc[segment].mem_pool_limit, METADATA_MEM_POOL(ctrl, segment),
|
||||||
|
ctrl->raw_desc[segment].mem_pool_limit);
|
||||||
|
if (error) {
|
||||||
|
env_free(context->segment_copy[segment].mem_pool);
|
||||||
|
context->segment_copy[segment].mem_pool = NULL;
|
||||||
|
OCF_PL_FINISH_RET(pipeline, error);
|
||||||
|
}
|
||||||
|
|
||||||
|
ocf_pipeline_next(pipeline);
|
||||||
|
}
|
||||||
|
|
||||||
static void ocf_medatata_hash_check_crc_sb_config(ocf_pipeline_t pipeline,
|
static void ocf_medatata_hash_check_crc_sb_config(ocf_pipeline_t pipeline,
|
||||||
void *priv, ocf_pipeline_arg_t arg)
|
void *priv, ocf_pipeline_arg_t arg)
|
||||||
{
|
{
|
||||||
@ -1321,21 +1350,58 @@ static void ocf_medatata_hash_load_superblock_post(ocf_pipeline_t pipeline,
|
|||||||
ocf_pipeline_next(pipeline);
|
ocf_pipeline_next(pipeline);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void ocf_metadata_hash_load_sb_restore(
|
||||||
|
struct ocf_metadata_hash_context *context)
|
||||||
|
{
|
||||||
|
ocf_cache_t cache = context->cache;
|
||||||
|
struct ocf_metadata_hash_ctrl *ctrl;
|
||||||
|
int segment, error;
|
||||||
|
|
||||||
|
ctrl = (struct ocf_metadata_hash_ctrl *)cache->metadata.iface_priv;
|
||||||
|
|
||||||
|
for (segment = metadata_segment_sb_config;
|
||||||
|
segment < metadata_segment_fixed_size_max; segment++) {
|
||||||
|
if (!context->segment_copy[segment].mem_pool)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
error = env_memcpy(METADATA_MEM_POOL(ctrl, segment),
|
||||||
|
ctrl->raw_desc[segment].mem_pool_limit,
|
||||||
|
context->segment_copy[segment].mem_pool,
|
||||||
|
ctrl->raw_desc[segment].mem_pool_limit);
|
||||||
|
ENV_BUG_ON(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void ocf_metadata_hash_load_superblock_finish(ocf_pipeline_t pipeline,
|
static void ocf_metadata_hash_load_superblock_finish(ocf_pipeline_t pipeline,
|
||||||
void *priv, int error)
|
void *priv, int error)
|
||||||
{
|
{
|
||||||
struct ocf_metadata_hash_context *context = priv;
|
struct ocf_metadata_hash_context *context = priv;
|
||||||
ocf_cache_t cache = context->cache;
|
ocf_cache_t cache = context->cache;
|
||||||
|
int segment;
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
ocf_cache_log(cache, log_err, "Metadata read FAILURE\n");
|
ocf_cache_log(cache, log_err, "Metadata read FAILURE\n");
|
||||||
ocf_metadata_error(cache);
|
ocf_metadata_error(cache);
|
||||||
|
ocf_metadata_hash_load_sb_restore(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (segment = metadata_segment_sb_config;
|
||||||
|
segment < metadata_segment_fixed_size_max; segment++) {
|
||||||
|
if (context->segment_copy[segment].mem_pool)
|
||||||
|
env_free(context->segment_copy[segment].mem_pool);
|
||||||
}
|
}
|
||||||
|
|
||||||
context->cmpl(context->priv, error);
|
context->cmpl(context->priv, error);
|
||||||
ocf_pipeline_destroy(pipeline);
|
ocf_pipeline_destroy(pipeline);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct ocf_pipeline_arg ocf_metadata_hash_load_sb_store_segment_args[] = {
|
||||||
|
OCF_PL_ARG_INT(metadata_segment_sb_config),
|
||||||
|
OCF_PL_ARG_INT(metadata_segment_sb_runtime),
|
||||||
|
OCF_PL_ARG_INT(metadata_segment_core_config),
|
||||||
|
OCF_PL_ARG_TERMINATOR(),
|
||||||
|
};
|
||||||
|
|
||||||
struct ocf_pipeline_arg ocf_metadata_hash_load_sb_load_segment_args[] = {
|
struct ocf_pipeline_arg ocf_metadata_hash_load_sb_load_segment_args[] = {
|
||||||
OCF_PL_ARG_INT(metadata_segment_sb_config),
|
OCF_PL_ARG_INT(metadata_segment_sb_config),
|
||||||
OCF_PL_ARG_INT(metadata_segment_sb_runtime),
|
OCF_PL_ARG_INT(metadata_segment_sb_runtime),
|
||||||
@ -1355,6 +1421,8 @@ struct ocf_pipeline_properties ocf_metadata_hash_load_sb_pipeline_props = {
|
|||||||
.priv_size = sizeof(struct ocf_metadata_hash_context),
|
.priv_size = sizeof(struct ocf_metadata_hash_context),
|
||||||
.finish = ocf_metadata_hash_load_superblock_finish,
|
.finish = ocf_metadata_hash_load_superblock_finish,
|
||||||
.steps = {
|
.steps = {
|
||||||
|
OCF_PL_STEP_FOREACH(ocf_medatata_hash_store_segment,
|
||||||
|
ocf_metadata_hash_load_sb_store_segment_args),
|
||||||
OCF_PL_STEP_FOREACH(ocf_medatata_hash_load_segment,
|
OCF_PL_STEP_FOREACH(ocf_medatata_hash_load_segment,
|
||||||
ocf_metadata_hash_load_sb_load_segment_args),
|
ocf_metadata_hash_load_sb_load_segment_args),
|
||||||
OCF_PL_STEP(ocf_medatata_hash_check_crc_sb_config),
|
OCF_PL_STEP(ocf_medatata_hash_check_crc_sb_config),
|
||||||
|
@ -409,6 +409,9 @@ static int raw_dynamic_load_all_update(struct ocf_request *req)
|
|||||||
|
|
||||||
OCF_DEBUG_PARAM(cache, "Non-zero loaded %llu", i);
|
OCF_DEBUG_PARAM(cache, "Non-zero loaded %llu", i);
|
||||||
|
|
||||||
|
if (ctrl->pages[context->i])
|
||||||
|
env_vfree(ctrl->pages[context->i]);
|
||||||
|
|
||||||
ctrl->pages[context->i] = context->page;
|
ctrl->pages[context->i] = context->page;
|
||||||
context->page = NULL;
|
context->page = NULL;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user