[thin-provisioning] walk_mapping_tree()
This commit is contained in:
parent
a06139ef9f
commit
b87742ccff
@ -131,12 +131,12 @@ namespace {
|
||||
using namespace thin_provisioning;
|
||||
using namespace mapping_tree_detail;
|
||||
|
||||
struct block_time_visitor {
|
||||
struct noop_block_time_visitor : public mapping_tree_detail::mapping_visitor {
|
||||
virtual void visit(btree_path const &, block_time const &) {
|
||||
}
|
||||
};
|
||||
|
||||
struct block_visitor {
|
||||
struct noop_block_visitor : public mapping_tree_detail::device_visitor {
|
||||
virtual void visit(btree_path const &, uint64_t) {
|
||||
}
|
||||
};
|
||||
@ -168,27 +168,58 @@ namespace {
|
||||
};
|
||||
}
|
||||
|
||||
void
|
||||
thin_provisioning::walk_mapping_tree(dev_tree const &tree,
|
||||
mapping_tree_detail::device_visitor &dev_v,
|
||||
mapping_tree_detail::damage_visitor &dv)
|
||||
{
|
||||
block_counter counter;
|
||||
ll_damage_visitor ll_dv(dv);
|
||||
btree_visit_values(tree, counter, dev_v, ll_dv);
|
||||
}
|
||||
|
||||
void
|
||||
thin_provisioning::check_mapping_tree(dev_tree const &tree,
|
||||
mapping_tree_detail::damage_visitor &visitor)
|
||||
{
|
||||
block_counter counter; // FIXME: get rid of this counter arg
|
||||
block_visitor vv;
|
||||
ll_damage_visitor dv(visitor);
|
||||
noop_block_visitor dev_v;
|
||||
walk_mapping_tree(tree, dev_v, visitor);
|
||||
}
|
||||
|
||||
btree_visit_values(tree, counter, vv, dv);
|
||||
void
|
||||
thin_provisioning::walk_mapping_tree(mapping_tree const &tree,
|
||||
mapping_tree_detail::mapping_visitor &mv,
|
||||
mapping_tree_detail::damage_visitor &dv)
|
||||
{
|
||||
block_counter counter;
|
||||
ll_damage_visitor ll_dv(dv);
|
||||
btree_visit_values(tree, counter, mv, ll_dv);
|
||||
}
|
||||
|
||||
void
|
||||
thin_provisioning::check_mapping_tree(mapping_tree const &tree,
|
||||
mapping_tree_detail::damage_visitor &visitor)
|
||||
{
|
||||
block_counter counter; //FIXME: get rid of this counter arg
|
||||
block_time_visitor vv;
|
||||
ll_damage_visitor dv(visitor);
|
||||
noop_block_time_visitor mv;
|
||||
walk_mapping_tree(tree, mv, visitor);
|
||||
}
|
||||
|
||||
btree_visit_values(tree, counter, vv, dv);
|
||||
void
|
||||
thin_provisioning::walk_mapping_tree(single_mapping_tree const &tree,
|
||||
mapping_tree_detail::mapping_visitor &mv,
|
||||
mapping_tree_detail::damage_visitor &dv)
|
||||
{
|
||||
block_counter counter;
|
||||
ll_damage_visitor ll_dv(dv);
|
||||
btree_visit_values(tree, counter, mv, ll_dv);
|
||||
}
|
||||
|
||||
void
|
||||
thin_provisioning::check_mapping_tree(single_mapping_tree const &tree,
|
||||
mapping_tree_detail::damage_visitor &visitor)
|
||||
{
|
||||
noop_block_time_visitor mv;
|
||||
walk_mapping_tree(tree, mv, visitor);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
|
@ -92,6 +92,8 @@ namespace thin_provisioning {
|
||||
|
||||
class damage_visitor {
|
||||
public:
|
||||
typedef boost::shared_ptr<damage_visitor> ptr;
|
||||
|
||||
virtual ~damage_visitor() {}
|
||||
|
||||
void visit(damage const &d) {
|
||||
@ -102,16 +104,42 @@ namespace thin_provisioning {
|
||||
virtual void visit(missing_mappings const &d) = 0;
|
||||
};
|
||||
|
||||
class mapping_visitor {
|
||||
public:
|
||||
virtual ~mapping_visitor() {}
|
||||
|
||||
// path contains 2 elements, the dev key, then the oblock
|
||||
virtual void visit(btree_path const &path, block_time const &m) = 0;
|
||||
};
|
||||
|
||||
class device_visitor {
|
||||
public:
|
||||
virtual ~device_visitor() {}
|
||||
virtual void visit(btree_path const &path, block_address dtree_root) = 0;
|
||||
};
|
||||
}
|
||||
|
||||
typedef persistent_data::btree<2, mapping_tree_detail::block_traits> mapping_tree;
|
||||
typedef persistent_data::btree<1, mapping_tree_detail::mtree_traits> dev_tree;
|
||||
typedef persistent_data::btree<1, mapping_tree_detail::block_traits> single_mapping_tree;
|
||||
|
||||
void walk_mapping_tree(dev_tree const &tree,
|
||||
mapping_tree_detail::device_visitor &dev_v,
|
||||
mapping_tree_detail::damage_visitor &dv);
|
||||
void check_mapping_tree(dev_tree const &tree,
|
||||
mapping_tree_detail::damage_visitor &visitor);
|
||||
|
||||
void walk_mapping_tree(mapping_tree const &tree,
|
||||
mapping_tree_detail::mapping_visitor &mv,
|
||||
mapping_tree_detail::damage_visitor &dv);
|
||||
void check_mapping_tree(mapping_tree const &tree,
|
||||
mapping_tree_detail::damage_visitor &visitor);
|
||||
|
||||
void walk_mapping_tree(single_mapping_tree const &tree,
|
||||
mapping_tree_detail::mapping_visitor &mv,
|
||||
mapping_tree_detail::damage_visitor &dv);
|
||||
void check_mapping_tree(single_mapping_tree const &tree,
|
||||
mapping_tree_detail::damage_visitor &visitor);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user