[thin-repair, thin_dump] When repairing we now hunt for the best btree roots.

We've had a trickle of users who accidentally activate the same pool on a
VM and host at the same time.  Typically the host doesn't do any IO, but
the kernel will still rewrite the superblock on shutdown.  This leaves
the superblock pointing to very out of date btree roots and so we get
massive metadata loss.

This patch changes thin_repair, and thin_dump --repair.  They now hunt
for the most recent, undamaged and consistent roots of the device and
mapping trees, and use that as the starting point of the repair.
This commit is contained in:
Joe Thornber
2019-04-17 12:17:13 +01:00
parent b027a1039f
commit 9e20465fd1
4 changed files with 560 additions and 362 deletions

View File

@@ -31,8 +31,7 @@ namespace thin_provisioning {
class dump_options {
public:
dump_options()
: repair_(false),
skip_mappings_(false) {
: skip_mappings_(false) {
}
bool selected_dev(uint64_t dev_id) const {
@@ -46,11 +45,11 @@ namespace thin_provisioning {
dev_filter_->insert(dev_id);
}
bool repair_;
bool skip_mappings_;
using dev_set = std::set<uint64_t>;
using maybe_dev_set = boost::optional<dev_set>;
maybe_dev_set dev_filter_;
};
@@ -58,6 +57,13 @@ namespace thin_provisioning {
// the dumper to do it's best to recover info. If not set, any
// corruption encountered will cause an exception to be thrown.
void metadata_dump(metadata::ptr md, emitter::ptr e, dump_options const &opts);
// We have to provide a different interface for repairing, since
// the superblock itself may be corrupt, so we wont be able
// to create the metadata object.
void metadata_repair(block_manager<>::ptr bm, emitter::ptr e);
// Only used by ll_restore, so we leave the repair arg
void metadata_dump_subtree(metadata::ptr md, emitter::ptr e, bool repair, uint64_t subtree_root);
}