115 lines
4.4 KiB
Diff
115 lines
4.4 KiB
Diff
|
diff --git a/thin-provisioning/metadata.cc b/thin-provisioning/metadata.cc
|
||
|
index c841614..771325a 100644
|
||
|
--- a/thin-provisioning/metadata.cc
|
||
|
+++ b/thin-provisioning/metadata.cc
|
||
|
@@ -57,15 +57,6 @@ namespace {
|
||
|
return tm;
|
||
|
}
|
||
|
|
||
|
- superblock
|
||
|
- read_superblock(block_manager<>::ptr bm, block_address location = SUPERBLOCK_LOCATION) {
|
||
|
- superblock sb;
|
||
|
- block_manager<>::read_ref r = bm->read_lock(location, superblock_validator());
|
||
|
- superblock_disk const *sbd = reinterpret_cast<superblock_disk const *>(&r.data());
|
||
|
- superblock_traits::unpack(*sbd, sb);
|
||
|
- return sb;
|
||
|
- }
|
||
|
-
|
||
|
void
|
||
|
copy_space_maps(space_map::ptr lhs, space_map::ptr rhs) {
|
||
|
for (block_address b = 0; b < rhs->get_nr_blocks(); b++) {
|
||
|
@@ -149,10 +140,10 @@ metadata::metadata(std::string const &dev_path, open_type ot,
|
||
|
}
|
||
|
}
|
||
|
|
||
|
-metadata::metadata(std::string const &dev_path)
|
||
|
+metadata::metadata(std::string const &dev_path, block_address metadata_snap)
|
||
|
{
|
||
|
tm_ = open_tm(open_bm(dev_path, false));
|
||
|
- sb_ = read_superblock(tm_->get_bm());
|
||
|
+ sb_ = read_superblock(tm_->get_bm(), metadata_snap);
|
||
|
|
||
|
// We don't open the metadata sm for a held root
|
||
|
//metadata_sm_ = open_metadata_sm(tm_, &sb_.metadata_space_map_root_);
|
||
|
diff --git a/thin-provisioning/metadata.h b/thin-provisioning/metadata.h
|
||
|
index 250c216..9749acb 100644
|
||
|
--- a/thin-provisioning/metadata.h
|
||
|
+++ b/thin-provisioning/metadata.h
|
||
|
@@ -62,10 +62,11 @@ namespace thin_provisioning {
|
||
|
// Deprecated: it would be better if we passed in an already
|
||
|
// constructed block_manager.
|
||
|
metadata(std::string const &dev_path, open_type ot,
|
||
|
- sector_t data_block_size = 128,
|
||
|
+ sector_t data_block_size = 128, // Only used if CREATE
|
||
|
block_address nr_data_blocks = 0); // Only used if CREATE
|
||
|
|
||
|
- metadata(std::string const &dev_path);
|
||
|
+ metadata(std::string const &dev_path,
|
||
|
+ block_address metadata_snap = 0);
|
||
|
|
||
|
// ... use these instead ...
|
||
|
metadata(block_manager<>::ptr bm, open_type ot,
|
||
|
diff --git a/thin-provisioning/superblock.cc b/thin-provisioning/superblock.cc
|
||
|
index c23fbc1..bf9544b 100644
|
||
|
--- a/thin-provisioning/superblock.cc
|
||
|
+++ b/thin-provisioning/superblock.cc
|
||
|
@@ -126,17 +126,22 @@ namespace thin_provisioning {
|
||
|
}
|
||
|
}
|
||
|
|
||
|
- superblock_detail::superblock read_superblock(block_manager<>::ptr bm)
|
||
|
+ superblock_detail::superblock read_superblock(block_manager<>::ptr bm, block_address location)
|
||
|
{
|
||
|
using namespace superblock_detail;
|
||
|
|
||
|
superblock sb;
|
||
|
- auto r = bm->read_lock(SUPERBLOCK_LOCATION, superblock_validator());
|
||
|
+ auto r = bm->read_lock(location, superblock_validator());
|
||
|
superblock_disk const *sbd = reinterpret_cast<superblock_disk const *>(&r.data());
|
||
|
superblock_traits::unpack(*sbd, sb);
|
||
|
return sb;
|
||
|
}
|
||
|
|
||
|
+ superblock_detail::superblock read_superblock(block_manager<>::ptr bm)
|
||
|
+ {
|
||
|
+ return read_superblock(bm, SUPERBLOCK_LOCATION);
|
||
|
+ }
|
||
|
+
|
||
|
void
|
||
|
check_superblock(block_manager<>::ptr bm,
|
||
|
superblock_detail::damage_visitor &visitor) {
|
||
|
diff --git a/thin-provisioning/superblock.h b/thin-provisioning/superblock.h
|
||
|
index e993497..a9377b0 100644
|
||
|
--- a/thin-provisioning/superblock.h
|
||
|
+++ b/thin-provisioning/superblock.h
|
||
|
@@ -123,6 +123,7 @@ namespace thin_provisioning {
|
||
|
persistent_data::block_manager<>::validator::ptr superblock_validator();
|
||
|
|
||
|
superblock_detail::superblock read_superblock(persistent_data::block_manager<>::ptr bm);
|
||
|
+ superblock_detail::superblock read_superblock(persistent_data::block_manager<>::ptr bm, persistent_data::block_address location);
|
||
|
void check_superblock(persistent_data::block_manager<>::ptr bm,
|
||
|
superblock_detail::damage_visitor &visitor);
|
||
|
}
|
||
|
diff --git a/thin-provisioning/thin_dump.cc b/thin-provisioning/thin_dump.cc
|
||
|
index a4bcf66..029a635 100644
|
||
|
--- a/thin-provisioning/thin_dump.cc
|
||
|
+++ b/thin-provisioning/thin_dump.cc
|
||
|
@@ -35,7 +35,7 @@ namespace {
|
||
|
int dump(string const &path, ostream &out, string const &format, bool repair,
|
||
|
block_address metadata_snap = 0) {
|
||
|
try {
|
||
|
- metadata::ptr md(new metadata(path, metadata::OPEN));
|
||
|
+ metadata::ptr md(metadata_snap ? new metadata(path, metadata_snap) : new metadata(path, metadata::OPEN, 0, 0));
|
||
|
emitter::ptr e;
|
||
|
|
||
|
if (format == "xml")
|
||
|
@@ -63,7 +63,7 @@ namespace {
|
||
|
<< " {-h|--help}" << endl
|
||
|
<< " {-f|--format} {xml|human_readable}" << endl
|
||
|
<< " {-r|--repair}" << endl
|
||
|
- << " {-m|--metadata-snap}" << endl
|
||
|
+ << " {-m|--metadata-snap} block#" << endl
|
||
|
<< " {-o <xml file>}" << endl
|
||
|
<< " {-V|--version}" << endl;
|
||
|
}
|