[cache_writeback] Fix space map commits

Fix github issue #138
This commit is contained in:
Ming-Hung Tsai 2021-10-25 15:33:18 +08:00
parent 8f9f9c74f6
commit 8806dfe4f4
3 changed files with 11 additions and 6 deletions

View File

@ -301,7 +301,7 @@ namespace {
int writeback_(flags const &f) {
block_manager::ptr bm = open_bm(*f.metadata_dev, block_manager::READ_WRITE);
metadata md(bm);
metadata md(bm, true);
// FIXME: we're going to have to copy runs to get the through put with small block sizes
unsigned max_ios = f.cache_size / (md.sb_.data_block_size << SECTOR_SHIFT);

View File

@ -45,9 +45,9 @@ metadata::metadata(block_manager::ptr bm, open_type ot, unsigned metadata_versio
}
}
metadata::metadata(block_manager::ptr bm)
metadata::metadata(block_manager::ptr bm, bool read_space_map)
{
open_metadata(bm);
open_metadata(bm, read_space_map);
}
void
@ -90,11 +90,16 @@ metadata::create_metadata(block_manager::ptr bm, unsigned metadata_version)
}
void
metadata::open_metadata(block_manager::ptr bm)
metadata::open_metadata(block_manager::ptr bm, bool read_space_map)
{
tm_ = open_tm(bm);
sb_ = read_superblock(tm_->get_bm());
if (read_space_map) {
metadata_sm_ = open_metadata_sm(*tm_, &sb_.metadata_space_map_root);
tm_->set_sm(metadata_sm_);
}
mappings_ = mapping_array::ptr(
new mapping_array(*tm_,
mapping_array::ref_counter(),

View File

@ -27,7 +27,7 @@ namespace caching {
typedef std::shared_ptr<metadata> ptr;
metadata(block_manager::ptr bm, open_type ot, unsigned metadata_version = 2); // Create only
metadata(block_manager::ptr bm);
metadata(block_manager::ptr bm, bool read_space_map = false);
void commit(bool clean_shutdown = true);
void setup_hint_array(size_t width);
@ -46,7 +46,7 @@ namespace caching {
void init_superblock();
void create_metadata(block_manager::ptr bm, unsigned metadata_version);
void open_metadata(block_manager::ptr bm);
void open_metadata(block_manager::ptr bm, bool read_space_map);
void commit_space_map();
void commit_mappings();