[thin-provisioning] walk_device_tree()
This commit is contained in:
parent
0fe7dddd8a
commit
a06139ef9f
@ -10,9 +10,22 @@ using namespace thin_provisioning;
|
||||
namespace {
|
||||
using namespace device_tree_detail;
|
||||
|
||||
struct visitor_adapter {
|
||||
visitor_adapter(device_visitor &dv)
|
||||
: dv_(dv) {
|
||||
}
|
||||
|
||||
void visit(btree_path const &path, device_details const &dd) {
|
||||
dv_.visit(path[0], dd);
|
||||
}
|
||||
|
||||
private:
|
||||
device_visitor &dv_;
|
||||
};
|
||||
|
||||
// No op for now, should add sanity checks in here however.
|
||||
struct leaf_visitor {
|
||||
virtual void visit(btree_path const &path, device_details const &dd) {
|
||||
struct noop_visitor : public device_visitor {
|
||||
virtual void visit(block_address dev_id, device_details const &dd) {
|
||||
}
|
||||
};
|
||||
|
||||
@ -62,15 +75,26 @@ namespace thin_provisioning {
|
||||
v.visit(*this);
|
||||
}
|
||||
}
|
||||
|
||||
void check_device_tree(device_tree const &tree, damage_visitor &visitor)
|
||||
{
|
||||
block_counter counter; // FIXME: get rid of this counter arg
|
||||
leaf_visitor vv;
|
||||
ll_damage_visitor dv(visitor);
|
||||
|
||||
btree_visit_values(tree, counter, vv, dv);
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
|
||||
void
|
||||
thin_provisioning::walk_device_tree(device_tree const &tree,
|
||||
device_tree_detail::device_visitor &vv,
|
||||
device_tree_detail::damage_visitor &dv)
|
||||
{
|
||||
block_counter counter;
|
||||
visitor_adapter av(vv);
|
||||
ll_damage_visitor ll_dv(dv);
|
||||
btree_visit_values(tree, counter, av, ll_dv);
|
||||
}
|
||||
|
||||
void
|
||||
thin_provisioning::check_device_tree(device_tree const &tree, damage_visitor &visitor)
|
||||
{
|
||||
noop_visitor vv;
|
||||
walk_device_tree(tree, vv, visitor);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
|
@ -4,6 +4,8 @@
|
||||
#include "persistent-data/data-structures/btree.h"
|
||||
#include "persistent-data/run.h"
|
||||
|
||||
using namespace boost;
|
||||
|
||||
//----------------------------------------------------------------
|
||||
|
||||
namespace thin_provisioning {
|
||||
@ -48,6 +50,8 @@ namespace thin_provisioning {
|
||||
|
||||
class damage_visitor {
|
||||
public:
|
||||
typedef shared_ptr<damage_visitor> ptr;
|
||||
|
||||
virtual ~damage_visitor() {}
|
||||
|
||||
void visit(damage const &d) {
|
||||
@ -59,10 +63,18 @@ namespace thin_provisioning {
|
||||
|
||||
// FIXME: need to add some more damage types for bad leaf data
|
||||
|
||||
class device_visitor {
|
||||
public:
|
||||
virtual ~device_visitor() {}
|
||||
virtual void visit(block_address dev_id, device_details const &v) = 0;
|
||||
};
|
||||
};
|
||||
|
||||
typedef persistent_data::btree<1, device_tree_detail::device_details_traits> device_tree;
|
||||
|
||||
void walk_device_tree(device_tree const &tree,
|
||||
device_tree_detail::device_visitor &dev_v,
|
||||
device_tree_detail::damage_visitor &dv);
|
||||
void check_device_tree(device_tree const &tree,
|
||||
device_tree_detail::damage_visitor &visitor);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user