[btree] visitor now passed as a reference rather than shared_ptr
This commit is contained in:
parent
5913de5e38
commit
a828cde96d
@ -334,7 +334,7 @@ namespace persistent_data {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Walks the tree in depth first order
|
// Walks the tree in depth first order
|
||||||
void visit_depth_first(typename visitor::ptr visitor) const;
|
void visit_depth_first(visitor &visitor) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
template <typename ValueTraits2, typename Search>
|
template <typename ValueTraits2, typename Search>
|
||||||
@ -362,7 +362,7 @@ namespace persistent_data {
|
|||||||
uint64_t key,
|
uint64_t key,
|
||||||
int *index);
|
int *index);
|
||||||
|
|
||||||
void walk_tree(typename visitor::ptr visitor,
|
void walk_tree(visitor &visitor,
|
||||||
btree_detail::node_location const &loc,
|
btree_detail::node_location const &loc,
|
||||||
block_address b) const;
|
block_address b) const;
|
||||||
|
|
||||||
|
@ -742,7 +742,7 @@ insert_location(btree_detail::shadow_spine &spine,
|
|||||||
|
|
||||||
template <unsigned Levels, typename ValueTraits>
|
template <unsigned Levels, typename ValueTraits>
|
||||||
void
|
void
|
||||||
btree<Levels, ValueTraits>::visit_depth_first(typename visitor::ptr visitor) const
|
btree<Levels, ValueTraits>::visit_depth_first(visitor &v) const
|
||||||
{
|
{
|
||||||
node_location loc;
|
node_location loc;
|
||||||
|
|
||||||
@ -751,13 +751,13 @@ btree<Levels, ValueTraits>::visit_depth_first(typename visitor::ptr visitor) con
|
|||||||
loc.sub_root = true;
|
loc.sub_root = true;
|
||||||
loc.key = boost::optional<uint64_t>();
|
loc.key = boost::optional<uint64_t>();
|
||||||
|
|
||||||
walk_tree(visitor, loc, root_);
|
walk_tree(v, loc, root_);
|
||||||
visitor->visit_complete();
|
v.visit_complete();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <unsigned Levels, typename ValueTraits>
|
template <unsigned Levels, typename ValueTraits>
|
||||||
void
|
void
|
||||||
btree<Levels, ValueTraits>::walk_tree(typename visitor::ptr visitor,
|
btree<Levels, ValueTraits>::walk_tree(visitor &v,
|
||||||
node_location const &loc,
|
node_location const &loc,
|
||||||
block_address b) const
|
block_address b) const
|
||||||
{
|
{
|
||||||
@ -766,7 +766,7 @@ btree<Levels, ValueTraits>::walk_tree(typename visitor::ptr visitor,
|
|||||||
read_ref blk = tm_->read_lock(b);
|
read_ref blk = tm_->read_lock(b);
|
||||||
internal_node o = to_node<uint64_traits>(blk);
|
internal_node o = to_node<uint64_traits>(blk);
|
||||||
if (o.get_type() == INTERNAL) {
|
if (o.get_type() == INTERNAL) {
|
||||||
if (visitor->visit_internal(loc, o))
|
if (v.visit_internal(loc, o))
|
||||||
for (unsigned i = 0; i < o.get_nr_entries(); i++) {
|
for (unsigned i = 0; i < o.get_nr_entries(); i++) {
|
||||||
node_location loc2(loc);
|
node_location loc2(loc);
|
||||||
|
|
||||||
@ -774,11 +774,11 @@ btree<Levels, ValueTraits>::walk_tree(typename visitor::ptr visitor,
|
|||||||
loc2.sub_root = false;
|
loc2.sub_root = false;
|
||||||
loc2.key = boost::optional<uint64_t>(o.key_at(i));
|
loc2.key = boost::optional<uint64_t>(o.key_at(i));
|
||||||
|
|
||||||
walk_tree(visitor, loc2, o.value_at(i));
|
walk_tree(v, loc2, o.value_at(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (loc.level < Levels - 1) {
|
} else if (loc.level < Levels - 1) {
|
||||||
if (visitor->visit_internal_leaf(loc, o))
|
if (v.visit_internal_leaf(loc, o))
|
||||||
for (unsigned i = 0; i < o.get_nr_entries(); i++) {
|
for (unsigned i = 0; i < o.get_nr_entries(); i++) {
|
||||||
node_location loc2(loc);
|
node_location loc2(loc);
|
||||||
|
|
||||||
@ -787,12 +787,12 @@ btree<Levels, ValueTraits>::walk_tree(typename visitor::ptr visitor,
|
|||||||
loc2.sub_root = true;
|
loc2.sub_root = true;
|
||||||
loc2.key = boost::optional<uint64_t>(o.key_at(i));
|
loc2.key = boost::optional<uint64_t>(o.key_at(i));
|
||||||
|
|
||||||
walk_tree(visitor, loc, o.value_at(i));
|
walk_tree(v, loc, o.value_at(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
leaf_node ov = to_node<ValueTraits>(blk);
|
leaf_node ov = to_node<ValueTraits>(blk);
|
||||||
visitor->visit_leaf(loc, ov);
|
v.visit_leaf(loc, ov);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -360,7 +360,7 @@ namespace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
virtual void check(block_counter &counter) const {
|
virtual void check(block_counter &counter) const {
|
||||||
ref_count_checker::ptr v(new ref_count_checker(counter));
|
ref_count_checker v(counter);
|
||||||
ref_counts_.visit_depth_first(v);
|
ref_counts_.visit_depth_first(v);
|
||||||
|
|
||||||
block_address nr_entries = div_up<block_address>(get_nr_blocks(), ENTRIES_PER_BLOCK);
|
block_address nr_entries = div_up<block_address>(get_nr_blocks(), ENTRIES_PER_BLOCK);
|
||||||
@ -584,9 +584,9 @@ namespace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
virtual void check(block_counter &counter, block_address nr_index_entries) const {
|
virtual void check(block_counter &counter, block_address nr_index_entries) const {
|
||||||
bitmap_tree_validator::ptr v(new bitmap_tree_validator(counter));
|
bitmap_tree_validator v(counter);
|
||||||
bitmaps_.visit_depth_first(v);
|
bitmaps_.visit_depth_first(v);
|
||||||
v->check_all_index_entries_present(nr_index_entries);
|
v.check_all_index_entries_present(nr_index_entries);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -75,7 +75,7 @@ damage_list_ptr
|
|||||||
device_checker::check()
|
device_checker::check()
|
||||||
{
|
{
|
||||||
block_counter counter;
|
block_counter counter;
|
||||||
device_visitor::ptr v(new device_visitor(counter));
|
device_visitor v(counter);
|
||||||
transaction_manager::ptr tm(open_core_tm(bm_));
|
transaction_manager::ptr tm(open_core_tm(bm_));
|
||||||
detail_tree::ptr details(new detail_tree(tm, root_,
|
detail_tree::ptr details(new detail_tree(tm, root_,
|
||||||
device_details_traits::ref_counter()));
|
device_details_traits::ref_counter()));
|
||||||
|
@ -198,13 +198,12 @@ thin_provisioning::metadata_dump(metadata::ptr md, emitter::ptr e, bool repair)
|
|||||||
md->data_sm_->get_nr_blocks(),
|
md->data_sm_->get_nr_blocks(),
|
||||||
md_snap);
|
md_snap);
|
||||||
|
|
||||||
details_extractor::ptr de(new details_extractor);
|
details_extractor de;
|
||||||
|
|
||||||
md->details_->visit_depth_first(de);
|
md->details_->visit_depth_first(de);
|
||||||
if (de->corruption() && !repair)
|
if (de.corruption() && !repair)
|
||||||
throw runtime_error("corruption in device details tree");
|
throw runtime_error("corruption in device details tree");
|
||||||
|
|
||||||
map<uint64_t, device_details> const &devs = de->get_devices();
|
map<uint64_t, device_details> const &devs = de.get_devices();
|
||||||
|
|
||||||
map<uint64_t, device_details>::const_iterator it, end = devs.end();
|
map<uint64_t, device_details>::const_iterator it, end = devs.end();
|
||||||
for (it = devs.begin(); it != end; ++it) {
|
for (it = devs.begin(); it != end; ++it) {
|
||||||
@ -217,10 +216,10 @@ thin_provisioning::metadata_dump(metadata::ptr md, emitter::ptr e, bool repair)
|
|||||||
dd.creation_time_,
|
dd.creation_time_,
|
||||||
dd.snapshotted_time_);
|
dd.snapshotted_time_);
|
||||||
|
|
||||||
mappings_extractor::ptr me(new mappings_extractor(dev_id, e, md->metadata_sm_, md->data_sm_));
|
mappings_extractor me(dev_id, e, md->metadata_sm_, md->data_sm_);
|
||||||
md->mappings_->visit_depth_first(me);
|
md->mappings_->visit_depth_first(me);
|
||||||
|
|
||||||
if (me->corruption() && !repair) {
|
if (me.corruption() && !repair) {
|
||||||
ostringstream out;
|
ostringstream out;
|
||||||
out << "corruption in mappings for device " << dev_id;
|
out << "corruption in mappings for device " << dev_id;
|
||||||
throw runtime_error(out.str());
|
throw runtime_error(out.str());
|
||||||
|
@ -91,7 +91,7 @@ namespace {
|
|||||||
void check_constraints(btree<1, uint64_traits>::ptr tree) {
|
void check_constraints(btree<1, uint64_traits>::ptr tree) {
|
||||||
typedef btree<1, uint64_traits> tree_type;
|
typedef btree<1, uint64_traits> tree_type;
|
||||||
|
|
||||||
tree_type::visitor::ptr v(new constraint_visitor);
|
constraint_visitor v;
|
||||||
tree->visit_depth_first(v);
|
tree->visit_depth_first(v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -355,12 +355,12 @@ TEST_F(DeviceCheckerTests, damaging_some_btree_nodes_results_in_the_correct_devi
|
|||||||
|
|
||||||
b.build();
|
b.build();
|
||||||
|
|
||||||
devices_visitor::ptr scanner(new devices_visitor);
|
devices_visitor scanner;
|
||||||
transaction_manager::ptr tm = open_temporary_tm(bm_);
|
transaction_manager::ptr tm = open_temporary_tm(bm_);
|
||||||
detail_tree::ptr devices(new detail_tree(tm, devices_root(),
|
detail_tree::ptr devices(new detail_tree(tm, devices_root(),
|
||||||
device_details_traits::ref_counter()));
|
device_details_traits::ref_counter()));
|
||||||
devices->visit_depth_first(scanner);
|
devices->visit_depth_first(scanner);
|
||||||
devices_visitor::node_info n = scanner->random_node();
|
devices_visitor::node_info n = scanner.random_node();
|
||||||
zero_block(n.b);
|
zero_block(n.b);
|
||||||
|
|
||||||
damage_list_ptr damage = mk_checker()->check();
|
damage_list_ptr damage = mk_checker()->check();
|
||||||
|
Loading…
Reference in New Issue
Block a user