2011-12-16 00:04:31 +05:30
|
|
|
// Copyright (C) 2011 Red Hat, Inc. All rights reserved.
|
2011-12-06 19:23:05 +05:30
|
|
|
//
|
2011-12-06 19:13:56 +05:30
|
|
|
// This file is part of the thin-provisioning-tools source.
|
|
|
|
//
|
|
|
|
// thin-provisioning-tools is free software: you can redistribute it
|
|
|
|
// and/or modify it under the terms of the GNU General Public License
|
|
|
|
// as published by the Free Software Foundation, either version 3 of
|
|
|
|
// the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// thin-provisioning-tools is distributed in the hope that it will be
|
|
|
|
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
|
|
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License along
|
|
|
|
// with thin-provisioning-tools. If not, see
|
|
|
|
// <http://www.gnu.org/licenses/>.
|
|
|
|
|
2011-10-28 16:37:21 +05:30
|
|
|
#ifndef METADATA_CHECKER_H
|
|
|
|
#define METADATA_CHECKER_H
|
|
|
|
|
2013-04-25 20:57:07 +05:30
|
|
|
#include "persistent-data/block.h"
|
2013-01-02 18:25:41 +05:30
|
|
|
#include "persistent-data/error_set.h"
|
2013-05-28 16:21:44 +05:30
|
|
|
#include "persistent-data/run.h"
|
2013-04-25 20:57:07 +05:30
|
|
|
#include "persistent-data/space_map.h"
|
|
|
|
|
|
|
|
#include <deque>
|
2011-10-28 16:37:21 +05:30
|
|
|
|
|
|
|
//----------------------------------------------------------------
|
|
|
|
|
|
|
|
namespace thin_provisioning {
|
2013-05-21 17:16:07 +05:30
|
|
|
// FIXME: should take a block manager or transaction manager
|
|
|
|
void check_metadata(std::string const &path);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if 0
|
2013-04-25 20:57:07 +05:30
|
|
|
|
|
|
|
// Base class for all types of metadata damage. Used in reporting.
|
|
|
|
class metadata_damage {
|
|
|
|
public:
|
|
|
|
typedef boost::shared_ptr<metadata_damage> ptr;
|
|
|
|
virtual ~metadata_damage() {}
|
|
|
|
virtual void visit(metadata_damage_visitor &visitor) const = 0;
|
|
|
|
|
|
|
|
void set_message(std::string const &message);
|
|
|
|
std::string const &get_message() const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::string message_;
|
|
|
|
};
|
|
|
|
|
2013-04-29 17:10:56 +05:30
|
|
|
// FIXME: there's a mix of abstraction here, some classes represent
|
|
|
|
// the actual damage on disk (bad_ref_count), others represent the
|
|
|
|
// repercussions (missing_mapping). Need to revist, probably once
|
|
|
|
// we've got the reporting layer in.
|
|
|
|
|
2013-04-25 20:57:07 +05:30
|
|
|
class super_block_corruption : public metadata_damage {
|
|
|
|
void visit(metadata_damage_visitor &visitor) const;
|
2013-04-29 20:42:05 +05:30
|
|
|
bool operator ==(super_block_corruption const &rhs) const;
|
2013-04-25 20:57:07 +05:30
|
|
|
};
|
|
|
|
|
2013-05-28 16:50:05 +05:30
|
|
|
typedef base::run<uint64_t> run64;
|
2013-04-25 20:57:07 +05:30
|
|
|
|
2013-04-29 20:07:53 +05:30
|
|
|
struct missing_device_details : public metadata_damage {
|
2013-05-28 16:50:05 +05:30
|
|
|
missing_device_details(run64 missing);
|
2013-04-25 20:57:07 +05:30
|
|
|
virtual void visit(metadata_damage_visitor &visitor) const;
|
2013-04-29 20:42:05 +05:30
|
|
|
bool operator ==(missing_device_details const &rhs) const;
|
2013-04-25 20:57:07 +05:30
|
|
|
|
2013-05-28 16:50:05 +05:30
|
|
|
run64 missing_;
|
2013-04-25 20:57:07 +05:30
|
|
|
};
|
|
|
|
|
|
|
|
struct missing_devices : public metadata_damage {
|
2013-05-28 16:50:05 +05:30
|
|
|
missing_devices(run64 missing);
|
2013-04-25 20:57:07 +05:30
|
|
|
virtual void visit(metadata_damage_visitor &visitor) const;
|
2013-04-29 20:42:05 +05:30
|
|
|
bool operator ==(missing_devices const &rhs) const;
|
2013-04-25 20:57:07 +05:30
|
|
|
|
2013-05-28 16:50:05 +05:30
|
|
|
run64 missing_;
|
2013-04-25 20:57:07 +05:30
|
|
|
};
|
|
|
|
|
|
|
|
struct missing_mappings : public metadata_damage {
|
2013-05-28 16:50:05 +05:30
|
|
|
missing_mappings(uint64_t dev, run64 missing);
|
2013-04-25 20:57:07 +05:30
|
|
|
virtual void visit(metadata_damage_visitor &visitor) const;
|
2013-04-29 20:42:05 +05:30
|
|
|
bool operator ==(missing_mappings const &rhs) const;
|
2013-04-25 20:57:07 +05:30
|
|
|
|
|
|
|
uint64_t dev_;
|
2013-05-28 16:50:05 +05:30
|
|
|
run64 missing_;
|
2013-04-25 20:57:07 +05:30
|
|
|
};
|
|
|
|
|
|
|
|
struct bad_metadata_ref_count : public metadata_damage {
|
|
|
|
bad_metadata_ref_count(block_address b,
|
|
|
|
ref_t actual,
|
|
|
|
ref_t expected);
|
|
|
|
|
|
|
|
virtual void visit(metadata_damage_visitor &visitor) const;
|
2013-04-29 20:42:05 +05:30
|
|
|
bool operator ==(bad_metadata_ref_count const &rhs) const;
|
2013-04-25 20:57:07 +05:30
|
|
|
|
|
|
|
block_address b_;
|
|
|
|
ref_t actual_;
|
|
|
|
ref_t expected_;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct bad_data_ref_count : public metadata_damage {
|
|
|
|
bad_data_ref_count(block_address b,
|
|
|
|
ref_t actual,
|
|
|
|
ref_t expected);
|
|
|
|
|
|
|
|
virtual void visit(metadata_damage_visitor &visitor) const;
|
2013-04-29 20:42:05 +05:30
|
|
|
bool operator ==(bad_data_ref_count const &rhs) const;
|
2013-04-25 20:57:07 +05:30
|
|
|
|
|
|
|
block_address b_;
|
|
|
|
ref_t actual_;
|
|
|
|
ref_t expected_;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct missing_metadata_ref_counts : public metadata_damage {
|
2013-05-28 16:50:05 +05:30
|
|
|
missing_metadata_ref_counts(run64 missing);
|
2013-04-25 20:57:07 +05:30
|
|
|
virtual void visit(metadata_damage_visitor &visitor) const;
|
2013-04-29 20:42:05 +05:30
|
|
|
bool operator ==(missing_metadata_ref_counts const &rhs) const;
|
2013-04-25 20:57:07 +05:30
|
|
|
|
2013-05-28 16:50:05 +05:30
|
|
|
run64 missing_;
|
2013-04-25 20:57:07 +05:30
|
|
|
};
|
|
|
|
|
|
|
|
struct missing_data_ref_counts : public metadata_damage {
|
2013-05-28 16:50:05 +05:30
|
|
|
missing_data_ref_counts(run64 missing);
|
2013-04-25 20:57:07 +05:30
|
|
|
virtual void visit(metadata_damage_visitor &visitor) const;
|
2013-04-29 20:42:05 +05:30
|
|
|
bool operator ==(missing_data_ref_counts const &rhs) const;
|
2013-04-25 20:57:07 +05:30
|
|
|
|
2013-05-28 16:50:05 +05:30
|
|
|
run64 missing_;
|
2013-04-25 20:57:07 +05:30
|
|
|
};
|
|
|
|
|
|
|
|
class metadata_damage_visitor {
|
|
|
|
public:
|
|
|
|
typedef boost::shared_ptr<metadata_damage_visitor> ptr;
|
|
|
|
|
|
|
|
virtual ~metadata_damage_visitor() {}
|
|
|
|
|
|
|
|
void visit(metadata_damage const &damage);
|
|
|
|
virtual void visit(super_block_corruption const &damage) = 0;
|
|
|
|
virtual void visit(missing_device_details const &damage) = 0;
|
|
|
|
virtual void visit(missing_devices const &damage) = 0;
|
|
|
|
virtual void visit(missing_mappings const &damage) = 0;
|
|
|
|
virtual void visit(bad_metadata_ref_count const &damage) = 0;
|
|
|
|
virtual void visit(bad_data_ref_count const &damage) = 0;
|
|
|
|
virtual void visit(missing_metadata_ref_counts const &damage) = 0;
|
|
|
|
virtual void visit(missing_data_ref_counts const &damage) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef std::deque<metadata_damage::ptr> damage_list;
|
|
|
|
typedef boost::shared_ptr<damage_list> damage_list_ptr;
|
2013-05-21 17:16:07 +05:30
|
|
|
#endif
|
2011-10-28 16:37:21 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------
|
|
|
|
|
|
|
|
#endif
|