diff --git a/emitter.h b/emitter.h index 8505995..ff136a6 100644 --- a/emitter.h +++ b/emitter.h @@ -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; }; } diff --git a/human_readable_format.cc b/human_readable_format.cc index 536ccc5..6fea41f 100644 --- a/human_readable_format.cc +++ b/human_readable_format.cc @@ -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; } diff --git a/metadata_dumper.cc b/metadata_dumper.cc index b60841b..851310d 100644 --- a/metadata_dumper.cc +++ b/metadata_dumper.cc @@ -32,7 +32,8 @@ namespace { bool visit_leaf(unsigned level, bool sub_root, boost::optional maybe_key, btree_detail::node_ref 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_; }; diff --git a/thin_pool.cc b/thin_pool.cc index c1fdc8d..0e5c9ce 100644 --- a/thin_pool.cc +++ b/thin_pool.cc @@ -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 diff --git a/xml_format.cc b/xml_format.cc index 0ef23ee..da938c2 100644 --- a/xml_format.cc +++ b/xml_format.cc @@ -83,20 +83,23 @@ namespace { out_ << "" << 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_ << "" - << 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_ << "" << 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(attr, "origin_begin"), get_attr(attr, "data_begin"), + get_attr(attr, "time"), get_attr(attr, "length")); } void parse_single_mapping(emitter *e, attributes const &attr) { e->single_map(get_attr(attr, "origin_block"), - get_attr(attr, "data_block")); + get_attr(attr, "data_block"), + get_attr(attr, "time")); } void start_tag(void *data, char const *el, char const **attr) {