|
|
944f5b |
persistent-data/data-structures/btree_counter.h | 22 ++++++++++++++++------
|
|
|
944f5b |
thin-provisioning/metadata_counter.cc | 14 ++++++++------
|
|
|
944f5b |
thin-provisioning/metadata_counter.h | 3 ++-
|
|
|
944f5b |
thin-provisioning/thin_check.cc | 2 +-
|
|
|
944f5b |
4 files changed, 27 insertions(+), 14 deletions(-)
|
|
|
944f5b |
|
|
|
944f5b |
diff --git a/persistent-data/data-structures/btree_counter.h b/persistent-data/data-structures/btree_counter.h
|
|
|
944f5b |
index 6ccf03a..e639c40 100644
|
|
|
944f5b |
--- a/persistent-data/data-structures/btree_counter.h
|
|
|
944f5b |
+++ b/persistent-data/data-structures/btree_counter.h
|
|
|
944f5b |
@@ -14,9 +14,11 @@ namespace persistent_data {
|
|
|
944f5b |
public:
|
|
|
944f5b |
typedef btree<Levels, ValueTraits> tree;
|
|
|
944f5b |
|
|
|
944f5b |
- counting_visitor(block_counter &bc, ValueCounter &vc)
|
|
|
944f5b |
+ counting_visitor(block_counter &bc, ValueCounter &vc,
|
|
|
944f5b |
+ bool ignore_non_fatal = false)
|
|
|
944f5b |
: bc_(bc),
|
|
|
944f5b |
- vc_(vc) {
|
|
|
944f5b |
+ vc_(vc),
|
|
|
944f5b |
+ ignore_non_fatal_(ignore_non_fatal) {
|
|
|
944f5b |
}
|
|
|
944f5b |
|
|
|
944f5b |
virtual bool visit_internal(node_location const &l,
|
|
|
944f5b |
@@ -63,7 +65,7 @@ namespace persistent_data {
|
|
|
944f5b |
if (!checker_.check_block_nr(n) ||
|
|
|
944f5b |
!checker_.check_value_size(n) ||
|
|
|
944f5b |
!checker_.check_max_entries(n) ||
|
|
|
944f5b |
- !checker_.check_nr_entries(n, l.is_sub_root()) ||
|
|
|
944f5b |
+ !check_nr_entries(l, n) ||
|
|
|
944f5b |
!checker_.check_ordered_keys(n) ||
|
|
|
944f5b |
!checker_.check_parent_key(n, l.is_sub_root() ? boost::optional<uint64_t>() : l.key))
|
|
|
944f5b |
return false;
|
|
|
944f5b |
@@ -80,7 +82,7 @@ namespace persistent_data {
|
|
|
944f5b |
if (!checker_.check_block_nr(n) ||
|
|
|
944f5b |
!checker_.check_value_size(n) ||
|
|
|
944f5b |
!checker_.check_max_entries(n) ||
|
|
|
944f5b |
- !checker_.check_nr_entries(n, l.is_sub_root()) ||
|
|
|
944f5b |
+ !check_nr_entries(l, n) ||
|
|
|
944f5b |
!checker_.check_ordered_keys(n) ||
|
|
|
944f5b |
!checker_.check_parent_key(n, l.is_sub_root() ? boost::optional<uint64_t>() : l.key) ||
|
|
|
944f5b |
!checker_.check_leaf_key(n, last_leaf_key_[l.level()]))
|
|
|
944f5b |
@@ -106,10 +108,17 @@ namespace persistent_data {
|
|
|
944f5b |
return !seen;
|
|
|
944f5b |
}
|
|
|
944f5b |
|
|
|
944f5b |
+ template <typename ValueTraits2>
|
|
|
944f5b |
+ bool check_nr_entries(node_location const &loc,
|
|
|
944f5b |
+ btree_detail::node_ref<ValueTraits2> const &n) {
|
|
|
944f5b |
+ return ignore_non_fatal_ || checker_.check_nr_entries(n, loc.is_sub_root());
|
|
|
944f5b |
+ }
|
|
|
944f5b |
+
|
|
|
944f5b |
block_counter &bc_;
|
|
|
944f5b |
ValueCounter &vc_;
|
|
|
944f5b |
btree_node_checker checker_;
|
|
|
944f5b |
boost::optional<uint64_t> last_leaf_key_[Levels];
|
|
|
944f5b |
+ bool ignore_non_fatal_;
|
|
|
944f5b |
};
|
|
|
944f5b |
}
|
|
|
944f5b |
|
|
|
944f5b |
@@ -137,8 +146,9 @@ namespace persistent_data {
|
|
|
944f5b |
// walked. This walk should only be done once you're sure the tree
|
|
|
944f5b |
// is not corrupt.
|
|
|
944f5b |
template <unsigned Levels, typename ValueTraits, typename ValueCounter>
|
|
|
944f5b |
- void count_btree_blocks(btree<Levels, ValueTraits> const &tree, block_counter &bc, ValueCounter &vc) {
|
|
|
944f5b |
- btree_count_detail::counting_visitor<Levels, ValueTraits, ValueCounter> v(bc, vc);
|
|
|
944f5b |
+ void count_btree_blocks(btree<Levels, ValueTraits> const &tree, block_counter &bc, ValueCounter &vc,
|
|
|
944f5b |
+ bool ignore_non_fatal = false) {
|
|
|
944f5b |
+ btree_count_detail::counting_visitor<Levels, ValueTraits, ValueCounter> v(bc, vc, ignore_non_fatal);
|
|
|
944f5b |
tree.visit_depth_first(v);
|
|
|
944f5b |
}
|
|
|
944f5b |
}
|
|
|
944f5b |
diff --git a/thin-provisioning/metadata_counter.cc b/thin-provisioning/metadata_counter.cc
|
|
|
944f5b |
index 95487d2..6f0d109 100644
|
|
|
944f5b |
--- a/thin-provisioning/metadata_counter.cc
|
|
|
944f5b |
+++ b/thin-provisioning/metadata_counter.cc
|
|
|
944f5b |
@@ -10,14 +10,15 @@ using namespace thin_provisioning;
|
|
|
944f5b |
namespace {
|
|
|
944f5b |
void count_trees(transaction_manager::ptr tm,
|
|
|
944f5b |
superblock_detail::superblock const &sb,
|
|
|
944f5b |
- block_counter &bc) {
|
|
|
944f5b |
+ block_counter &bc,
|
|
|
944f5b |
+ bool ignore_non_fatal) {
|
|
|
944f5b |
|
|
|
944f5b |
// Count the device tree
|
|
|
944f5b |
{
|
|
|
944f5b |
noop_value_counter<device_tree_detail::device_details> vc;
|
|
|
944f5b |
device_tree dtree(*tm, sb.device_details_root_,
|
|
|
944f5b |
device_tree_detail::device_details_traits::ref_counter());
|
|
|
944f5b |
- count_btree_blocks(dtree, bc, vc);
|
|
|
944f5b |
+ count_btree_blocks(dtree, bc, vc, ignore_non_fatal);
|
|
|
944f5b |
}
|
|
|
944f5b |
|
|
|
944f5b |
// Count the mapping tree
|
|
|
944f5b |
@@ -25,7 +26,7 @@ namespace {
|
|
|
944f5b |
noop_value_counter<mapping_tree_detail::block_time> vc;
|
|
|
944f5b |
mapping_tree mtree(*tm, sb.data_mapping_root_,
|
|
|
944f5b |
mapping_tree_detail::block_traits::ref_counter(space_map::ptr()));
|
|
|
944f5b |
- count_btree_blocks(mtree, bc, vc);
|
|
|
944f5b |
+ count_btree_blocks(mtree, bc, vc, ignore_non_fatal);
|
|
|
944f5b |
}
|
|
|
944f5b |
}
|
|
|
944f5b |
|
|
|
944f5b |
@@ -55,17 +56,18 @@ namespace {
|
|
|
944f5b |
void thin_provisioning::count_metadata(transaction_manager::ptr tm,
|
|
|
944f5b |
superblock_detail::superblock const &sb,
|
|
|
944f5b |
block_counter &bc,
|
|
|
944f5b |
- bool skip_metadata_snap) {
|
|
|
944f5b |
+ bool skip_metadata_snap,
|
|
|
944f5b |
+ bool ignore_non_fatal) {
|
|
|
944f5b |
// Count the superblock
|
|
|
944f5b |
bc.inc(superblock_detail::SUPERBLOCK_LOCATION);
|
|
|
944f5b |
- count_trees(tm, sb, bc);
|
|
|
944f5b |
+ count_trees(tm, sb, bc, ignore_non_fatal);
|
|
|
944f5b |
|
|
|
944f5b |
// Count the metadata snap, if present
|
|
|
944f5b |
if (!skip_metadata_snap && sb.metadata_snap_ != superblock_detail::SUPERBLOCK_LOCATION) {
|
|
|
944f5b |
bc.inc(sb.metadata_snap_);
|
|
|
944f5b |
|
|
|
944f5b |
superblock_detail::superblock snap = read_superblock(tm->get_bm(), sb.metadata_snap_);
|
|
|
944f5b |
- count_trees(tm, snap, bc);
|
|
|
944f5b |
+ count_trees(tm, snap, bc, ignore_non_fatal);
|
|
|
944f5b |
}
|
|
|
944f5b |
|
|
|
944f5b |
count_space_maps(tm, sb, bc);
|
|
|
944f5b |
diff --git a/thin-provisioning/metadata_counter.h b/thin-provisioning/metadata_counter.h
|
|
|
944f5b |
index bc65ab9..ea9813d 100644
|
|
|
944f5b |
--- a/thin-provisioning/metadata_counter.h
|
|
|
944f5b |
+++ b/thin-provisioning/metadata_counter.h
|
|
|
944f5b |
@@ -10,7 +10,8 @@ namespace thin_provisioning {
|
|
|
944f5b |
void count_metadata(transaction_manager::ptr tm,
|
|
|
944f5b |
superblock_detail::superblock const &sb,
|
|
|
944f5b |
block_counter &bc,
|
|
|
944f5b |
- bool skip_metadata_snap = false);
|
|
|
944f5b |
+ bool skip_metadata_snap = false,
|
|
|
944f5b |
+ bool ignore_non_fatal = false);
|
|
|
944f5b |
}
|
|
|
944f5b |
|
|
|
944f5b |
//----------------------------------------------------------------
|
|
|
944f5b |
diff --git a/thin-provisioning/thin_check.cc b/thin-provisioning/thin_check.cc
|
|
|
944f5b |
index c2612b5..5900902 100644
|
|
|
944f5b |
--- a/thin-provisioning/thin_check.cc
|
|
|
944f5b |
+++ b/thin-provisioning/thin_check.cc
|
|
|
944f5b |
@@ -165,7 +165,7 @@ namespace {
|
|
|
944f5b |
transaction_manager::ptr tm) {
|
|
|
944f5b |
block_counter bc;
|
|
|
944f5b |
|
|
|
944f5b |
- count_metadata(tm, sb, bc);
|
|
|
944f5b |
+ count_metadata(tm, sb, bc, false, fs.ignore_non_fatal_errors);
|
|
|
944f5b |
|
|
|
944f5b |
// Finally we need to check the metadata space map agrees
|
|
|
944f5b |
// with the counts we've just calculated.
|