Merge pull request #65 from mingnus/v0.7-devel-fix
Minor fixes for new dev-tools
This commit is contained in:
commit
ef40277d55
@ -37,7 +37,7 @@ namespace persistent_data {
|
||||
for (unsigned i = 0; i < nr; i++) {
|
||||
// FIXME: confirm l2 is correct
|
||||
node_location l2(l);
|
||||
l2.push_key(i);
|
||||
l2.push_key(n.key_at(i));
|
||||
vc_.visit(l2, n.value_at(i));
|
||||
}
|
||||
|
||||
|
@ -742,7 +742,7 @@ persistent_data::create_disk_sm(transaction_manager &tm,
|
||||
}
|
||||
|
||||
checked_space_map::ptr
|
||||
persistent_data::open_disk_sm(transaction_manager &tm, void *root)
|
||||
persistent_data::open_disk_sm(transaction_manager &tm, void const *root)
|
||||
{
|
||||
sm_root_disk d;
|
||||
sm_root v;
|
||||
@ -770,7 +770,7 @@ persistent_data::create_metadata_sm(transaction_manager &tm, block_address nr_bl
|
||||
}
|
||||
|
||||
checked_space_map::ptr
|
||||
persistent_data::open_metadata_sm(transaction_manager &tm, void *root)
|
||||
persistent_data::open_metadata_sm(transaction_manager &tm, void const *root)
|
||||
{
|
||||
sm_root_disk d;
|
||||
sm_root v;
|
||||
|
@ -29,13 +29,13 @@ namespace persistent_data {
|
||||
create_disk_sm(transaction_manager &tm, block_address nr_blocks);
|
||||
|
||||
checked_space_map::ptr
|
||||
open_disk_sm(transaction_manager &tm, void *root);
|
||||
open_disk_sm(transaction_manager &tm, void const *root);
|
||||
|
||||
checked_space_map::ptr
|
||||
create_metadata_sm(transaction_manager &tm, block_address nr_blocks);
|
||||
|
||||
checked_space_map::ptr
|
||||
open_metadata_sm(transaction_manager &tm, void *root);
|
||||
open_metadata_sm(transaction_manager &tm, void const *root);
|
||||
|
||||
bcache::validator::ptr bitmap_validator();
|
||||
|
||||
|
@ -193,14 +193,16 @@ namespace {
|
||||
|
||||
class single_mapping_tree_damage_visitor {
|
||||
public:
|
||||
single_mapping_tree_damage_visitor(damage_visitor &v)
|
||||
: v_(v) {
|
||||
single_mapping_tree_damage_visitor(damage_visitor &v,
|
||||
uint64_t dev_id)
|
||||
: v_(v),
|
||||
dev_id_(dev_id) {
|
||||
}
|
||||
|
||||
virtual void visit(btree_path const &path, btree_detail::damage const &d) {
|
||||
switch (path.size()) {
|
||||
case 0:
|
||||
v_.visit(missing_devices(d.desc_, d.lost_keys_));
|
||||
v_.visit(missing_mappings(d.desc_, dev_id_, d.lost_keys_));
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -210,6 +212,7 @@ namespace {
|
||||
|
||||
private:
|
||||
damage_visitor &v_;
|
||||
uint64_t dev_id_;
|
||||
};
|
||||
|
||||
}
|
||||
@ -250,19 +253,21 @@ thin_provisioning::check_mapping_tree(mapping_tree const &tree,
|
||||
|
||||
void
|
||||
thin_provisioning::walk_mapping_tree(single_mapping_tree const &tree,
|
||||
uint64_t dev_id,
|
||||
mapping_tree_detail::mapping_visitor &mv,
|
||||
mapping_tree_detail::damage_visitor &dv)
|
||||
{
|
||||
single_mapping_tree_damage_visitor ll_dv(dv);
|
||||
single_mapping_tree_damage_visitor ll_dv(dv, dev_id);
|
||||
btree_visit_values(tree, mv, ll_dv);
|
||||
}
|
||||
|
||||
void
|
||||
thin_provisioning::check_mapping_tree(single_mapping_tree const &tree,
|
||||
uint64_t dev_id,
|
||||
mapping_tree_detail::damage_visitor &visitor)
|
||||
{
|
||||
noop_block_time_visitor mv;
|
||||
walk_mapping_tree(tree, mv, visitor);
|
||||
walk_mapping_tree(tree, dev_id, mv, visitor);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
|
@ -139,9 +139,11 @@ namespace thin_provisioning {
|
||||
mapping_tree_detail::damage_visitor &visitor);
|
||||
|
||||
void walk_mapping_tree(single_mapping_tree const &tree,
|
||||
uint64_t dev_id,
|
||||
mapping_tree_detail::mapping_visitor &mv,
|
||||
mapping_tree_detail::damage_visitor &dv);
|
||||
void check_mapping_tree(single_mapping_tree const &tree,
|
||||
uint64_t dev_id,
|
||||
mapping_tree_detail::damage_visitor &visitor);
|
||||
}
|
||||
|
||||
|
@ -7,51 +7,53 @@ using namespace thin_provisioning;
|
||||
|
||||
//----------------------------------------------------------------
|
||||
|
||||
void thin_provisioning::count_trees(transaction_manager::ptr tm,
|
||||
superblock_detail::superblock &sb,
|
||||
block_counter &bc) {
|
||||
namespace {
|
||||
void count_trees(transaction_manager::ptr tm,
|
||||
superblock_detail::superblock const &sb,
|
||||
block_counter &bc) {
|
||||
|
||||
// Count the device tree
|
||||
{
|
||||
noop_value_counter<device_tree_detail::device_details> vc;
|
||||
device_tree dtree(*tm, sb.device_details_root_,
|
||||
device_tree_detail::device_details_traits::ref_counter());
|
||||
count_btree_blocks(dtree, bc, vc);
|
||||
// Count the device tree
|
||||
{
|
||||
noop_value_counter<device_tree_detail::device_details> vc;
|
||||
device_tree dtree(*tm, sb.device_details_root_,
|
||||
device_tree_detail::device_details_traits::ref_counter());
|
||||
count_btree_blocks(dtree, bc, vc);
|
||||
}
|
||||
|
||||
// Count the mapping tree
|
||||
{
|
||||
noop_value_counter<mapping_tree_detail::block_time> vc;
|
||||
mapping_tree mtree(*tm, sb.data_mapping_root_,
|
||||
mapping_tree_detail::block_traits::ref_counter(space_map::ptr()));
|
||||
count_btree_blocks(mtree, bc, vc);
|
||||
}
|
||||
}
|
||||
|
||||
// Count the mapping tree
|
||||
{
|
||||
noop_value_counter<mapping_tree_detail::block_time> vc;
|
||||
mapping_tree mtree(*tm, sb.data_mapping_root_,
|
||||
mapping_tree_detail::block_traits::ref_counter(space_map::ptr()));
|
||||
count_btree_blocks(mtree, bc, vc);
|
||||
void count_space_maps(transaction_manager::ptr tm,
|
||||
superblock_detail::superblock const &sb,
|
||||
block_counter &bc) {
|
||||
// Count the metadata space map (no-throw)
|
||||
try {
|
||||
persistent_space_map::ptr metadata_sm =
|
||||
open_metadata_sm(*tm, static_cast<void const *>(&sb.metadata_space_map_root_));
|
||||
metadata_sm->count_metadata(bc);
|
||||
} catch (std::exception &e) {
|
||||
cerr << e.what() << endl;
|
||||
}
|
||||
|
||||
// Count the data space map (no-throw)
|
||||
{
|
||||
persistent_space_map::ptr data_sm =
|
||||
open_disk_sm(*tm, static_cast<void const *>(&sb.data_space_map_root_));
|
||||
data_sm->count_metadata(bc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void thin_provisioning::count_space_maps(transaction_manager::ptr tm,
|
||||
superblock_detail::superblock &sb,
|
||||
block_counter &bc) {
|
||||
// Count the metadata space map (no-throw)
|
||||
try {
|
||||
persistent_space_map::ptr metadata_sm =
|
||||
open_metadata_sm(*tm, static_cast<void *>(&sb.metadata_space_map_root_));
|
||||
metadata_sm->count_metadata(bc);
|
||||
} catch (std::exception &e) {
|
||||
cerr << e.what() << endl;
|
||||
}
|
||||
|
||||
// Count the data space map (no-throw)
|
||||
try {
|
||||
persistent_space_map::ptr data_sm =
|
||||
open_disk_sm(*tm, static_cast<void *>(&sb.data_space_map_root_));
|
||||
data_sm->count_metadata(bc);
|
||||
} catch (std::exception &e) {
|
||||
cerr << e.what() << endl;
|
||||
}
|
||||
}
|
||||
//----------------------------------------------------------------
|
||||
|
||||
void thin_provisioning::count_metadata(transaction_manager::ptr tm,
|
||||
superblock_detail::superblock &sb,
|
||||
superblock_detail::superblock const &sb,
|
||||
block_counter &bc,
|
||||
bool skip_metadata_snap) {
|
||||
// Count the superblock
|
||||
|
@ -7,14 +7,8 @@
|
||||
//----------------------------------------------------------------
|
||||
|
||||
namespace thin_provisioning {
|
||||
void count_trees(transaction_manager::ptr tm,
|
||||
superblock_detail::superblock &sb,
|
||||
block_counter &bc);
|
||||
void count_space_maps(transaction_manager::ptr tm,
|
||||
superblock_detail::superblock &sb,
|
||||
block_counter &bc);
|
||||
void count_metadata(transaction_manager::ptr tm,
|
||||
superblock_detail::superblock &sb,
|
||||
superblock_detail::superblock const &sb,
|
||||
block_counter &bc,
|
||||
bool skip_metadata_snap = false);
|
||||
}
|
||||
|
@ -196,7 +196,7 @@ namespace {
|
||||
|
||||
try {
|
||||
if (!opts_.skip_mappings_)
|
||||
emit_mappings(tree_root);
|
||||
emit_mappings(dev_id, tree_root);
|
||||
} catch (exception &e) {
|
||||
cerr << e.what();
|
||||
e_->end_device();
|
||||
@ -213,11 +213,11 @@ namespace {
|
||||
}
|
||||
|
||||
private:
|
||||
void emit_mappings(block_address subtree_root) {
|
||||
void emit_mappings(uint64_t dev_id, block_address subtree_root) {
|
||||
mapping_emitter me(e_);
|
||||
single_mapping_tree tree(*md_->tm_, subtree_root,
|
||||
mapping_tree_detail::block_time_ref_counter(md_->data_sm_));
|
||||
walk_mapping_tree(tree, static_cast<mapping_tree_detail::mapping_visitor &>(me), *damage_policy_);
|
||||
walk_mapping_tree(tree, dev_id, static_cast<mapping_tree_detail::mapping_visitor &>(me), *damage_policy_);
|
||||
}
|
||||
|
||||
dump_options const &opts_;
|
||||
@ -274,7 +274,8 @@ thin_provisioning::metadata_dump_subtree(metadata::ptr md, emitter::ptr e, bool
|
||||
mapping_emitter me(e);
|
||||
single_mapping_tree tree(*md->tm_, subtree_root,
|
||||
mapping_tree_detail::block_time_ref_counter(md->data_sm_));
|
||||
walk_mapping_tree(tree, static_cast<mapping_tree_detail::mapping_visitor &>(me),
|
||||
// FIXME: pass the current device id instead of zero
|
||||
walk_mapping_tree(tree, 0, static_cast<mapping_tree_detail::mapping_visitor &>(me),
|
||||
*mapping_damage_policy(repair));
|
||||
}
|
||||
|
||||
|
@ -248,7 +248,7 @@ namespace {
|
||||
|
||||
mapping_pass1 pass1(mappings);
|
||||
fatal_mapping_damage dv;
|
||||
walk_mapping_tree(dev_mappings, pass1, dv);
|
||||
walk_mapping_tree(dev_mappings, dev_id, pass1, dv);
|
||||
}
|
||||
|
||||
|
||||
@ -264,7 +264,7 @@ namespace {
|
||||
|
||||
mapping_pass2 pass2(mappings);
|
||||
fatal_mapping_damage dv;
|
||||
walk_mapping_tree(dev_mappings, pass2, dv);
|
||||
walk_mapping_tree(dev_mappings, dev_id, pass2, dv);
|
||||
return pass2.get_exclusives();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user