[thin_pool] Complete device creation

- Set up the device details
- Cache device details of opened devices
- Update changed devices at once while committing the pool
This commit is contained in:
Ming-Hung Tsai
2020-05-31 20:14:42 +08:00
parent 77adb08c3f
commit 7f7ba950ef
2 changed files with 114 additions and 31 deletions

View File

@@ -49,9 +49,14 @@ namespace thin_provisioning {
private:
friend class thin_pool;
thin(thin_dev_t dev, thin_pool &pool);
thin(thin_dev_t dev, thin_pool &pool,
device_tree_detail::device_details const &details);
thin_dev_t dev_;
thin_pool &pool_;
device_tree_detail::device_details details_;
uint32_t open_count_;
bool changed_;
};
class thin_pool {
@@ -67,6 +72,7 @@ namespace thin_provisioning {
void create_thin(thin_dev_t dev);
void create_snap(thin_dev_t dev, thin_dev_t origin);
void del(thin_dev_t);
void commit();
void set_transaction_id(uint64_t id);
uint64_t get_transaction_id() const;
@@ -80,14 +86,22 @@ namespace thin_provisioning {
block_address get_nr_free_data_blocks() const;
sector_t get_data_block_size() const;
block_address get_data_dev_size() const;
uint32_t get_time() const;
thin::ptr open_thin(thin_dev_t);
private:
friend class thin;
typedef std::map<thin_dev_t, thin::ptr> device_map;
bool device_exists(thin_dev_t dev) const;
thin::ptr create_device(thin_dev_t dev);
thin::ptr open_device(thin_dev_t dev);
void close_device(thin::ptr device);
void write_changed_details();
metadata::ptr md_;
device_map thin_devices_;
};
};