Merge branch 'v0.7-devel' into 2016-03-08-cache-writeback
Conflicts: thin-provisioning/commands.h
This commit is contained in:
commit
0bc126fbeb
@ -11,8 +11,6 @@ thin_provisioning::register_thin_commands(base::application &app)
|
||||
app.add_cmd(command::ptr(new thin_check_cmd()));
|
||||
app.add_cmd(command::ptr(new thin_delta_cmd()));
|
||||
app.add_cmd(command::ptr(new thin_dump_cmd()));
|
||||
app.add_cmd(command::ptr(new thin_ll_dump_cmd()));
|
||||
app.add_cmd(command::ptr(new thin_ll_restore_cmd()));
|
||||
app.add_cmd(command::ptr(new thin_ls_cmd()));
|
||||
app.add_cmd(command::ptr(new thin_metadata_size_cmd()));
|
||||
app.add_cmd(command::ptr(new thin_restore_cmd()));
|
||||
@ -20,6 +18,8 @@ thin_provisioning::register_thin_commands(base::application &app)
|
||||
app.add_cmd(command::ptr(new thin_rmap_cmd()));
|
||||
|
||||
#ifdef DEV_TOOLS
|
||||
app.add_cmd(command::ptr(new thin_ll_dump_cmd()));
|
||||
app.add_cmd(command::ptr(new thin_ll_restore_cmd()));
|
||||
app.add_cmd(command::ptr(new thin_scan_cmd()));
|
||||
app.add_cmd(command::ptr(new thin_trim_cmd()));
|
||||
app.add_cmd(command::ptr(new thin_generate_metadata_cmd()));
|
||||
|
@ -28,20 +28,6 @@ namespace thin_provisioning {
|
||||
virtual int run(int argc, char **argv);
|
||||
};
|
||||
|
||||
class thin_ll_dump_cmd : public base::command {
|
||||
public:
|
||||
thin_ll_dump_cmd();
|
||||
virtual void usage(std::ostream &out) const;
|
||||
virtual int run(int argc, char **argv);
|
||||
};
|
||||
|
||||
class thin_ll_restore_cmd : public base::command {
|
||||
public:
|
||||
thin_ll_restore_cmd();
|
||||
virtual void usage(std::ostream &out) const;
|
||||
virtual int run(int argc, char **argv);
|
||||
};
|
||||
|
||||
class thin_ls_cmd : public base::command {
|
||||
public:
|
||||
thin_ls_cmd();
|
||||
@ -80,14 +66,32 @@ namespace thin_provisioning {
|
||||
class thin_trim_cmd : public base::command {
|
||||
public:
|
||||
thin_trim_cmd();
|
||||
|
||||
virtual void usage(std::ostream &out) const;
|
||||
virtual int run(int argc, char **argv);
|
||||
};
|
||||
|
||||
#ifdef DEV_TOOLS
|
||||
class thin_ll_dump_cmd : public base::command {
|
||||
public:
|
||||
thin_ll_dump_cmd();
|
||||
|
||||
virtual void usage(std::ostream &out) const;
|
||||
virtual int run(int argc, char **argv);
|
||||
};
|
||||
|
||||
class thin_ll_restore_cmd : public base::command {
|
||||
public:
|
||||
thin_ll_restore_cmd();
|
||||
|
||||
virtual void usage(std::ostream &out) const;
|
||||
virtual int run(int argc, char **argv);
|
||||
};
|
||||
|
||||
class thin_scan_cmd : public base::command {
|
||||
public:
|
||||
thin_scan_cmd();
|
||||
|
||||
virtual void usage(std::ostream &out) const;
|
||||
virtual int run(int argc, char **argv);
|
||||
};
|
||||
|
@ -47,6 +47,13 @@ namespace {
|
||||
|
||||
namespace thin_provisioning {
|
||||
namespace device_tree_detail {
|
||||
device_details::device_details()
|
||||
: mapped_blocks_(0),
|
||||
transaction_id_(0),
|
||||
creation_time_(0),
|
||||
snapshotted_time_(0) {
|
||||
}
|
||||
|
||||
void
|
||||
device_details_traits::unpack(device_details_disk const &disk, device_details &value)
|
||||
{
|
||||
|
@ -16,6 +16,8 @@ namespace thin_provisioning {
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct device_details {
|
||||
device_details();
|
||||
|
||||
uint64_t mapped_blocks_;
|
||||
uint64_t transaction_id_; /* when created */
|
||||
uint32_t creation_time_;
|
||||
|
@ -85,9 +85,6 @@ namespace {
|
||||
void parse_device(metadata::ptr md, emitter::ptr e, attributes const &attr) {
|
||||
uint32_t dev_id = get_attr<uint32_t>(attr, "dev_id");
|
||||
device_tree_detail::device_details details;
|
||||
details.transaction_id_ = 0;
|
||||
details.creation_time_ = 0;
|
||||
details.snapshotted_time_ = 0;
|
||||
|
||||
device_tree::ptr details_tree;
|
||||
boost::optional<uint32_t> details_root = get_opt_attr<uint32_t>(attr, "blocknr");
|
||||
|
@ -129,14 +129,6 @@ namespace {
|
||||
};
|
||||
|
||||
struct block_range {
|
||||
uint64_t begin_;
|
||||
uint64_t end_; // one-pass-the-end
|
||||
boost::optional<uint64_t> blocknr_begin_;
|
||||
metadata_block_type type_;
|
||||
int64_t ref_count_; // ref_count in metadata space map
|
||||
size_t value_size_; // btree node only
|
||||
bool is_valid_; // btree node only
|
||||
|
||||
block_range()
|
||||
: begin_(0), end_(0),
|
||||
type_(UNKNOWN), ref_count_(-1),
|
||||
@ -151,10 +143,50 @@ namespace {
|
||||
value_size_(rhs.value_size_), is_valid_(rhs.is_valid_)
|
||||
{
|
||||
}
|
||||
|
||||
uint64_t size() const {
|
||||
return (end_ > begin_) ? (end_ - begin_) : 0;
|
||||
}
|
||||
|
||||
// returns true if r is left or right-adjacent
|
||||
bool is_adjacent_to(block_range const &r) const {
|
||||
block_range const &lhs = begin_ < r.begin_ ? *this : r;
|
||||
block_range const &rhs = begin_ < r.begin_ ? r : *this;
|
||||
|
||||
if (size() && r.size() &&
|
||||
rhs.begin_ == lhs.end_ &&
|
||||
((!blocknr_begin_ && !r.blocknr_begin_) ||
|
||||
(blocknr_begin_ && r.blocknr_begin_ &&
|
||||
*rhs.blocknr_begin_ >= *lhs.blocknr_begin_ &&
|
||||
(*rhs.blocknr_begin_ - *lhs.blocknr_begin_ == rhs.begin_ - lhs.begin_))) &&
|
||||
type_ == r.type_ &&
|
||||
ref_count_ == r.ref_count_ &&
|
||||
value_size_ == r.value_size_ &&
|
||||
is_valid_ == r.is_valid_)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool concat(block_range const &r) {
|
||||
if (!is_adjacent_to(r))
|
||||
return false;
|
||||
begin_ = std::min(begin_, r.begin_);
|
||||
end_ = std::max(end_, r.end_);
|
||||
return true;
|
||||
}
|
||||
|
||||
uint64_t begin_;
|
||||
uint64_t end_; // one-pass-the-end
|
||||
boost::optional<uint64_t> blocknr_begin_;
|
||||
metadata_block_type type_;
|
||||
int64_t ref_count_; // ref_count in metadata space map
|
||||
size_t value_size_; // btree node only
|
||||
bool is_valid_;
|
||||
};
|
||||
|
||||
void output_block_range(block_range const &r, std::ostream &out) {
|
||||
if (r.end_ <= r.begin_)
|
||||
if (!r.size())
|
||||
return;
|
||||
|
||||
if (r.end_ - r.begin_ > 1) {
|
||||
@ -288,18 +320,8 @@ namespace {
|
||||
curr_range.ref_count_ = -1;
|
||||
}
|
||||
|
||||
// output the current block
|
||||
if (run_range.end_ == 0)
|
||||
run_range = curr_range;
|
||||
else if (((!curr_range.blocknr_begin_ && !run_range.blocknr_begin_) ||
|
||||
(curr_range.blocknr_begin_ && run_range.blocknr_begin_ &&
|
||||
*curr_range.blocknr_begin_ == *run_range.blocknr_begin_ + (run_range.end_ - run_range.begin_))) &&
|
||||
curr_range.type_ == run_range.type_ &&
|
||||
curr_range.ref_count_ == run_range.ref_count_ &&
|
||||
curr_range.value_size_ == run_range.value_size_ &&
|
||||
curr_range.is_valid_ == run_range.is_valid_) {
|
||||
++run_range.end_;
|
||||
} else {
|
||||
// store the current block
|
||||
if (!run_range.concat(curr_range)) {
|
||||
output_block_range(run_range, out);
|
||||
run_range = curr_range;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user