[thin_pool] Replace the member pointer by references
This commit is contained in:
parent
0b058a2850
commit
77adb08c3f
@ -31,7 +31,7 @@ using namespace thin_provisioning;
|
|||||||
|
|
||||||
//----------------------------------------------------------------
|
//----------------------------------------------------------------
|
||||||
|
|
||||||
thin::thin(thin_dev_t dev, thin_pool *pool)
|
thin::thin(thin_dev_t dev, thin_pool &pool)
|
||||||
: dev_(dev),
|
: dev_(dev),
|
||||||
pool_(pool)
|
pool_(pool)
|
||||||
{
|
{
|
||||||
@ -47,7 +47,7 @@ thin::maybe_address
|
|||||||
thin::lookup(block_address thin_block)
|
thin::lookup(block_address thin_block)
|
||||||
{
|
{
|
||||||
uint64_t key[2] = {dev_, thin_block};
|
uint64_t key[2] = {dev_, thin_block};
|
||||||
return pool_->md_->mappings_->lookup(key);
|
return pool_.md_->mappings_->lookup(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
@ -57,33 +57,33 @@ thin::insert(block_address thin_block, block_address data_block)
|
|||||||
mapping_tree_detail::block_time bt;
|
mapping_tree_detail::block_time bt;
|
||||||
bt.block_ = data_block;
|
bt.block_ = data_block;
|
||||||
bt.time_ = 0; // FIXME: use current time.
|
bt.time_ = 0; // FIXME: use current time.
|
||||||
return pool_->md_->mappings_->insert(key, bt);
|
return pool_.md_->mappings_->insert(key, bt);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
thin::remove(block_address thin_block)
|
thin::remove(block_address thin_block)
|
||||||
{
|
{
|
||||||
uint64_t key[2] = {dev_, thin_block};
|
uint64_t key[2] = {dev_, thin_block};
|
||||||
pool_->md_->mappings_->remove(key);
|
pool_.md_->mappings_->remove(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
thin::set_snapshot_time(uint32_t time)
|
thin::set_snapshot_time(uint32_t time)
|
||||||
{
|
{
|
||||||
uint64_t key[1] = { dev_ };
|
uint64_t key[1] = { dev_ };
|
||||||
boost::optional<device_tree_detail::device_details> mdetail = pool_->md_->details_->lookup(key);
|
boost::optional<device_tree_detail::device_details> mdetail = pool_.md_->details_->lookup(key);
|
||||||
if (!mdetail)
|
if (!mdetail)
|
||||||
throw runtime_error("no such device");
|
throw runtime_error("no such device");
|
||||||
|
|
||||||
mdetail->snapshotted_time_ = time;
|
mdetail->snapshotted_time_ = time;
|
||||||
pool_->md_->details_->insert(key, *mdetail);
|
pool_.md_->details_->insert(key, *mdetail);
|
||||||
}
|
}
|
||||||
|
|
||||||
block_address
|
block_address
|
||||||
thin::get_mapped_blocks() const
|
thin::get_mapped_blocks() const
|
||||||
{
|
{
|
||||||
uint64_t key[1] = { dev_ };
|
uint64_t key[1] = { dev_ };
|
||||||
boost::optional<device_tree_detail::device_details> mdetail = pool_->md_->details_->lookup(key);
|
boost::optional<device_tree_detail::device_details> mdetail = pool_.md_->details_->lookup(key);
|
||||||
if (!mdetail)
|
if (!mdetail)
|
||||||
throw runtime_error("no such device");
|
throw runtime_error("no such device");
|
||||||
|
|
||||||
@ -94,12 +94,12 @@ void
|
|||||||
thin::set_mapped_blocks(block_address count)
|
thin::set_mapped_blocks(block_address count)
|
||||||
{
|
{
|
||||||
uint64_t key[1] = { dev_ };
|
uint64_t key[1] = { dev_ };
|
||||||
boost::optional<device_tree_detail::device_details> mdetail = pool_->md_->details_->lookup(key);
|
boost::optional<device_tree_detail::device_details> mdetail = pool_.md_->details_->lookup(key);
|
||||||
if (!mdetail)
|
if (!mdetail)
|
||||||
throw runtime_error("no such device");
|
throw runtime_error("no such device");
|
||||||
|
|
||||||
mdetail->mapped_blocks_ = count;
|
mdetail->mapped_blocks_ = count;
|
||||||
pool_->md_->details_->insert(key, *mdetail);
|
pool_.md_->details_->insert(key, *mdetail);
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------
|
//--------------------------------
|
||||||
@ -234,7 +234,7 @@ thin_pool::open_thin(thin_dev_t dev)
|
|||||||
if (!mdetails)
|
if (!mdetails)
|
||||||
throw runtime_error("no such device");
|
throw runtime_error("no such device");
|
||||||
|
|
||||||
thin *ptr = new thin(dev, this);
|
thin *ptr = new thin(dev, *this);
|
||||||
thin::ptr r(ptr);
|
thin::ptr r(ptr);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
@ -48,10 +48,10 @@ namespace thin_provisioning {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
friend class thin_pool;
|
friend class thin_pool;
|
||||||
thin(thin_dev_t dev, thin_pool *pool); // FIXME: pass a reference rather than a ptr
|
thin(thin_dev_t dev, thin_pool &pool);
|
||||||
|
|
||||||
thin_dev_t dev_;
|
thin_dev_t dev_;
|
||||||
thin_pool *pool_;
|
thin_pool &pool_;
|
||||||
};
|
};
|
||||||
|
|
||||||
class thin_pool {
|
class thin_pool {
|
||||||
|
Loading…
Reference in New Issue
Block a user