[block_counter] Add the stop-on-error option to prevent silent errors

The stop-on-error option aims to solve the lack of damage_visitor support
in space_map::count_metadata and btree counting_visitor. To prevent
possibly silent errors during space map or btree counting, the option
stops the counting process immediately when a btree or bitmap error
was found.

The bitmap blocks are also validated to avoid potential false-alarm,
if broken bitmap is not counted, and the corresponding ref-count is
also zeroed.
This commit is contained in:
Ming-Hung Tsai
2020-08-11 19:41:41 +08:00
parent 3609b8bee5
commit 12725983db
3 changed files with 46 additions and 10 deletions

View File

@ -16,7 +16,10 @@ namespace persistent_data {
counting_visitor(block_counter &bc, ValueCounter &vc)
: bc_(bc),
vc_(vc) {
vc_(vc),
error_outcome_(bc.stop_on_error() ?
tree::visitor::RETHROW_EXCEPTION :
tree::visitor::EXCEPTION_HANDLED) {
}
virtual bool visit_internal(node_location const &l,
@ -51,7 +54,7 @@ namespace persistent_data {
error_outcome error_accessing_node(node_location const &l, block_address b,
std::string const &what) {
return btree<Levels, ValueTraits>::visitor::EXCEPTION_HANDLED;
return error_outcome_;
}
private:
@ -110,6 +113,7 @@ namespace persistent_data {
ValueCounter &vc_;
btree_node_checker checker_;
boost::optional<uint64_t> last_leaf_key_[Levels];
error_outcome error_outcome_;
};
}