thin_dump: support --metadata-snap block#
This commit is contained in:
parent
d4e9875758
commit
1b6f9255a1
@ -22,6 +22,9 @@ Print output in XML or human readable format.
|
|||||||
|
|
||||||
.IP "\fB\-r, \-\-repair\fP".
|
.IP "\fB\-r, \-\-repair\fP".
|
||||||
|
|
||||||
|
.IP "\fB\-m, \-\-metadata_snap\fP block#".
|
||||||
|
Dump metadata snapshot at block#
|
||||||
|
|
||||||
.IP "\fB\-h, \-\-help\fP".
|
.IP "\fB\-h, \-\-help\fP".
|
||||||
Print help and exit.
|
Print help and exit.
|
||||||
|
|
||||||
|
@ -57,15 +57,6 @@ namespace {
|
|||||||
return tm;
|
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
|
void
|
||||||
copy_space_maps(space_map::ptr lhs, space_map::ptr rhs) {
|
copy_space_maps(space_map::ptr lhs, space_map::ptr rhs) {
|
||||||
for (block_address b = 0; b < rhs->get_nr_blocks(); b++) {
|
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));
|
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
|
// We don't open the metadata sm for a held root
|
||||||
//metadata_sm_ = open_metadata_sm(tm_, &sb_.metadata_space_map_root_);
|
//metadata_sm_ = open_metadata_sm(tm_, &sb_.metadata_space_map_root_);
|
||||||
|
@ -62,10 +62,11 @@ namespace thin_provisioning {
|
|||||||
// Deprecated: it would be better if we passed in an already
|
// Deprecated: it would be better if we passed in an already
|
||||||
// constructed block_manager.
|
// constructed block_manager.
|
||||||
metadata(std::string const &dev_path, open_type ot,
|
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
|
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 ...
|
// ... use these instead ...
|
||||||
metadata(block_manager<>::ptr bm, open_type ot,
|
metadata(block_manager<>::ptr bm, open_type ot,
|
||||||
|
@ -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;
|
using namespace superblock_detail;
|
||||||
|
|
||||||
superblock sb;
|
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_disk const *sbd = reinterpret_cast<superblock_disk const *>(&r.data());
|
||||||
superblock_traits::unpack(*sbd, sb);
|
superblock_traits::unpack(*sbd, sb);
|
||||||
return sb;
|
return sb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
superblock_detail::superblock read_superblock(block_manager<>::ptr bm)
|
||||||
|
{
|
||||||
|
return read_superblock(bm, SUPERBLOCK_LOCATION);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
check_superblock(block_manager<>::ptr bm,
|
check_superblock(block_manager<>::ptr bm,
|
||||||
superblock_detail::damage_visitor &visitor) {
|
superblock_detail::damage_visitor &visitor) {
|
||||||
|
@ -123,6 +123,7 @@ namespace thin_provisioning {
|
|||||||
persistent_data::block_manager<>::validator::ptr superblock_validator();
|
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);
|
||||||
|
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,
|
void check_superblock(persistent_data::block_manager<>::ptr bm,
|
||||||
superblock_detail::damage_visitor &visitor);
|
superblock_detail::damage_visitor &visitor);
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ namespace {
|
|||||||
int dump(string const &path, ostream &out, string const &format, bool repair,
|
int dump(string const &path, ostream &out, string const &format, bool repair,
|
||||||
block_address metadata_snap = 0) {
|
block_address metadata_snap = 0) {
|
||||||
try {
|
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;
|
emitter::ptr e;
|
||||||
|
|
||||||
if (format == "xml")
|
if (format == "xml")
|
||||||
@ -63,7 +63,7 @@ namespace {
|
|||||||
<< " {-h|--help}" << endl
|
<< " {-h|--help}" << endl
|
||||||
<< " {-f|--format} {xml|human_readable}" << endl
|
<< " {-f|--format} {xml|human_readable}" << endl
|
||||||
<< " {-r|--repair}" << endl
|
<< " {-r|--repair}" << endl
|
||||||
<< " {-m|--metadata-snap}" << endl
|
<< " {-m|--metadata-snap} block#" << endl
|
||||||
<< " {-o <xml file>}" << endl
|
<< " {-o <xml file>}" << endl
|
||||||
<< " {-V|--version}" << endl;
|
<< " {-V|--version}" << endl;
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
*
|
*
|
||||||
* This file is released under the GPL
|
* This file is released under the GPL
|
||||||
*
|
*
|
||||||
*
|
|
||||||
* Calculates device-mapper thin privisioning
|
* Calculates device-mapper thin privisioning
|
||||||
* metadata device size based on pool, block size and
|
* metadata device size based on pool, block size and
|
||||||
* maximum expected thin provisioned devices and snapshots.
|
* maximum expected thin provisioned devices and snapshots.
|
||||||
|
Loading…
Reference in New Issue
Block a user