Merge remote-tracking branch 'ejt/master'

This commit is contained in:
Heinz Mauelshagen 2013-08-08 12:10:41 +02:00
commit a441b7d4db
10 changed files with 65 additions and 47 deletions

View File

@ -83,7 +83,7 @@ OBJECTS:=$(subst .cc,.o,$(SOURCE))
TOP_DIR:=@top_srcdir@
TOP_BUILDDIR:=@top_builddir@
CFLAGS+=-g -Wall -O3
CXXFLAGS+=-std=c++11 -g -Wall -fno-strict-aliasing
CXXFLAGS+=-g -Wall -fno-strict-aliasing
CXXFLAGS+=@CXXOPTIMISE_FLAG@
CXXFLAGS+=@CXXDEBUG_FLAG@
INCLUDES+=-I$(TOP_BUILDDIR) -I$(TOP_DIR) -I$(TOP_DIR)/thin-provisioning

View File

@ -62,7 +62,7 @@ namespace base {
if (!runs_.size())
return false;
auto it = runs_.lower_bound(run<T>(v));
typename rset::const_iterator it = runs_.lower_bound(run<T>(v));
if (it->begin_ == v)
return true;
@ -98,7 +98,7 @@ namespace base {
if (runs_.begin() == runs_.end())
replacement.insert(run<T>());
else {
auto b = runs_.begin();
typename rset::const_iterator b = runs_.begin();
maybe last = b->end_;
if (b->begin_)

View File

@ -19,6 +19,8 @@
#include "persistent-data/space-maps/careful_alloc.h"
#include "persistent-data/space-maps/subtracting_span_iterator.h"
#include <boost/shared_ptr.hpp>
//----------------------------------------------------------------
namespace {
@ -26,7 +28,7 @@ namespace {
class sm_careful_alloc : public checked_space_map {
public:
typedef std::shared_ptr<sm_careful_alloc> ptr;
typedef boost::shared_ptr<sm_careful_alloc> ptr;
sm_careful_alloc(checked_space_map::ptr sm)
: sm_(sm) {

View File

@ -29,16 +29,19 @@ rmap_visitor::visit(btree_path const &path,
}
}
namespace {
bool cmp_data_begin(rmap_visitor::rmap_region const &lhs,
rmap_visitor::rmap_region const &rhs) {
return lhs.data_begin < rhs.data_begin;
};
}
void
rmap_visitor::complete()
{
if (current_rmap_)
push_current();
auto cmp_data_begin = [] (rmap_region const &lhs, rmap_region const &rhs) {
return lhs.data_begin < rhs.data_begin;
};
std::sort(rmap_.begin(), rmap_.end(), cmp_data_begin);
}
@ -52,8 +55,9 @@ rmap_visitor::get_rmap() const
bool
rmap_visitor::in_regions(block_address b) const
{
for (region const &r : regions_)
if (r.contains(b))
vector<region>::const_iterator it;
for (it = regions_.begin(); it != regions_.end(); ++it)
if (it->contains(b))
return true;
return false;

View File

@ -131,7 +131,7 @@ namespace thin_provisioning {
using namespace superblock_detail;
superblock sb;
auto r = bm->read_lock(location, superblock_validator());
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;

View File

@ -168,7 +168,7 @@ namespace {
virtual void visit(superblock_detail::superblock_corruption const &d) {
out_ << "superblock is corrupt" << end_message();
{
auto _ = out_.push();
nested_output::nest _ = out_.push();
out_ << d.desc_ << end_message();
}
err_ = combine_errors(err_, FATAL);
@ -195,7 +195,7 @@ namespace {
virtual void visit(device_tree_detail::missing_devices const &d) {
out_ << "missing devices: " << d.keys_ << end_message();
{
auto _ = out_.push();
nested_output::nest _ = out_.push();
out_ << d.desc_ << end_message();
}
@ -222,7 +222,7 @@ namespace {
virtual void visit(mapping_tree_detail::missing_devices const &d) {
out_ << "missing all mappings for devices: " << d.keys_ << end_message();
{
auto _ = out_.push();
nested_output::nest _ = out_.push();
out_ << d.desc_ << end_message();
}
err_ = combine_errors(err_, FATAL);
@ -231,7 +231,7 @@ namespace {
virtual void visit(mapping_tree_detail::missing_mappings const &d) {
out_ << "thin device " << d.thin_dev_ << " is missing mappings " << d.keys_ << end_message();
{
auto _ = out_.push();
nested_output::nest _ = out_.push();
out_ << d.desc_ << end_message();
}
err_ = combine_errors(err_, FATAL);
@ -267,7 +267,7 @@ namespace {
out << "examining superblock" << end_message();
{
auto _ = out.push();
nested_output::nest _ = out.push();
check_superblock(bm, sb_rep);
}
@ -280,7 +280,7 @@ namespace {
if (fs.check_device_tree) {
out << "examining devices tree" << end_message();
{
auto _ = out.push();
nested_output::nest _ = out.push();
device_tree dtree(tm, sb.device_details_root_,
device_tree_detail::device_details_traits::ref_counter());
check_device_tree(dtree, dev_rep);
@ -290,7 +290,7 @@ namespace {
if (fs.check_mapping_tree_level1 && !fs.check_mapping_tree_level2) {
out << "examining top level of mapping tree" << end_message();
{
auto _ = out.push();
nested_output::nest _ = out.push();
dev_tree dtree(tm, sb.data_mapping_root_,
mapping_tree_detail::mtree_traits::ref_counter(tm));
check_mapping_tree(dtree, mapping_rep);
@ -299,7 +299,7 @@ namespace {
} else if (fs.check_mapping_tree_level2) {
out << "examining mapping tree" << end_message();
{
auto _ = out.push();
nested_output::nest _ = out.push();
mapping_tree mtree(tm, sb.data_mapping_root_,
mapping_tree_detail::block_traits::ref_counter(tm->get_sm()));
check_mapping_tree(mtree, mapping_rep);

View File

@ -50,7 +50,9 @@ namespace {
};
void display_rmap(ostream &out, vector<rmap_region> const &rmap) {
for (rmap_region const &r : rmap) {
vector<rmap_region>::const_iterator it;
for (it = rmap.begin(); it != rmap.end(); ++it) {
rmap_region const &r = *it;
out << "data " << r.data_begin
<< ".." << r.data_end
<< " -> thin(" << r.thin_dev
@ -66,8 +68,9 @@ namespace {
rmap_visitor rv;
try {
for (region const &r : regions)
rv.add_data_region(r);
vector<region>::const_iterator it;
for (it = regions.begin(); it != regions.end(); ++it)
rv.add_data_region(*it);
block_manager<>::ptr bm = open_bm(path);
transaction_manager::ptr tm = open_tm(bm);

View File

@ -82,13 +82,14 @@ namespace {
<< ", path [";
bool first = true;
for (auto k : ni.path) {
btree_detail::btree_path::const_iterator it;
for (it = ni.path.begin(); it != ni.path.end(); ++it) {
if (first)
first = false;
else
out << ", ";
out << k;
out << *it;
}
out << "], b " << ni.b
@ -121,8 +122,9 @@ namespace {
unsigned get_nr_nodes(Predicate const &pred) const {
unsigned nr = 0;
for (auto n : nodes_)
if (pred(n))
node_array::const_iterator it;
for (it = nodes_.begin(); it != nodes_.end(); ++it)
if (pred(*it))
nr++;
return nr;
@ -132,8 +134,9 @@ namespace {
node_info get_node(unsigned target, Predicate const &pred) const {
unsigned i = 0;
for (auto n : nodes_) {
if (pred(n)) {
node_array::const_iterator it;
for (it = nodes_.begin(); it != nodes_.end(); ++it) {
if (pred(*it)) {
if (!target)
break;
else
@ -163,13 +166,14 @@ namespace {
node_array v;
for (auto n : nodes_) {
node_array::const_iterator it;
for (it = nodes_.begin(); it != nodes_.end(); ++it) {
if (!target)
break;
if (pred(n)) {
if (pred(*it)) {
if (target <= count)
v.push_back(n);
v.push_back(*it);
target--;
}
@ -525,8 +529,9 @@ TEST_F(BTreeDamageVisitorTests, populated_tree_with_a_sequence_of_damaged_leaf_n
unsigned const COUNT = 5;
node_array nodes = layout_->get_random_nodes(COUNT, is_leaf);
for (auto n : nodes)
trash_block(n.b);
node_array::const_iterator it;
for (it = nodes.begin(); it != nodes.end(); ++it)
trash_block(it->b);
block_address begin = *nodes[0].keys.begin_;
block_address end = *nodes[COUNT - 1].keys.end_;
@ -627,15 +632,17 @@ TEST_F(BTreeDamageVisitor2Tests, populated_tree_with_no_damage)
run();
}
namespace {
bool leaf1(node_info const &n) {
return (n.leaf && n.path.size() == 1 && n.path[0] == 1);
}
}
TEST_F(BTreeDamageVisitor2Tests, damaged_leaf)
{
insert_values(10, 1000);
tree_complete();
auto leaf1 = [] (node_info const &n) {
return (n.leaf && n.path.size() == 1 && n.path[0] == 1);
};
node_info n = layout_->random_node(leaf1);
trash_block(n.b);

View File

@ -19,6 +19,8 @@
#include "gmock/gmock.h"
#include "persistent-data/cache.h"
#include <boost/shared_ptr.hpp>
using namespace boost;
using namespace base;
using namespace std;
@ -53,7 +55,7 @@ namespace {
struct SharedThingTraits {
typedef unsigned key_type;
typedef std::shared_ptr<Thing> value_type;
typedef boost::shared_ptr<Thing> value_type;
static key_type get_key(value_type const &p) {
return p->key_;

View File

@ -119,7 +119,7 @@ TEST(RegularSpanItTests, regular_span_iterator)
TEST_F(SpanItTests, sub_it_with_no_removed_blocks)
{
auto it = run();
subtracting_span_iterator it = run();
ASSERT_THAT(it.first(), Eq(maybe_span(span(23, 47))));
ASSERT_THAT(it.next(), Eq(maybe_span(span(59, 103))));
}
@ -128,7 +128,7 @@ TEST_F(SpanItTests, sub_it_with_removed_first_block)
{
forbidden.add(23);
auto it = run();
subtracting_span_iterator it = run();
ASSERT_THAT(it.first(), Eq(maybe_span(span(24, 47))));
ASSERT_THAT(it.next(), Eq(maybe_span(span(59, 103))));
}
@ -138,7 +138,7 @@ TEST_F(SpanItTests, sub_it_with_removed_run_overlapping_front_of_first_block)
for (block_address i = 19; i < 26; i++)
forbidden.add(i);
auto it = run();
subtracting_span_iterator it = run();
ASSERT_THAT(it.first(), Eq(maybe_span(span(26, 47))));
ASSERT_THAT(it.next(), Eq(maybe_span(span(59, 103))));
}
@ -147,7 +147,7 @@ TEST_F(SpanItTests, sub_it_with_removed_mid_block)
{
forbidden.add(40);
auto it = run();
subtracting_span_iterator it = run();
ASSERT_THAT(it.first(), Eq(maybe_span(span(23, 40))));
ASSERT_THAT(it.next(), Eq(maybe_span(span(41, 47))));
ASSERT_THAT(it.next(), Eq(maybe_span(span(59, 103))));
@ -158,7 +158,7 @@ TEST_F(SpanItTests, sub_it_with_removed_run_mid_block)
for (block_address i = 26; i < 36; i++)
forbidden.add(i);
auto it = run();
subtracting_span_iterator it = run();
ASSERT_THAT(it.first(), Eq(maybe_span(span(23, 26))));
ASSERT_THAT(it.next(), Eq(maybe_span(span(36, 47))));
ASSERT_THAT(it.next(), Eq(maybe_span(span(59, 103))));
@ -168,7 +168,7 @@ TEST_F(SpanItTests, sub_it_with_removed_end_block)
{
forbidden.add(46);
auto it = run();
subtracting_span_iterator it = run();
ASSERT_THAT(it.first(), Eq(maybe_span(span(23, 46))));
ASSERT_THAT(it.next(), Eq(maybe_span(span(59, 103))));
}
@ -178,7 +178,7 @@ TEST_F(SpanItTests, sub_it_with_removed_run_end_block)
for (block_address i = 26; i < 50; i++)
forbidden.add(i);
auto it = run();
subtracting_span_iterator it = run();
ASSERT_THAT(it.first(), Eq(maybe_span(span(23, 26))));
ASSERT_THAT(it.next(), Eq(maybe_span(span(59, 103))));
}
@ -188,7 +188,7 @@ TEST_F(SpanItTests, sub_it_with_removed_run_overlapping_2_blocks)
for (block_address i = 26; i < 70; i++)
forbidden.add(i);
auto it = run();
subtracting_span_iterator it = run();
ASSERT_THAT(it.first(), Eq(maybe_span(span(23, 26))));
ASSERT_THAT(it.next(), Eq(maybe_span(span(70, 103))));
}
@ -200,7 +200,7 @@ TEST_F(SpanItTests, sub_it_with_removed_intermediate_blocks)
forbidden.add(57);
forbidden.add(58);
auto it = run();
subtracting_span_iterator it = run();
ASSERT_THAT(it.first(), Eq(maybe_span(span(23, 47))));
ASSERT_THAT(it.next(), Eq(maybe_span(span(59, 103))));
}