From 4e1e7200a998ebce6e6e78476dc23e5837a015bf Mon Sep 17 00:00:00 2001 From: Heinz Mauelshagen Date: Tue, 30 Jul 2013 19:55:52 +0200 Subject: [PATCH 1/6] manual page fixes in header --- man8/thin_check.8 | 2 +- man8/thin_rmap.8 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/man8/thin_check.8 b/man8/thin_check.8 index 1489078..a8dc81b 100644 --- a/man8/thin_check.8 +++ b/man8/thin_check.8 @@ -1,4 +1,4 @@ -.TH THIN_REPAIR 8 "Thin Provisioning Tools" "Red Hat, Inc." \" -*- nroff -*- +.TH THIN_CHECK 8 "Thin Provisioning Tools" "Red Hat, Inc." \" -*- nroff -*- .SH NAME thin_check \- repair thin provisioning metadata on device or file diff --git a/man8/thin_rmap.8 b/man8/thin_rmap.8 index 4d74520..684c86c 100644 --- a/man8/thin_rmap.8 +++ b/man8/thin_rmap.8 @@ -1,4 +1,4 @@ -.TH THIN_DUMP 8 "Thin Provisioning Tools" "Red Hat, Inc." \" -*- nroff -*- +.TH THIN_RMAP(g 8 "Thin Provisioning Tools" "Red Hat, Inc." \" -*- nroff -*- .SH NAME thin_rmap \- output reverse map of a thin provisioned region of blocks from metadata device or file From 13293d064075234dd602c8ab4aa54108e18cee08 Mon Sep 17 00:00:00 2001 From: Heinz Mauelshagen Date: Wed, 31 Jul 2013 12:07:16 +0200 Subject: [PATCH 2/6] Fix missing quote in xml output with metadata_snap= --- thin-provisioning/xml_format.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/thin-provisioning/xml_format.cc b/thin-provisioning/xml_format.cc index 7125b4c..55007ca 100644 --- a/thin-provisioning/xml_format.cc +++ b/thin-provisioning/xml_format.cc @@ -59,7 +59,7 @@ namespace { << " nr_data_blocks=\"" << nr_data_blocks; if (metadata_snap) - out_ << " metadata_snap=\"" << *metadata_snap; + out_ << "\" metadata_snap=\"" << *metadata_snap; out_ << "\">" << endl; From fa6e2ab84151848e7ea0a8dcf16fa306597437b6 Mon Sep 17 00:00:00 2001 From: Joe Thornber Date: Fri, 2 Aug 2013 13:14:07 +0100 Subject: [PATCH 3/6] update Gemfile.lock --- Gemfile.lock | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 4994d34..16b0c75 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -8,20 +8,22 @@ GEM builder (3.2.2) childprocess (0.3.9) ffi (~> 1.0, >= 1.0.11) - cucumber (1.3.2) + cucumber (1.3.5) builder (>= 2.1.2) diff-lcs (>= 1.1.3) gherkin (~> 2.12.0) - multi_json (~> 1.3) + multi_json (~> 1.7.5) + multi_test (>= 0.0.2) diff-lcs (1.2.4) ejt_command_line (0.0.2) ffi (1.9.0) gherkin (2.12.0) multi_json (~> 1.3) multi_json (1.7.7) - rspec-expectations (2.13.0) + multi_test (0.0.2) + rspec-expectations (2.14.0) diff-lcs (>= 1.1.3, < 2.0) - thinp_xml (0.0.3) + thinp_xml (0.0.6) ejt_command_line (= 0.0.2) PLATFORMS From dd26ec76b20ba36dadef9d3dabaff00240a32d5c Mon Sep 17 00:00:00 2001 From: Joe Thornber Date: Fri, 2 Aug 2013 13:14:49 +0100 Subject: [PATCH 4/6] [thin_repair] don't open the space maps in the old metadata, we'll regenerate. --- thin-provisioning/thin_repair.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/thin-provisioning/thin_repair.cc b/thin-provisioning/thin_repair.cc index 4921ee9..f1b078a 100644 --- a/thin-provisioning/thin_repair.cc +++ b/thin-provisioning/thin_repair.cc @@ -19,7 +19,7 @@ namespace { metadata::ptr new_md(new metadata(new_path, metadata::CREATE, 128, 0)); emitter::ptr e = create_restore_emitter(new_md); - metadata::ptr old_md(new metadata(old_path, metadata::OPEN)); + metadata::ptr old_md(new metadata(old_path)); metadata_dump(old_md, e, true); } catch (std::exception &e) { From 79f64267b5248ecff86aa65b76b5aa9ee35eba5a Mon Sep 17 00:00:00 2001 From: Joe Thornber Date: Fri, 2 Aug 2013 13:15:36 +0100 Subject: [PATCH 5/6] bump version --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index ee1372d..abd4105 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.2.2 +0.2.4 From 0029962f200ca4f256de114779bb5fad96836d89 Mon Sep 17 00:00:00 2001 From: Joe Thornber Date: Thu, 8 Aug 2013 10:49:59 +0100 Subject: [PATCH 6/6] Give up with --std=c++11 There are too many distros that use old versions of g++ that don't support it adequately. --- Makefile.in | 2 +- persistent-data/run_set.h | 4 +-- persistent-data/space-maps/careful_alloc.cc | 4 ++- thin-provisioning/rmap_visitor.cc | 16 +++++---- thin-provisioning/superblock.cc | 2 +- thin-provisioning/thin_check.cc | 16 ++++----- thin-provisioning/thin_rmap.cc | 9 +++-- unit-tests/btree_damage_visitor_t.cc | 37 ++++++++++++--------- unit-tests/cache_t.cc | 4 ++- unit-tests/span_iterator_t.cc | 18 +++++----- 10 files changed, 65 insertions(+), 47 deletions(-) diff --git a/Makefile.in b/Makefile.in index 17dbb67..505166d 100644 --- a/Makefile.in +++ b/Makefile.in @@ -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 diff --git a/persistent-data/run_set.h b/persistent-data/run_set.h index 1732896..a061487 100644 --- a/persistent-data/run_set.h +++ b/persistent-data/run_set.h @@ -62,7 +62,7 @@ namespace base { if (!runs_.size()) return false; - auto it = runs_.lower_bound(run(v)); + typename rset::const_iterator it = runs_.lower_bound(run(v)); if (it->begin_ == v) return true; @@ -98,7 +98,7 @@ namespace base { if (runs_.begin() == runs_.end()) replacement.insert(run()); else { - auto b = runs_.begin(); + typename rset::const_iterator b = runs_.begin(); maybe last = b->end_; if (b->begin_) diff --git a/persistent-data/space-maps/careful_alloc.cc b/persistent-data/space-maps/careful_alloc.cc index 7ef0217..a0fb180 100644 --- a/persistent-data/space-maps/careful_alloc.cc +++ b/persistent-data/space-maps/careful_alloc.cc @@ -19,6 +19,8 @@ #include "persistent-data/space-maps/careful_alloc.h" #include "persistent-data/space-maps/subtracting_span_iterator.h" +#include + //---------------------------------------------------------------- namespace { @@ -26,7 +28,7 @@ namespace { class sm_careful_alloc : public checked_space_map { public: - typedef std::shared_ptr ptr; + typedef boost::shared_ptr ptr; sm_careful_alloc(checked_space_map::ptr sm) : sm_(sm) { diff --git a/thin-provisioning/rmap_visitor.cc b/thin-provisioning/rmap_visitor.cc index 5df2229..64a3b8d 100644 --- a/thin-provisioning/rmap_visitor.cc +++ b/thin-provisioning/rmap_visitor.cc @@ -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::const_iterator it; + for (it = regions_.begin(); it != regions_.end(); ++it) + if (it->contains(b)) return true; return false; diff --git a/thin-provisioning/superblock.cc b/thin-provisioning/superblock.cc index bf9544b..130e70d 100644 --- a/thin-provisioning/superblock.cc +++ b/thin-provisioning/superblock.cc @@ -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(&r.data()); superblock_traits::unpack(*sbd, sb); return sb; diff --git a/thin-provisioning/thin_check.cc b/thin-provisioning/thin_check.cc index 0db0e63..517d85d 100644 --- a/thin-provisioning/thin_check.cc +++ b/thin-provisioning/thin_check.cc @@ -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); diff --git a/thin-provisioning/thin_rmap.cc b/thin-provisioning/thin_rmap.cc index ee24314..96f2a63 100644 --- a/thin-provisioning/thin_rmap.cc +++ b/thin-provisioning/thin_rmap.cc @@ -50,7 +50,9 @@ namespace { }; void display_rmap(ostream &out, vector const &rmap) { - for (rmap_region const &r : rmap) { + vector::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::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); diff --git a/unit-tests/btree_damage_visitor_t.cc b/unit-tests/btree_damage_visitor_t.cc index e33f9aa..175f0a7 100644 --- a/unit-tests/btree_damage_visitor_t.cc +++ b/unit-tests/btree_damage_visitor_t.cc @@ -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); diff --git a/unit-tests/cache_t.cc b/unit-tests/cache_t.cc index ecce000..aaf1257 100644 --- a/unit-tests/cache_t.cc +++ b/unit-tests/cache_t.cc @@ -19,6 +19,8 @@ #include "gmock/gmock.h" #include "persistent-data/cache.h" +#include + using namespace boost; using namespace base; using namespace std; @@ -53,7 +55,7 @@ namespace { struct SharedThingTraits { typedef unsigned key_type; - typedef std::shared_ptr value_type; + typedef boost::shared_ptr value_type; static key_type get_key(value_type const &p) { return p->key_; diff --git a/unit-tests/span_iterator_t.cc b/unit-tests/span_iterator_t.cc index c75640a..c0771d8 100644 --- a/unit-tests/span_iterator_t.cc +++ b/unit-tests/span_iterator_t.cc @@ -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)))); }