we need to dump the time field of the mappings also

This commit is contained in:
Joe Thornber 2011-10-28 13:53:15 +01:00
parent b98fc8abb6
commit 25d9cfffa5
5 changed files with 33 additions and 19 deletions

View File

@ -43,8 +43,8 @@ namespace thin_provisioning {
virtual void end_named_mapping() = 0;
virtual void identifier(std::string const &name) = 0;
virtual void range_map(uint64_t origin_begin, uint64_t data_begin, uint64_t len) = 0;
virtual void single_map(uint64_t origin_block, uint64_t data_block) = 0;
virtual void range_map(uint64_t origin_begin, uint64_t data_begin, uint32_t time, uint64_t len) = 0;
virtual void single_map(uint64_t origin_block, uint64_t data_block, uint32_t time) = 0;
};
}

View File

@ -59,17 +59,20 @@ namespace {
out_ << "identifier: " << name << endl;
}
void range_map(uint64_t origin_begin, uint64_t data_begin, uint64_t len) {
void range_map(uint64_t origin_begin, uint64_t data_begin, uint32_t time, uint64_t len) {
out_ << " (" << origin_begin
<< ".." << origin_begin + len - 1
<< ") -> (" << data_begin
<< ".." << data_begin + len - 1
<< ")" << endl;
<< "), "
<< time
<< endl;
}
void single_map(uint64_t origin_block, uint64_t data_block) {
void single_map(uint64_t origin_block, uint64_t data_block, uint32_t time) {
out_ << " " << origin_block
<< " -> " << data_block
<< ", " << time
<< endl;
}

View File

@ -32,7 +32,8 @@ namespace {
bool visit_leaf(unsigned level, bool sub_root, boost::optional<uint64_t> maybe_key,
btree_detail::node_ref<block_traits> const &n) {
for (unsigned i = 0; i < n.get_nr_entries(); i++) {
add_mapping(n.key_at(i), n.value_at(i).block_);
block_time bt = n.value_at(i);
add_mapping(n.key_at(i), bt.block_, bt.time_);
}
return true;
@ -44,9 +45,10 @@ namespace {
}
private:
void start_mapping(uint64_t origin_block, uint64_t dest_block) {
void start_mapping(uint64_t origin_block, uint64_t dest_block, uint32_t time) {
origin_start_ = origin_block;
dest_start_ = dest_block;
time_ = time;
len_ = 1;
in_range_ = true;
}
@ -54,25 +56,26 @@ namespace {
void end_mapping() {
if (in_range_) {
if (len_ == 1)
e_->single_map(origin_start_, dest_start_);
e_->single_map(origin_start_, dest_start_, time_);
else
e_->range_map(origin_start_, dest_start_, len_);
e_->range_map(origin_start_, dest_start_, time_, len_);
in_range_ = false;
}
}
void add_mapping(uint64_t origin_block, uint64_t dest_block) {
void add_mapping(uint64_t origin_block, uint64_t dest_block, uint32_t time) {
if (!in_range_)
start_mapping(origin_block, dest_block);
start_mapping(origin_block, dest_block, time);
else if (origin_block == origin_start_ + len_ &&
dest_block == dest_start_ + len_)
dest_block == dest_start_ + len_ &&
time == time_)
len_++;
else {
end_mapping();
start_mapping(origin_block, dest_block);
start_mapping(origin_block, dest_block, time);
}
}
@ -83,6 +86,7 @@ namespace {
bool in_range_;
uint64_t origin_start_, dest_start_, len_;
uint32_t time_;
};

View File

@ -109,6 +109,8 @@ thin_pool::create_thin(thin_dev_t dev)
single_mapping_tree::ptr new_tree(new single_mapping_tree(md_->tm_, block_time_ref_counter(md_->data_sm_)));
md_->mappings_top_level_.insert(key, new_tree->get_root());
md_->mappings_.set_root(md_->mappings_top_level_.get_root()); // FIXME: ugly
// FIXME: doesn't set up the device details
}
void

View File

@ -83,20 +83,23 @@ namespace {
out_ << "<identifier name=\"" << name << "\"/>" << endl;
}
void range_map(uint64_t origin_begin, uint64_t data_begin, uint64_t len) {
void range_map(uint64_t origin_begin, uint64_t data_begin, uint32_t time, uint64_t len) {
indent();
out_ << "<range_mapping origin_begin=\"" << origin_begin << "\""
<< " data_begin=\"" << data_begin << "\""
<< " length=\"" << len << "\"/>"
<< endl;
<< " length=\"" << len << "\""
<< " time=\"" << time << "\""
<< "/>" << endl;
}
void single_map(uint64_t origin_block, uint64_t data_block) {
void single_map(uint64_t origin_block, uint64_t data_block, uint32_t time) {
indent();
out_ << "<single_mapping origin_block=\"" << origin_block << "\""
<< " data_block=\"" << data_block << "\"/>" << endl;
<< " data_block=\"" << data_block << "\""
<< " time=\"" << time << "\""
<< "/>" << endl;
}
private:
@ -169,12 +172,14 @@ namespace {
void parse_range_mapping(emitter *e, attributes const &attr) {
e->range_map(get_attr<uint64_t>(attr, "origin_begin"),
get_attr<uint64_t>(attr, "data_begin"),
get_attr<uint32_t>(attr, "time"),
get_attr<uint64_t>(attr, "length"));
}
void parse_single_mapping(emitter *e, attributes const &attr) {
e->single_map(get_attr<uint64_t>(attr, "origin_block"),
get_attr<uint64_t>(attr, "data_block"));
get_attr<uint64_t>(attr, "data_block"),
get_attr<uint32_t>(attr, "time"));
}
void start_tag(void *data, char const *el, char const **attr) {