From 716edcc637cf30aae24153113d0f922b6959b1b7 Mon Sep 17 00:00:00 2001 From: Adam Rutkowski Date: Mon, 28 Sep 2020 15:31:30 +0200 Subject: [PATCH] Flush cache volume after writing config metadata segments After writing metadata configuration to disk we must send a flush request to make sure configuration sections are commited to non-volatile storage. Signed-off-by: Adam Rutkowski --- src/metadata/metadata_hash.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/metadata/metadata_hash.c b/src/metadata/metadata_hash.c index 3c2352d..377b0b8 100644 --- a/src/metadata/metadata_hash.c +++ b/src/metadata/metadata_hash.c @@ -10,6 +10,7 @@ #include "metadata_status.h" #include "../concurrency/ocf_concurrency.h" #include "../utils/utils_cache_line.h" +#include "../utils/utils_io.h" #include "../utils/utils_pipeline.h" #include "../ocf_def_priv.h" #include "../ocf_priv.h" @@ -1580,6 +1581,29 @@ static void ocf_metadata_hash_flush_superblock_finish(ocf_pipeline_t pipeline, ocf_pipeline_destroy(pipeline); } +static void ocf_metadata_hash_flush_disk_end(void *priv, int error) +{ + struct ocf_metadata_hash_context *context = priv; + ocf_pipeline_t pipeline = context->pipeline; + + if (error) { + OCF_PL_FINISH_RET(pipeline, error); + return; + } + + ocf_pipeline_next(pipeline); +} + +static void ocf_metadata_hash_flush_disk(ocf_pipeline_t pipeline, + void *priv, ocf_pipeline_arg_t arg) +{ + struct ocf_metadata_hash_context *context = priv; + ocf_cache_t cache = context->cache; + + ocf_submit_volume_flush(ocf_cache_get_volume(cache), + ocf_metadata_hash_flush_disk_end, context); +} + struct ocf_pipeline_arg ocf_metadata_hash_flush_sb_calculate_crc_args[] = { OCF_PL_ARG_INT(metadata_segment_part_config), OCF_PL_ARG_INT(metadata_segment_core_config), @@ -1605,6 +1629,7 @@ struct ocf_pipeline_properties ocf_metadata_hash_flush_sb_pipeline_props = { ocf_metadata_hash_flush_sb_calculate_crc_args), OCF_PL_STEP_FOREACH(ocf_medatata_hash_flush_segment, ocf_metadata_hash_flush_sb_flush_segment_args), + OCF_PL_STEP(ocf_metadata_hash_flush_disk), OCF_PL_STEP_TERMINATOR(), }, };