2011-06-23 19:17:08 +05:30
|
|
|
#ifndef MULTISNAP_METADATA_H
|
|
|
|
#define MULTISNAP_METADATA_H
|
|
|
|
|
2011-10-28 16:55:06 +05:30
|
|
|
#include "metadata.h"
|
2011-06-23 19:17:08 +05:30
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <boost/shared_ptr.hpp>
|
|
|
|
|
|
|
|
//----------------------------------------------------------------
|
|
|
|
|
2011-07-22 20:39:56 +05:30
|
|
|
namespace thin_provisioning {
|
2011-10-28 16:51:58 +05:30
|
|
|
// 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;
|
2011-07-22 20:39:56 +05:30
|
|
|
class thin {
|
|
|
|
public:
|
|
|
|
typedef boost::shared_ptr<thin> ptr;
|
2011-08-24 15:15:39 +05:30
|
|
|
typedef boost::optional<block_time> maybe_address;
|
2011-07-22 20:39:56 +05:30
|
|
|
|
|
|
|
thin_dev_t get_dev_t() const;
|
|
|
|
maybe_address lookup(block_address thin_block);
|
|
|
|
void insert(block_address thin_block, block_address data_block);
|
|
|
|
void remove(block_address thin_block);
|
|
|
|
|
|
|
|
void set_snapshot_time(uint32_t time);
|
|
|
|
|
|
|
|
block_address get_mapped_blocks() const;
|
|
|
|
void set_mapped_blocks(block_address count);
|
|
|
|
|
|
|
|
private:
|
2011-10-28 16:51:58 +05:30
|
|
|
friend class thin_pool;
|
|
|
|
thin(thin_dev_t dev, thin_pool *pool); // FIXME: pass a reference rather than a ptr
|
2011-07-22 20:39:56 +05:30
|
|
|
|
|
|
|
thin_dev_t dev_;
|
2011-10-28 16:51:58 +05:30
|
|
|
thin_pool *pool_;
|
2011-07-22 20:39:56 +05:30
|
|
|
};
|
2011-06-27 15:15:30 +05:30
|
|
|
|
2011-10-28 16:51:58 +05:30
|
|
|
class thin_pool {
|
2011-06-23 19:17:08 +05:30
|
|
|
public:
|
2011-10-28 16:51:58 +05:30
|
|
|
typedef boost::shared_ptr<thin_pool> ptr;
|
2011-06-23 19:17:08 +05:30
|
|
|
|
2011-10-28 16:55:06 +05:30
|
|
|
thin_pool(metadata::ptr md);
|
2011-10-28 16:51:58 +05:30
|
|
|
~thin_pool();
|
2011-06-23 19:17:08 +05:30
|
|
|
|
2011-07-22 20:39:56 +05:30
|
|
|
void create_thin(thin_dev_t dev);
|
|
|
|
void create_snap(thin_dev_t dev, thin_dev_t origin);
|
|
|
|
void del(thin_dev_t);
|
2011-06-23 19:17:08 +05:30
|
|
|
|
|
|
|
void set_transaction_id(uint64_t id);
|
|
|
|
uint64_t get_transaction_id() const;
|
|
|
|
|
|
|
|
block_address get_held_root() const;
|
|
|
|
|
|
|
|
block_address alloc_data_block();
|
|
|
|
void free_data_block(block_address b);
|
|
|
|
|
|
|
|
// accessors
|
|
|
|
block_address get_nr_free_data_blocks() const;
|
|
|
|
sector_t get_data_block_size() const;
|
|
|
|
block_address get_data_dev_size() const;
|
|
|
|
|
2011-07-22 20:39:56 +05:30
|
|
|
thin::ptr open_thin(thin_dev_t);
|
2011-06-23 19:17:08 +05:30
|
|
|
|
|
|
|
private:
|
|
|
|
friend class thin;
|
2011-07-22 20:39:56 +05:30
|
|
|
bool device_exists(thin_dev_t dev) const;
|
2011-06-23 19:17:08 +05:30
|
|
|
|
2011-10-28 16:55:06 +05:30
|
|
|
metadata::ptr md_;
|
2011-06-23 19:17:08 +05:30
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
//----------------------------------------------------------------
|
|
|
|
|
|
|
|
#endif
|