[thin] Stop metadata counting on the first error
This commit is contained in:
@@ -8,7 +8,7 @@ using namespace thin_provisioning;
|
||||
//----------------------------------------------------------------
|
||||
|
||||
namespace {
|
||||
void count_trees(transaction_manager::ptr tm,
|
||||
bool count_trees(transaction_manager::ptr tm,
|
||||
superblock_detail::superblock const &sb,
|
||||
block_counter &bc) {
|
||||
|
||||
@@ -27,11 +27,15 @@ namespace {
|
||||
mapping_tree_detail::block_traits::ref_counter(space_map::ptr()));
|
||||
count_btree_blocks(mtree, bc, vc);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void count_space_maps(transaction_manager::ptr tm,
|
||||
bool count_space_maps(transaction_manager::ptr tm,
|
||||
superblock_detail::superblock const &sb,
|
||||
block_counter &bc) {
|
||||
bool ret = true;
|
||||
|
||||
// Count the metadata space map (no-throw)
|
||||
try {
|
||||
persistent_space_map::ptr metadata_sm =
|
||||
@@ -39,36 +43,46 @@ namespace {
|
||||
metadata_sm->count_metadata(bc);
|
||||
} catch (std::exception &e) {
|
||||
cerr << e.what() << endl;
|
||||
ret = false;
|
||||
}
|
||||
|
||||
// Count the data space map (no-throw)
|
||||
{
|
||||
try {
|
||||
persistent_space_map::ptr data_sm =
|
||||
open_disk_sm(*tm, static_cast<void const *>(&sb.data_space_map_root_));
|
||||
data_sm->count_metadata(bc);
|
||||
} catch (std::exception &e) {
|
||||
cerr << e.what() << endl;
|
||||
ret = false;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
|
||||
void thin_provisioning::count_metadata(transaction_manager::ptr tm,
|
||||
bool thin_provisioning::count_metadata(transaction_manager::ptr tm,
|
||||
superblock_detail::superblock const &sb,
|
||||
block_counter &bc,
|
||||
bool skip_metadata_snap) {
|
||||
bool ret = true;
|
||||
|
||||
// Count the superblock
|
||||
bc.inc(superblock_detail::SUPERBLOCK_LOCATION);
|
||||
count_trees(tm, sb, bc);
|
||||
ret &= count_trees(tm, sb, bc);
|
||||
|
||||
// Count the metadata snap, if present
|
||||
if (!skip_metadata_snap && sb.metadata_snap_ != superblock_detail::SUPERBLOCK_LOCATION) {
|
||||
bc.inc(sb.metadata_snap_);
|
||||
|
||||
superblock_detail::superblock snap = read_superblock(tm->get_bm(), sb.metadata_snap_);
|
||||
count_trees(tm, snap, bc);
|
||||
ret &= count_trees(tm, snap, bc);
|
||||
}
|
||||
|
||||
count_space_maps(tm, sb, bc);
|
||||
ret &= count_space_maps(tm, sb, bc);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user