Rename metadata -> thin_pool/thin
This commit is contained in:
parent
9a4ebc8c25
commit
c2dfb0b462
2
Makefile
2
Makefile
@ -8,12 +8,12 @@ SOURCE=\
|
||||
error_set.cc \
|
||||
hex_dump.cc \
|
||||
human_readable_format.cc \
|
||||
metadata.cc \
|
||||
metadata_checker.cc \
|
||||
metadata_dumper.cc \
|
||||
metadata_ll.cc \
|
||||
metadata_disk_structures.cc \
|
||||
space_map_disk.cc \
|
||||
thin_pool.cc \
|
||||
transaction_manager.cc \
|
||||
xml_format.cc
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "metadata.h"
|
||||
#include "thin_pool.h"
|
||||
|
||||
#include "btree_checker.h"
|
||||
|
||||
@ -15,9 +15,9 @@ using namespace thin_provisioning;
|
||||
|
||||
//----------------------------------------------------------------
|
||||
|
||||
thin::thin(thin_dev_t dev, metadata *metadata)
|
||||
thin::thin(thin_dev_t dev, thin_pool *pool)
|
||||
: dev_(dev),
|
||||
metadata_(metadata)
|
||||
pool_(pool)
|
||||
{
|
||||
}
|
||||
|
||||
@ -31,7 +31,7 @@ thin::maybe_address
|
||||
thin::lookup(block_address thin_block)
|
||||
{
|
||||
uint64_t key[2] = {dev_, thin_block};
|
||||
return metadata_->md_->mappings_.lookup(key);
|
||||
return pool_->md_->mappings_.lookup(key);
|
||||
}
|
||||
|
||||
void
|
||||
@ -41,33 +41,33 @@ thin::insert(block_address thin_block, block_address data_block)
|
||||
block_time bt;
|
||||
bt.block_ = data_block;
|
||||
bt.time_ = 0; // FIXME: use current time.
|
||||
return metadata_->md_->mappings_.insert(key, bt);
|
||||
return pool_->md_->mappings_.insert(key, bt);
|
||||
}
|
||||
|
||||
void
|
||||
thin::remove(block_address thin_block)
|
||||
{
|
||||
uint64_t key[2] = {dev_, thin_block};
|
||||
metadata_->md_->mappings_.remove(key);
|
||||
pool_->md_->mappings_.remove(key);
|
||||
}
|
||||
|
||||
void
|
||||
thin::set_snapshot_time(uint32_t time)
|
||||
{
|
||||
uint64_t key[1] = { dev_ };
|
||||
optional<device_details> mdetail = metadata_->md_->details_.lookup(key);
|
||||
optional<device_details> mdetail = pool_->md_->details_.lookup(key);
|
||||
if (!mdetail)
|
||||
throw runtime_error("no such device");
|
||||
|
||||
mdetail->snapshotted_time_ = time;
|
||||
metadata_->md_->details_.insert(key, *mdetail);
|
||||
pool_->md_->details_.insert(key, *mdetail);
|
||||
}
|
||||
|
||||
block_address
|
||||
thin::get_mapped_blocks() const
|
||||
{
|
||||
uint64_t key[1] = { dev_ };
|
||||
optional<device_details> mdetail = metadata_->md_->details_.lookup(key);
|
||||
optional<device_details> mdetail = pool_->md_->details_.lookup(key);
|
||||
if (!mdetail)
|
||||
throw runtime_error("no such device");
|
||||
|
||||
@ -78,28 +78,28 @@ void
|
||||
thin::set_mapped_blocks(block_address count)
|
||||
{
|
||||
uint64_t key[1] = { dev_ };
|
||||
optional<device_details> mdetail = metadata_->md_->details_.lookup(key);
|
||||
optional<device_details> mdetail = pool_->md_->details_.lookup(key);
|
||||
if (!mdetail)
|
||||
throw runtime_error("no such device");
|
||||
|
||||
mdetail->mapped_blocks_ = count;
|
||||
metadata_->md_->details_.insert(key, *mdetail);
|
||||
pool_->md_->details_.insert(key, *mdetail);
|
||||
}
|
||||
|
||||
//--------------------------------
|
||||
|
||||
metadata::metadata(metadata_ll::ptr md)
|
||||
thin_pool::thin_pool(metadata_ll::ptr md)
|
||||
: md_(md)
|
||||
{
|
||||
}
|
||||
|
||||
metadata::~metadata()
|
||||
thin_pool::~thin_pool()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
metadata::create_thin(thin_dev_t dev)
|
||||
thin_pool::create_thin(thin_dev_t dev)
|
||||
{
|
||||
uint64_t key[1] = {dev};
|
||||
|
||||
@ -112,7 +112,7 @@ metadata::create_thin(thin_dev_t dev)
|
||||
}
|
||||
|
||||
void
|
||||
metadata::create_snap(thin_dev_t dev, thin_dev_t origin)
|
||||
thin_pool::create_snap(thin_dev_t dev, thin_dev_t origin)
|
||||
{
|
||||
uint64_t snap_key[1] = {dev};
|
||||
uint64_t origin_key[1] = {origin};
|
||||
@ -138,62 +138,62 @@ metadata::create_snap(thin_dev_t dev, thin_dev_t origin)
|
||||
}
|
||||
|
||||
void
|
||||
metadata::del(thin_dev_t dev)
|
||||
thin_pool::del(thin_dev_t dev)
|
||||
{
|
||||
uint64_t key[1] = {dev};
|
||||
md_->mappings_top_level_.remove(key);
|
||||
}
|
||||
|
||||
void
|
||||
metadata::set_transaction_id(uint64_t id)
|
||||
thin_pool::set_transaction_id(uint64_t id)
|
||||
{
|
||||
md_->sb_.trans_id_ = id;
|
||||
}
|
||||
|
||||
uint64_t
|
||||
metadata::get_transaction_id() const
|
||||
thin_pool::get_transaction_id() const
|
||||
{
|
||||
return md_->sb_.trans_id_;
|
||||
}
|
||||
|
||||
block_address
|
||||
metadata::get_held_root() const
|
||||
thin_pool::get_held_root() const
|
||||
{
|
||||
return md_->sb_.held_root_;
|
||||
}
|
||||
|
||||
block_address
|
||||
metadata::alloc_data_block()
|
||||
thin_pool::alloc_data_block()
|
||||
{
|
||||
return md_->data_sm_->new_block();
|
||||
}
|
||||
|
||||
void
|
||||
metadata::free_data_block(block_address b)
|
||||
thin_pool::free_data_block(block_address b)
|
||||
{
|
||||
md_->data_sm_->dec(b);
|
||||
}
|
||||
|
||||
block_address
|
||||
metadata::get_nr_free_data_blocks() const
|
||||
thin_pool::get_nr_free_data_blocks() const
|
||||
{
|
||||
return md_->data_sm_->get_nr_free();
|
||||
}
|
||||
|
||||
sector_t
|
||||
metadata::get_data_block_size() const
|
||||
thin_pool::get_data_block_size() const
|
||||
{
|
||||
return md_->sb_.data_block_size_;
|
||||
}
|
||||
|
||||
block_address
|
||||
metadata::get_data_dev_size() const
|
||||
thin_pool::get_data_dev_size() const
|
||||
{
|
||||
return md_->data_sm_->get_nr_blocks();
|
||||
}
|
||||
|
||||
thin::ptr
|
||||
metadata::open_thin(thin_dev_t dev)
|
||||
thin_pool::open_thin(thin_dev_t dev)
|
||||
{
|
||||
uint64_t key[1] = {dev};
|
||||
optional<device_details> mdetails = md_->details_.lookup(key);
|
||||
@ -206,7 +206,7 @@ metadata::open_thin(thin_dev_t dev)
|
||||
}
|
||||
|
||||
bool
|
||||
metadata::device_exists(thin_dev_t dev) const
|
||||
thin_pool::device_exists(thin_dev_t dev) const
|
||||
{
|
||||
uint64_t key[1] = {dev};
|
||||
return md_->details_.lookup(key);
|
@ -9,7 +9,11 @@
|
||||
//----------------------------------------------------------------
|
||||
|
||||
namespace thin_provisioning {
|
||||
class metadata;
|
||||
// This interface is very like that in the kernel. It'll allow us
|
||||
// to write simulators to try out different space maps etc. Not
|
||||
// currently used by the tools.
|
||||
|
||||
class thin_pool;
|
||||
class thin {
|
||||
public:
|
||||
typedef boost::shared_ptr<thin> ptr;
|
||||
@ -26,19 +30,19 @@ namespace thin_provisioning {
|
||||
void set_mapped_blocks(block_address count);
|
||||
|
||||
private:
|
||||
friend class metadata;
|
||||
thin(thin_dev_t dev, metadata *metadata);
|
||||
friend class thin_pool;
|
||||
thin(thin_dev_t dev, thin_pool *pool); // FIXME: pass a reference rather than a ptr
|
||||
|
||||
thin_dev_t dev_;
|
||||
metadata *metadata_;
|
||||
thin_pool *pool_;
|
||||
};
|
||||
|
||||
class metadata {
|
||||
class thin_pool {
|
||||
public:
|
||||
typedef boost::shared_ptr<metadata> ptr;
|
||||
typedef boost::shared_ptr<thin_pool> ptr;
|
||||
|
||||
metadata(metadata_ll::ptr md);
|
||||
~metadata();
|
||||
thin_pool(metadata_ll::ptr md);
|
||||
~thin_pool();
|
||||
|
||||
void create_thin(thin_dev_t dev);
|
||||
void create_snap(thin_dev_t dev, thin_dev_t origin);
|
||||
@ -61,7 +65,6 @@ namespace thin_provisioning {
|
||||
|
||||
private:
|
||||
friend class thin;
|
||||
|
||||
bool device_exists(thin_dev_t dev) const;
|
||||
|
||||
metadata_ll::ptr md_;
|
Loading…
Reference in New Issue
Block a user