Merge branch 'master' of github.com:jthornber/thin-provisioning-tools
This commit is contained in:
commit
9adcc7911f
@ -48,8 +48,10 @@ namespace {
|
|||||||
base::sector_t next_offset() {
|
base::sector_t next_offset() {
|
||||||
sector_t r = current_;
|
sector_t r = current_;
|
||||||
current_ += block_size_;
|
current_ += block_size_;
|
||||||
if (current_ > end_)
|
if (current_ > end_) {
|
||||||
current_ = begin_;
|
current_ = begin_;
|
||||||
|
return begin_;
|
||||||
|
}
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,8 +117,7 @@ namespace {
|
|||||||
class base_io_generator: public io_generator {
|
class base_io_generator: public io_generator {
|
||||||
public:
|
public:
|
||||||
base_io_generator(io_generator_options const &opts);
|
base_io_generator(io_generator_options const &opts);
|
||||||
virtual bool has_next();
|
virtual bool next(base::io &next_io);
|
||||||
virtual void next(base::io &next_io);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
offset_generator::ptr
|
offset_generator::ptr
|
||||||
@ -140,19 +141,17 @@ namespace {
|
|||||||
io_size_total_(opts.io_size_) {
|
io_size_total_(opts.io_size_) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool base_io_generator::has_next() {
|
bool base_io_generator::next(base::io &next_io) {
|
||||||
return io_size_finished_ < io_size_total_;
|
|
||||||
}
|
|
||||||
|
|
||||||
void base_io_generator::next(base::io &next_io) {
|
|
||||||
if (io_size_finished_ >= io_size_total_)
|
if (io_size_finished_ >= io_size_total_)
|
||||||
throw std::runtime_error("");
|
return false;
|
||||||
|
|
||||||
next_io.op_ = op_gen_->next_op();
|
next_io.op_ = op_gen_->next_op();
|
||||||
next_io.sector_ = offset_gen_->next_offset();
|
next_io.sector_ = offset_gen_->next_offset();
|
||||||
next_io.size_ = block_size_;
|
next_io.size_ = block_size_;
|
||||||
|
|
||||||
io_size_finished_ += block_size_;
|
io_size_finished_ += block_size_;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
offset_generator::ptr
|
offset_generator::ptr
|
||||||
|
@ -42,8 +42,7 @@ namespace base {
|
|||||||
public:
|
public:
|
||||||
typedef std::shared_ptr<io_generator> ptr;
|
typedef std::shared_ptr<io_generator> ptr;
|
||||||
|
|
||||||
virtual bool has_next() = 0;
|
virtual bool next(base::io &next_io) = 0;
|
||||||
virtual void next(base::io &next_io) = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
io_generator::ptr
|
io_generator::ptr
|
||||||
|
@ -93,11 +93,12 @@ namespace persistent_data {
|
|||||||
{
|
{
|
||||||
using namespace btree_detail;
|
using namespace btree_detail;
|
||||||
|
|
||||||
unsigned i = 0;
|
unsigned i = *index;
|
||||||
bool r = false;
|
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
r = spine.step(block);
|
bool inc = spine.step(block);
|
||||||
|
if (inc)
|
||||||
|
inc_children<ValueTraits>(spine, leaf_rc);
|
||||||
|
|
||||||
// patch up the parent to point to the new shadow
|
// patch up the parent to point to the new shadow
|
||||||
if (spine.has_parent()) {
|
if (spine.has_parent()) {
|
||||||
@ -115,9 +116,9 @@ namespace persistent_data {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
r = rebalance_children<ValueTraits>(spine, key);
|
bool r = rebalance_children<ValueTraits>(spine, key);
|
||||||
if (!r)
|
if (!r)
|
||||||
break;
|
return false;
|
||||||
|
|
||||||
n = spine.get_node<block_traits>();
|
n = spine.get_node<block_traits>();
|
||||||
if (n.get_type() == btree_detail::LEAF) {
|
if (n.get_type() == btree_detail::LEAF) {
|
||||||
@ -133,7 +134,7 @@ namespace persistent_data {
|
|||||||
block = n.value_at(i);
|
block = n.value_at(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
return r;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <unsigned Levels, typename _>
|
template <unsigned Levels, typename _>
|
||||||
|
@ -93,10 +93,8 @@ namespace {
|
|||||||
io_generator::ptr gen = create_io_generator(opts);
|
io_generator::ptr gen = create_io_generator(opts);
|
||||||
|
|
||||||
base::io io;
|
base::io io;
|
||||||
while (gen->has_next()) {
|
while (gen->next(io)) {
|
||||||
// TODO: support io.size_
|
// TODO: support io.size_
|
||||||
gen->next(io);
|
|
||||||
|
|
||||||
switch (io.op_) {
|
switch (io.op_) {
|
||||||
case base::REQ_OP_READ:
|
case base::REQ_OP_READ:
|
||||||
process_read(td, pool, io.sector_);
|
process_read(td, pool, io.sector_);
|
||||||
@ -131,10 +129,10 @@ thin_generate_mappings_cmd::usage(std::ostream &out) const
|
|||||||
<< " {-h|--help}\n"
|
<< " {-h|--help}\n"
|
||||||
<< " {-o|--output} <output device or file>\n"
|
<< " {-o|--output} <output device or file>\n"
|
||||||
<< " {--dev-id} <dev-id>\n"
|
<< " {--dev-id} <dev-id>\n"
|
||||||
<< " {--offset} <offset>\n"
|
<< " {--offset} <offset in sectors>\n"
|
||||||
<< " {--io-size} <io_size>\n"
|
<< " {--io-size} <io-size in sectors>\n"
|
||||||
<< " {--rw write|trim|randwrite|randtrim|randtw}\n"
|
<< " {--rw write|trim|randwrite|randtrim|randtw}\n"
|
||||||
<< " {--size} <size>\n"
|
<< " {--size} <size in sectors>\n"
|
||||||
<< " {-V|--version}" << endl;
|
<< " {-V|--version}" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,13 +72,16 @@ thin::insert(block_address thin_block, block_address data_block)
|
|||||||
{
|
{
|
||||||
uint64_t key[2] = {dev_, thin_block};
|
uint64_t key[2] = {dev_, thin_block};
|
||||||
|
|
||||||
++details_.mapped_blocks_;
|
|
||||||
changed_ = true;
|
|
||||||
|
|
||||||
mapping_tree_detail::block_time bt;
|
mapping_tree_detail::block_time bt;
|
||||||
bt.block_ = data_block;
|
bt.block_ = data_block;
|
||||||
bt.time_ = pool_.get_time();
|
bt.time_ = pool_.get_time();
|
||||||
return pool_.md_->mappings_->insert(key, bt);
|
bool inserted = pool_.md_->mappings_->insert(key, bt);
|
||||||
|
|
||||||
|
changed_ = true;
|
||||||
|
if (inserted)
|
||||||
|
++details_.mapped_blocks_;
|
||||||
|
|
||||||
|
return inserted;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
Reference in New Issue
Block a user