From 9693b82cf9899abe35c13959135cd56ccae86fae Mon Sep 17 00:00:00 2001 From: Adam Rutkowski Date: Thu, 23 Dec 2021 13:29:04 +0100 Subject: [PATCH] Only flush superblock at the end of cache attach The purpose of this change is not to write superblock to the cache drive untill all other sections are initilized on disk in attach() path. Combined with superblock clearing at the erarlier stage of attach(), this assures there are no residual mappings in the collision section in case of power failure during attach with pre-existing metadata. This is implemented by removing ocf_metadata_flush_all_set_status() step at the beginning of ocf_metadata_flush_all(). ocf_metadata_flush_all() is called, except for the attach() case described above, in two cases: 1. at the end of cache load - potentially after cache recovery 2. during detaching cache drive in cache stop. To make sure there are no regressions in the first case, an explicit _ocf_mngt_attach_shutdown_status() is added to load pipeline before ocf_metadata_flush_all(). The second case is always ran after cache drive is attached, so dirty status bit must have already be written to the disk. Signed-off-by: Adam Rutkowski --- src/metadata/metadata.c | 2 -- src/mngt/ocf_mngt_cache.c | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/metadata/metadata.c b/src/metadata/metadata.c index ac43b33..02c6be6 100644 --- a/src/metadata/metadata.c +++ b/src/metadata/metadata.c @@ -991,8 +991,6 @@ struct ocf_pipeline_properties ocf_metadata_flush_all_pipeline_props = { .priv_size = sizeof(struct ocf_metadata_context), .finish = ocf_metadata_flush_all_finish, .steps = { - OCF_PL_STEP_ARG_INT(ocf_metadata_flush_all_set_status, - ocf_metadata_dirty_shutdown), OCF_PL_STEP_FOREACH(ocf_metadata_flush_segment, ocf_metadata_flush_all_args), OCF_PL_STEP_FOREACH(ocf_metadata_calculate_crc, diff --git a/src/mngt/ocf_mngt_cache.c b/src/mngt/ocf_mngt_cache.c index 6e08f94..5ea714a 100644 --- a/src/mngt/ocf_mngt_cache.c +++ b/src/mngt/ocf_mngt_cache.c @@ -1737,6 +1737,7 @@ struct ocf_pipeline_properties _ocf_mngt_cache_load_pipeline_properties = { OCF_PL_STEP(_ocf_mngt_load_add_cores), OCF_PL_STEP(_ocf_mngt_load_metadata), OCF_PL_STEP(_ocf_mngt_load_post_metadata_load), + OCF_PL_STEP(_ocf_mngt_attach_shutdown_status), OCF_PL_STEP(_ocf_mngt_attach_flush_metadata), OCF_PL_STEP(_ocf_mngt_attach_shutdown_status), OCF_PL_STEP(_ocf_mngt_attach_post_init),