2013-09-11 16:10:46 +05:30
|
|
|
#ifndef CACHE_METADATA_H
|
|
|
|
#define CACHE_METADATA_H
|
|
|
|
|
2013-11-19 15:53:35 +05:30
|
|
|
#include "base/endian_utils.h"
|
|
|
|
|
2013-09-11 16:10:46 +05:30
|
|
|
#include "persistent-data/block.h"
|
|
|
|
#include "persistent-data/data-structures/array.h"
|
2013-10-10 17:38:04 +05:30
|
|
|
#include "persistent-data/data-structures/bitset.h"
|
2013-09-11 16:10:46 +05:30
|
|
|
#include "persistent-data/space-maps/disk.h"
|
|
|
|
#include "persistent-data/transaction_manager.h"
|
|
|
|
|
|
|
|
#include "caching/superblock.h"
|
2013-09-12 17:03:32 +05:30
|
|
|
#include "caching/hint_array.h"
|
|
|
|
#include "caching/mapping_array.h"
|
2013-09-11 16:10:46 +05:30
|
|
|
|
|
|
|
//----------------------------------------------------------------
|
|
|
|
|
|
|
|
namespace caching {
|
|
|
|
class metadata {
|
|
|
|
public:
|
|
|
|
enum open_type {
|
2016-10-08 00:31:16 +05:30
|
|
|
CREATE
|
2013-09-11 16:10:46 +05:30
|
|
|
};
|
|
|
|
|
2020-04-30 19:00:01 +05:30
|
|
|
typedef block_manager::read_ref read_ref;
|
|
|
|
typedef block_manager::write_ref write_ref;
|
2020-04-30 19:32:43 +05:30
|
|
|
typedef std::shared_ptr<metadata> ptr;
|
2013-09-11 16:10:46 +05:30
|
|
|
|
2020-04-30 19:00:01 +05:30
|
|
|
metadata(block_manager::ptr bm, open_type ot, unsigned metadata_version = 2); // Create only
|
|
|
|
metadata(block_manager::ptr bm);
|
2013-09-18 17:30:26 +05:30
|
|
|
|
2013-10-29 18:16:23 +05:30
|
|
|
void commit(bool clean_shutdown = true);
|
2013-09-26 16:06:01 +05:30
|
|
|
void setup_hint_array(size_t width);
|
|
|
|
|
2013-09-12 17:03:32 +05:30
|
|
|
|
|
|
|
typedef persistent_data::transaction_manager tm;
|
|
|
|
tm::ptr tm_;
|
2013-10-07 19:51:45 +05:30
|
|
|
superblock sb_;
|
2013-09-12 17:03:32 +05:30
|
|
|
checked_space_map::ptr metadata_sm_;
|
|
|
|
mapping_array::ptr mappings_;
|
2013-09-24 16:30:09 +05:30
|
|
|
hint_array::ptr hints_;
|
2013-11-17 02:12:23 +05:30
|
|
|
persistent_data::bitset::ptr discard_bits_;
|
2016-09-30 20:51:20 +05:30
|
|
|
persistent_data::bitset::ptr dirty_bits_;
|
2013-09-19 18:15:56 +05:30
|
|
|
|
|
|
|
private:
|
|
|
|
void init_superblock();
|
|
|
|
|
2020-04-30 19:00:01 +05:30
|
|
|
void create_metadata(block_manager::ptr bm, unsigned metadata_version);
|
|
|
|
void open_metadata(block_manager::ptr bm);
|
2013-09-23 15:45:41 +05:30
|
|
|
|
|
|
|
void commit_space_map();
|
|
|
|
void commit_mappings();
|
2013-09-24 16:30:09 +05:30
|
|
|
void commit_hints();
|
2013-10-10 17:38:04 +05:30
|
|
|
void commit_discard_bits();
|
2013-10-29 18:16:23 +05:30
|
|
|
void commit_superblock(bool clean_shutdown);
|
2013-09-11 16:10:46 +05:30
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
//----------------------------------------------------------------
|
|
|
|
|
|
|
|
#endif
|