diff --git a/Makefile.in b/Makefile.in index 699e00d..a72d18c 100644 --- a/Makefile.in +++ b/Makefile.in @@ -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] $@" diff --git a/caching/cache_restore.cc b/caching/cache_restore.cc index 8211f7e..62c4ea6 100644 --- a/caching/cache_restore.cc +++ b/caching/cache_restore.cc @@ -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" diff --git a/caching/hint_array.h b/caching/hint_array.h new file mode 100644 index 0000000..507f362 --- /dev/null +++ b/caching/hint_array.h @@ -0,0 +1,31 @@ +#ifndef CACHE_HINT_ARRAY_H +#define CACHE_HINT_ARRAY_H + +#include "persistent-data/data-structures/array.h" + +#include + +//---------------------------------------------------------------- + +namespace caching { + namespace hint_array_detail { + template + struct hint_traits { + typedef unsigned char byte; + typedef byte disk_type[WIDTH]; + typedef std::string value_type; + typedef no_op_ref_counter 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 hint_array; +} + +//---------------------------------------------------------------- + +#endif diff --git a/caching/mapping_array.h b/caching/mapping_array.h new file mode 100644 index 0000000..a938466 --- /dev/null +++ b/caching/mapping_array.h @@ -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 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; +} + +//---------------------------------------------------------------- + +#endif diff --git a/caching/metadata.h b/caching/metadata.h index 99f6c17..e94bea2 100644 --- a/caching/metadata.h +++ b/caching/metadata.h @@ -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_; }; }; diff --git a/caching/restore_emitter.cc b/caching/restore_emitter.cc new file mode 100644 index 0000000..499f13b --- /dev/null +++ b/caching/restore_emitter.cc @@ -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)); +} + +//---------------------------------------------------------------- diff --git a/caching/restore_emitter.h b/caching/restore_emitter.h new file mode 100644 index 0000000..658dc68 --- /dev/null +++ b/caching/restore_emitter.h @@ -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