some work on cache_restore

This commit is contained in:
Joe Thornber 2013-09-12 12:33:32 +01:00
parent 6615b25e4b
commit dadb32d15f
7 changed files with 152 additions and 1 deletions

View File

@ -38,6 +38,7 @@ SOURCE=\
\
caching/superblock.cc \
caching/metadata.cc \
caching/restore_emitter.cc \
caching/xml_format.cc \
\
persistent-data/checksum.cc \
@ -236,6 +237,7 @@ CACHE_CHECK_SOURCE=\
persistent-data/transaction_manager.cc \
caching/superblock.cc \
caching/metadata.cc \
caching/restore_emitter.cc \
caching/xml_format.cc
CACHE_CHECK_OBJECTS=$(subst .cc,.o,$(CACHE_CHECK_SOURCE))
@ -248,7 +250,7 @@ CACHE_RESTORE_OBJECTS=$(subst .cc,.o,$(CACHE_RESTORE_SOURCE))
cache_check: $(CACHE_CHECK_OBJECTS) caching/cache_check.o
@echo " [LD] $@"
$(V) $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $+ $(LIBS)
$(V) $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $+ $(LIBS) $(LIBEXPAT)
cache_dump: $(CACHE_DUMP_OBJECTS) caching/cache_dump.o
@echo " [LD] $@"

View File

@ -1,6 +1,7 @@
#include "version.h"
#include "caching/metadata.h"
#include "caching/restore_emitter.h"
#include "caching/xml_format.h"
#include "persistent-data/file_utils.h"

31
caching/hint_array.h Normal file
View File

@ -0,0 +1,31 @@
#ifndef CACHE_HINT_ARRAY_H
#define CACHE_HINT_ARRAY_H
#include "persistent-data/data-structures/array.h"
#include <string>
//----------------------------------------------------------------
namespace caching {
namespace hint_array_detail {
template <uint32_t WIDTH>
struct hint_traits {
typedef unsigned char byte;
typedef byte disk_type[WIDTH];
typedef std::string value_type;
typedef no_op_ref_counter<value_type> ref_counter;
static void unpack(disk_type const &disk, value_type &value);
static void pack(value_type const &value, disk_type &disk);
};
// FIXME: data visitor stuff
}
// typedef persistent_data::array<mapping_array_detail::hint_traits> hint_array;
}
//----------------------------------------------------------------
#endif

32
caching/mapping_array.h Normal file
View File

@ -0,0 +1,32 @@
#ifndef CACHE_MAPPING_ARRAY_H
#define CACHE_MAPPING_ARRAY_H
#include "persistent-data/data-structures/array.h"
//----------------------------------------------------------------
namespace caching {
namespace mapping_array_detail {
struct mapping {
uint64_t oblock_;
uint32_t flags_;
};
struct mapping_traits {
typedef base::le64 disk_type;
typedef mapping value_type;
typedef no_op_ref_counter<value_type> ref_counter;
static void unpack(disk_type const &disk, value_type &value);
static void pack(value_type const &value, disk_type &disk);
};
// FIXME: damage visitor stuff
}
typedef persistent_data::array<mapping_array_detail::mapping_traits> mapping_array;
}
//----------------------------------------------------------------
#endif

View File

@ -8,6 +8,8 @@
#include "persistent-data/transaction_manager.h"
#include "caching/superblock.h"
#include "caching/hint_array.h"
#include "caching/mapping_array.h"
//----------------------------------------------------------------
@ -25,6 +27,13 @@ namespace caching {
metadata(block_manager<>::ptr bm, open_type ot);
metadata(block_manager<>::ptr bm, block_address metadata_snap);
typedef persistent_data::transaction_manager tm;
tm::ptr tm_;
superblock_detail::superblock sb_;
checked_space_map::ptr metadata_sm_;
mapping_array::ptr mappings_;
//hint_array::ptr hints_;
};
};

View File

@ -0,0 +1,61 @@
#include "caching/restore_emitter.h"
#include "caching/superblock.h"
using namespace std;
using namespace caching;
//----------------------------------------------------------------
namespace {
using namespace superblock_detail;
class restorer : public emitter {
public:
restorer(metadata::ptr md)
: md_(md) {
}
virtual void begin_superblock(std::string const &uuid,
pd::block_address block_size,
pd::block_address nr_cache_blocks,
std::string const &policy) {
}
virtual void end_superblock() {
}
virtual void begin_mappings() {
}
virtual void end_mappings() {
}
virtual void mapping(pd::block_address cblock,
pd::block_address oblock,
bool dirty) {
}
virtual void begin_hints() {
}
virtual void end_hints() {
}
virtual void hint(pd::block_address cblock,
std::string const &data) {
}
private:
metadata::ptr md_;
};
}
//----------------------------------------------------------------
emitter::ptr
caching::create_restore_emitter(metadata::ptr md)
{
return emitter::ptr(new restorer(md));
}
//----------------------------------------------------------------

15
caching/restore_emitter.h Normal file
View File

@ -0,0 +1,15 @@
#ifndef CACHE_RESTORE_EMITTER_H
#define CACHE_RESTORE_EMITTER_H
#include "emitter.h"
#include "metadata.h"
//----------------------------------------------------------------
namespace caching {
emitter::ptr create_restore_emitter(metadata::ptr md);
}
//----------------------------------------------------------------
#endif