Merge pull request #45 from mingnus/v0.6.2-repairtool
Minor fixes for new dev-tools
This commit is contained in:
commit
752163b681
@ -47,6 +47,13 @@ namespace {
|
||||
|
||||
namespace thin_provisioning {
|
||||
namespace device_tree_detail {
|
||||
device_details::device_details()
|
||||
: mapped_blocks_(0),
|
||||
transaction_id_(0),
|
||||
creation_time_(0),
|
||||
snapshotted_time_(0) {
|
||||
}
|
||||
|
||||
void
|
||||
device_details_traits::unpack(device_details_disk const &disk, device_details &value)
|
||||
{
|
||||
|
@ -20,6 +20,8 @@ namespace thin_provisioning {
|
||||
uint64_t transaction_id_; /* when created */
|
||||
uint32_t creation_time_;
|
||||
uint32_t snapshotted_time_;
|
||||
|
||||
device_details();
|
||||
};
|
||||
|
||||
struct device_details_traits {
|
||||
|
@ -85,9 +85,6 @@ namespace {
|
||||
void parse_device(metadata::ptr md, emitter::ptr e, attributes const &attr) {
|
||||
uint32_t dev_id = get_attr<uint32_t>(attr, "dev_id");
|
||||
device_tree_detail::device_details details;
|
||||
details.transaction_id_ = 0;
|
||||
details.creation_time_ = 0;
|
||||
details.snapshotted_time_ = 0;
|
||||
|
||||
device_tree::ptr details_tree;
|
||||
boost::optional<uint32_t> details_root = get_opt_attr<uint32_t>(attr, "blocknr");
|
||||
|
@ -151,10 +151,43 @@ namespace {
|
||||
value_size_(rhs.value_size_), is_valid_(rhs.is_valid_)
|
||||
{
|
||||
}
|
||||
|
||||
uint64_t size() const {
|
||||
return (end_ > begin_) ? (end_ - begin_) : 0;
|
||||
}
|
||||
|
||||
// returns true if r is left or right-adjacent
|
||||
bool is_adjacent_to(block_range const &r) const {
|
||||
block_range const &lhs = begin_ < r.begin_ ? *this : r;
|
||||
block_range const &rhs = begin_ < r.begin_ ? r : *this;
|
||||
uint64_t common_end = std::min(end_, r.end_);
|
||||
|
||||
if (size() && r.size() &&
|
||||
rhs.begin_ == common_end &&
|
||||
((!blocknr_begin_ && !r.blocknr_begin_) ||
|
||||
(blocknr_begin_ && r.blocknr_begin_ &&
|
||||
*rhs.blocknr_begin_ > *lhs.blocknr_begin_ &&
|
||||
(*rhs.blocknr_begin_ - *lhs.blocknr_begin_ == rhs.begin_ - lhs.begin_))) &&
|
||||
type_ == r.type_ &&
|
||||
ref_count_ == r.ref_count_ &&
|
||||
value_size_ == r.value_size_ &&
|
||||
is_valid_ == r.is_valid_)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool concat(block_range const &r) {
|
||||
if (!is_adjacent_to(r))
|
||||
return false;
|
||||
begin_ = std::min(begin_, r.begin_);
|
||||
end_ = std::max(end_, r.end_);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
void output_block_range(block_range const &r, std::ostream &out) {
|
||||
if (r.end_ <= r.begin_)
|
||||
if (!r.size())
|
||||
return;
|
||||
|
||||
if (r.end_ - r.begin_ > 1) {
|
||||
@ -288,18 +321,8 @@ namespace {
|
||||
curr_range.ref_count_ = -1;
|
||||
}
|
||||
|
||||
// output the current block
|
||||
if (run_range.end_ == 0)
|
||||
run_range = curr_range;
|
||||
else if (((!curr_range.blocknr_begin_ && !run_range.blocknr_begin_) ||
|
||||
(curr_range.blocknr_begin_ && run_range.blocknr_begin_ &&
|
||||
*curr_range.blocknr_begin_ == *run_range.blocknr_begin_ + (run_range.end_ - run_range.begin_))) &&
|
||||
curr_range.type_ == run_range.type_ &&
|
||||
curr_range.ref_count_ == run_range.ref_count_ &&
|
||||
curr_range.value_size_ == run_range.value_size_ &&
|
||||
curr_range.is_valid_ == run_range.is_valid_) {
|
||||
++run_range.end_;
|
||||
} else {
|
||||
// store the current block
|
||||
if (!run_range.concat(curr_range)) {
|
||||
output_block_range(run_range, out);
|
||||
run_range = curr_range;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user