[thin_repair, thin_dump] Don't look for better roots if the ones in the sb are ok.

Calculating the most recent trees is inexact, so trees other than the ones
in the superblock, which presumably are the most recent, could be chosen.
This commit is contained in:
Joe Thornber 2019-05-27 16:43:32 +01:00
parent 5e6ddbf2da
commit 0624ded67f

View File

@ -741,36 +741,9 @@ namespace {
// metadata snap, we really don't know
return 0ull;
}
}
//----------------------------------------------------------------
void
thin_provisioning::metadata_dump(metadata::ptr md, emitter::ptr e, dump_options const &opts)
{
details_extractor de(opts);
device_tree_detail::damage_visitor::ptr dd_policy(details_damage_policy(false));
walk_device_tree(*md->details_, de, *dd_policy);
e->begin_superblock("", md->sb_.time_,
md->sb_.trans_id_,
md->sb_.flags_,
md->sb_.version_,
md->sb_.data_block_size_,
get_nr_blocks(md),
boost::optional<block_address>());
{
mapping_tree_detail::damage_visitor::ptr md_policy(mapping_damage_policy(false));
mapping_tree_emitter mte(opts, md, e, de.get_details(), mapping_damage_policy(false));
walk_mapping_tree(*md->mappings_top_level_, mte, *md_policy);
}
e->end_superblock();
}
void
thin_provisioning::metadata_repair(block_manager<>::ptr bm, emitter::ptr e)
metadata_repair_(block_manager<>::ptr bm, emitter::ptr e)
{
// We assume the superblock is wrong, and find the best roots
// for ourselves. We've had a few cases where people have
@ -825,6 +798,49 @@ thin_provisioning::metadata_repair(block_manager<>::ptr bm, emitter::ptr e)
e->end_superblock();
}
}
//----------------------------------------------------------------
void
thin_provisioning::metadata_dump(metadata::ptr md, emitter::ptr e, dump_options const &opts)
{
details_extractor de(opts);
device_tree_detail::damage_visitor::ptr dd_policy(details_damage_policy(false));
walk_device_tree(*md->details_, de, *dd_policy);
e->begin_superblock("", md->sb_.time_,
md->sb_.trans_id_,
md->sb_.flags_,
md->sb_.version_,
md->sb_.data_block_size_,
get_nr_blocks(md),
boost::optional<block_address>());
{
mapping_tree_detail::damage_visitor::ptr md_policy(mapping_damage_policy(false));
mapping_tree_emitter mte(opts, md, e, de.get_details(), mapping_damage_policy(false));
walk_mapping_tree(*md->mappings_top_level_, mte, *md_policy);
}
e->end_superblock();
}
void
thin_provisioning::metadata_repair(block_manager<>::ptr bm, emitter::ptr e)
{
auto sb = read_superblock(*bm);
auto tm = open_tm(bm, superblock_detail::SUPERBLOCK_LOCATION);
if (get_dev_ids(*tm, sb.device_details_root_) && get_map_ids(*tm, sb.data_mapping_root_)) {
// The roots in the superblock look ok (perhaps the corruption was in the
// space maps). Just dump the metadata skipping repair.
dump_options opts;
auto md = metadata::ptr(new metadata(bm, false));
metadata_dump(md, e, opts);
} else
metadata_repair_(bm, e);
}
//----------------------------------------------------------------