[cache_restore/dump] hint_width work.
dump/restore cycle works again.
This commit is contained in:
parent
bd1a189298
commit
bb898eeaad
@ -21,9 +21,9 @@ GEM
|
||||
multi_json (~> 1.3)
|
||||
multi_json (1.8.0)
|
||||
multi_test (0.0.2)
|
||||
rspec-expectations (2.14.2)
|
||||
rspec-expectations (2.14.3)
|
||||
diff-lcs (>= 1.1.3, < 2.0)
|
||||
thinp_xml (0.0.10)
|
||||
thinp_xml (0.0.12)
|
||||
ejt_command_line (= 0.0.2)
|
||||
|
||||
PLATFORMS
|
||||
|
@ -36,7 +36,9 @@ namespace {
|
||||
emitter::ptr e = create_xml_emitter(out);
|
||||
|
||||
superblock const &sb = md->sb_;
|
||||
e->begin_superblock(to_string(sb.uuid), sb.data_block_size, sb.cache_blocks, to_string(sb.policy_name));
|
||||
e->begin_superblock(to_string(sb.uuid), sb.data_block_size,
|
||||
sb.cache_blocks, to_string(sb.policy_name),
|
||||
sb.policy_hint_size);
|
||||
|
||||
e->begin_mappings();
|
||||
|
||||
|
@ -20,7 +20,8 @@ namespace caching {
|
||||
virtual void begin_superblock(std::string const &uuid,
|
||||
pd::block_address block_size,
|
||||
pd::block_address nr_cache_blocks,
|
||||
std::string const &policy) = 0;
|
||||
std::string const &policy,
|
||||
size_t hint_width) = 0;
|
||||
|
||||
virtual void end_superblock() = 0;
|
||||
|
||||
|
@ -36,6 +36,8 @@ namespace {
|
||||
|
||||
all_widths
|
||||
#undef xx
|
||||
default:
|
||||
throw runtime_error("invalid hint width");
|
||||
}
|
||||
|
||||
// never get here
|
||||
@ -59,6 +61,8 @@ namespace {
|
||||
#define xx(n) case n: return mk_array<n>(tm, root, nr_entries)
|
||||
all_widths
|
||||
#undef xx
|
||||
default:
|
||||
throw runtime_error("invalid hint width");
|
||||
}
|
||||
|
||||
// never get here
|
||||
|
@ -19,12 +19,12 @@ namespace caching {
|
||||
// FIXME: slow copying for now
|
||||
static void unpack(disk_type const &disk, value_type &value) {
|
||||
for (unsigned byte = 0; byte < WIDTH; byte++)
|
||||
value[byte] = disk[byte];
|
||||
value.at(byte) = disk[byte];
|
||||
}
|
||||
|
||||
static void pack(value_type const &value, disk_type &disk) {
|
||||
for (unsigned byte = 0; byte < WIDTH; byte++)
|
||||
disk[byte] = value[byte];
|
||||
disk[byte] = value.at(byte);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -57,6 +57,14 @@ metadata::commit()
|
||||
commit_superblock();
|
||||
}
|
||||
|
||||
void
|
||||
metadata::setup_hint_array(size_t width)
|
||||
{
|
||||
if (width > 0)
|
||||
hints_ = hint_array::ptr(
|
||||
new hint_array(tm_, width));
|
||||
}
|
||||
|
||||
void
|
||||
metadata::init_superblock()
|
||||
{
|
||||
@ -85,7 +93,9 @@ metadata::create_metadata(block_manager<>::ptr bm)
|
||||
tm_->set_sm(metadata_sm_);
|
||||
|
||||
mappings_ = mapping_array::ptr(new mapping_array(tm_, mapping_array::ref_counter()));
|
||||
// hints_ = hint_array::ptr(new hint_array(tm_));
|
||||
|
||||
// We can't instantiate the hint array yet, since we don't know the
|
||||
// hint width.
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -28,6 +28,8 @@ namespace caching {
|
||||
metadata(block_manager<>::ptr bm, open_type ot);
|
||||
|
||||
void commit();
|
||||
void setup_hint_array(size_t width);
|
||||
|
||||
|
||||
typedef persistent_data::transaction_manager tm;
|
||||
tm::ptr tm_;
|
||||
|
@ -23,7 +23,8 @@ namespace {
|
||||
virtual void begin_superblock(std::string const &uuid,
|
||||
pd::block_address block_size,
|
||||
pd::block_address nr_cache_blocks,
|
||||
std::string const &policy) {
|
||||
std::string const &policy,
|
||||
size_t hint_width) {
|
||||
|
||||
superblock &sb = md_->sb_;
|
||||
|
||||
@ -31,11 +32,13 @@ namespace {
|
||||
memset(sb.uuid, 0, sizeof(sb.uuid));
|
||||
sb.magic = caching::superblock_detail::SUPERBLOCK_MAGIC;
|
||||
sb.version = 0; // FIXME: fix
|
||||
// strncpy(sb.policy_name, policy.c_str(), sizeof(sb.policy_name));
|
||||
strncpy((char *) sb.policy_name, policy.c_str(), sizeof(sb.policy_name));
|
||||
memset(sb.policy_version, 0, sizeof(sb.policy_version));
|
||||
sb.policy_hint_size = 0; // FIXME: fix
|
||||
sb.policy_hint_size = hint_width;
|
||||
md_->setup_hint_array(hint_width);
|
||||
|
||||
memset(sb.metadata_space_map_root, 0, sizeof(sb.metadata_space_map_root));
|
||||
memset(sb.metadata_space_map_root, 0,
|
||||
sizeof(sb.metadata_space_map_root));
|
||||
sb.mapping_root = 0;
|
||||
sb.hint_root = 0;
|
||||
|
||||
@ -60,6 +63,9 @@ namespace {
|
||||
unmapped_value.oblock_ = 0;
|
||||
unmapped_value.flags_ = 0;
|
||||
md_->mappings_->grow(nr_cache_blocks, unmapped_value);
|
||||
|
||||
vector<unsigned char> hint_value(hint_width, '\0');
|
||||
md_->hints_->grow(nr_cache_blocks, hint_value);
|
||||
}
|
||||
|
||||
virtual void end_superblock() {
|
||||
|
@ -22,6 +22,7 @@ superblock_traits::unpack(superblock_disk const &disk, superblock &core)
|
||||
core.policy_version[i] = to_cpu<uint32_t>(disk.policy_version[i]);
|
||||
|
||||
core.policy_hint_size = to_cpu<uint32_t>(disk.policy_hint_size);
|
||||
cerr << "unpacking: hint width = " << core.policy_hint_size << endl;
|
||||
|
||||
::memcpy(core.metadata_space_map_root,
|
||||
disk.metadata_space_map_root,
|
||||
|
@ -33,12 +33,14 @@ namespace {
|
||||
void begin_superblock(std::string const &uuid,
|
||||
block_address block_size,
|
||||
block_address nr_cache_blocks,
|
||||
std::string const &policy) {
|
||||
std::string const &policy,
|
||||
size_t hint_width) {
|
||||
indent();
|
||||
out_ << "<superblock uuid=\"" << uuid << "\""
|
||||
<< " block_size=\"" << block_size << "\""
|
||||
<< " nr_cache_blocks=\"" << nr_cache_blocks << "\""
|
||||
<< " policy=\"" << policy << "\">" << endl;
|
||||
<< " policy=\"" << policy << "\""
|
||||
<< " hint_width=\"" << hint_width << "\">" << endl;
|
||||
inc();
|
||||
}
|
||||
|
||||
@ -164,7 +166,8 @@ namespace {
|
||||
e->begin_superblock(get_attr<string>(attr, "uuid"),
|
||||
get_attr<uint64_t>(attr, "block_size"),
|
||||
get_attr<uint64_t>(attr, "nr_cache_blocks"),
|
||||
get_attr<string>(attr, "policy"));
|
||||
get_attr<string>(attr, "policy"),
|
||||
get_attr<size_t>(attr, "hint_width"));
|
||||
}
|
||||
|
||||
bool to_bool(string const &str) {
|
||||
|
Loading…
Reference in New Issue
Block a user