[thin_pool] Determine shared blocks while looking up mappings

This commit is contained in:
Ming-Hung Tsai 2020-06-02 01:03:01 +08:00
parent a842b4ecfd
commit 383ae78871
2 changed files with 14 additions and 2 deletions

View File

@ -60,7 +60,14 @@ thin::maybe_address
thin::lookup(block_address thin_block)
{
uint64_t key[2] = {dev_, thin_block};
return pool_.md_->mappings_->lookup(key);
mapping_tree::maybe_value m = pool_.md_->mappings_->lookup(key);
if (!m)
return thin::maybe_address();
lookup_result r;
r.block_ = m->block_;
r.shared_ = m->time_ < details_.snapshotted_time_;
return r;
}
bool

View File

@ -33,8 +33,13 @@ namespace thin_provisioning {
class thin_pool;
class thin {
public:
struct lookup_result {
block_address block_;
bool shared_;
};
typedef std::shared_ptr<thin> ptr;
typedef boost::optional<mapping_tree_detail::block_time> maybe_address;
typedef boost::optional<lookup_result> maybe_address;
thin_dev_t get_dev_t() const;
maybe_address lookup(block_address thin_block);