Blame device-mapper-persistent-data-0.2.1-thin_dump-support-metadata-snap-block.patch

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