From: Sage Weil Date: Thu, 24 Aug 2017 18:30:50 +0000 (-0400) Subject: osd: remove support for pre-luminous past_intervals X-Git-Tag: v13.0.1~1107^2~8 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b8caf0139931823792150cdd7ca877edb549afe3;p=ceph.git osd: remove support for pre-luminous past_intervals Signed-off-by: Sage Weil --- diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 59f0740d8afd..f2c5125f47c6 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -8482,9 +8482,7 @@ void OSD::handle_pg_create(OpRequestRef op) bool mapped = osdmap->get_primary_shard(on, &pgid); assert(mapped); - PastIntervals pi( - osdmap->get_pools().at(pgid.pool()).ec_pool(), - *osdmap); + PastIntervals pi; pg_history_t history; build_initial_pg_history(pgid, created, ci->second, &history, &pi); @@ -9098,9 +9096,7 @@ void OSD::handle_pg_query(OpRequestRef op) it->second.epoch_sent, osdmap->get_epoch(), empty), - PastIntervals( - osdmap->get_pools().at(pgid.pool()).ec_pool(), - *osdmap))); + PastIntervals())); } } do_notifies(notify_list, osdmap); diff --git a/src/osd/PG.cc b/src/osd/PG.cc index bdbd4982d9d7..b9f62f415d03 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -299,9 +299,6 @@ PG::PG(OSDService *o, OSDMapRef curmap, pg_log(cct), pgmeta_oid(p.make_pgmeta_oid()), missing_loc(this), - past_intervals( - curmap->get_pools().at(p.pgid.pool()).ec_pool(), - *curmap), stat_queue_item(this), scrub_queued(false), recovery_queued(false), @@ -5697,7 +5694,6 @@ void PG::handle_advance_map( << dendl; update_osdmap_ref(osdmap); pool.update(osdmap); - past_intervals.update_type_from_map(pool.info.ec_pool(), *osdmap); if (cct->_conf->osd_debug_verify_cached_snaps) { interval_set actual_removed_snaps; const pg_pool_t *pi = osdmap->get_pg_pool(info.pgid.pool()); diff --git a/src/osd/osd_types.cc b/src/osd/osd_types.cc index 393cd7097d23..a4d7d3150401 100644 --- a/src/osd/osd_types.cc +++ b/src/osd/osd_types.cc @@ -2957,154 +2957,6 @@ void PastIntervals::pg_interval_t::generate_test_instances(list& WRITE_CLASS_ENCODER(PastIntervals::pg_interval_t) -class pi_simple_rep : public PastIntervals::interval_rep { - map interval_map; - - pi_simple_rep( - bool ec_pool, - std::list &&intervals) { - for (auto &&i: intervals) - add_interval(ec_pool, i); - } - -public: - pi_simple_rep() = default; - pi_simple_rep(const pi_simple_rep &) = default; - pi_simple_rep(pi_simple_rep &&) = default; - pi_simple_rep &operator=(pi_simple_rep &&) = default; - pi_simple_rep &operator=(const pi_simple_rep &) = default; - - size_t size() const override { return interval_map.size(); } - bool empty() const override { return interval_map.empty(); } - void clear() override { interval_map.clear(); } - pair get_bounds() const override { - auto iter = interval_map.begin(); - if (iter != interval_map.end()) { - auto riter = interval_map.rbegin(); - return make_pair( - iter->second.first, - riter->second.last + 1); - } else { - return make_pair(0, 0); - } - } - set get_all_participants( - bool ec_pool) const override { - set all_participants; - - // We need to decide who might have unfound objects that we need - auto p = interval_map.rbegin(); - auto end = interval_map.rend(); - for (; p != end; ++p) { - const PastIntervals::pg_interval_t &interval(p->second); - // If nothing changed, we don't care about this interval. - if (!interval.maybe_went_rw) - continue; - - int i = 0; - std::vector::const_iterator a = interval.acting.begin(); - std::vector::const_iterator a_end = interval.acting.end(); - for (; a != a_end; ++a, ++i) { - pg_shard_t shard(*a, ec_pool ? shard_id_t(i) : shard_id_t::NO_SHARD); - if (*a != CRUSH_ITEM_NONE) - all_participants.insert(shard); - } - } - return all_participants; - } - void add_interval( - bool ec_pool, - const PastIntervals::pg_interval_t &interval) override { - interval_map[interval.first] = interval; - } - unique_ptr clone() const override { - return unique_ptr(new pi_simple_rep(*this)); - } - ostream &print(ostream &out) const override { - return out << interval_map; - } - void encode(bufferlist &bl) const override { - ::encode(interval_map, bl); - } - void decode(bufferlist::iterator &bl) override { - ::decode(interval_map, bl); - } - void dump(Formatter *f) const override { - f->open_array_section("PastIntervals::compat_rep"); - for (auto &&i: interval_map) { - f->open_object_section("pg_interval_t"); - f->dump_int("epoch", i.first); - f->open_object_section("interval"); - i.second.dump(f); - f->close_section(); - f->close_section(); - } - f->close_section(); - } - bool is_classic() const override { - return true; - } - static void generate_test_instances(list &o) { - using ival = PastIntervals::pg_interval_t; - using ivallst = std::list; - o.push_back( - new pi_simple_rep( - true, ivallst - { ival{{0, 1, 2}, {0, 1, 2}, 10, 20, true, 0, 0} - , ival{{ 1, 2}, { 1, 2}, 21, 30, true, 1, 1} - , ival{{ 2}, { 2}, 31, 35, false, 2, 2} - , ival{{0, 2}, {0, 2}, 36, 50, true, 0, 0} - })); - o.push_back( - new pi_simple_rep( - false, ivallst - { ival{{0, 1, 2}, {0, 1, 2}, 10, 20, true, 0, 0} - , ival{{ 1, 2}, { 1, 2}, 20, 30, true, 1, 1} - , ival{{ 2}, { 2}, 31, 35, false, 2, 2} - , ival{{0, 2}, {0, 2}, 36, 50, true, 0, 0} - })); - o.push_back( - new pi_simple_rep( - true, ivallst - { ival{{2, 1, 0}, {2, 1, 0}, 10, 20, true, 1, 1} - , ival{{ 0, 2}, { 0, 2}, 21, 30, true, 0, 0} - , ival{{ 0, 2}, {2, 0}, 31, 35, true, 2, 2} - , ival{{ 0, 2}, { 0, 2}, 36, 50, true, 0, 0} - })); - return; - } - void iterate_mayberw_back_to( - bool ec_pool, - epoch_t les, - std::function &)> &&f) const override { - for (auto i = interval_map.rbegin(); i != interval_map.rend(); ++i) { - if (!i->second.maybe_went_rw) - continue; - if (i->second.last < les) - break; - set actingset; - for (unsigned j = 0; j < i->second.acting.size(); ++j) { - if (i->second.acting[j] == CRUSH_ITEM_NONE) - continue; - actingset.insert( - pg_shard_t( - i->second.acting[j], - ec_pool ? shard_id_t(j) : shard_id_t::NO_SHARD)); - } - f(i->second.first, actingset); - } - } - - bool has_full_intervals() const override { return true; } - void iterate_all_intervals( - std::function &&f - ) const override { - for (auto &&i: interval_map) { - f(i.second); - } - } - virtual ~pi_simple_rep() override {} -}; /** * pi_compact_rep @@ -3267,9 +3119,6 @@ public: f->close_section(); f->close_section(); } - bool is_classic() const override { - return false; - } static void generate_test_instances(list &o) { using ival = PastIntervals::pg_interval_t; using ivallst = std::list; @@ -3312,6 +3161,11 @@ public: }; WRITE_CLASS_ENCODER(pi_compact_rep) +PastIntervals::PastIntervals() +{ + past_intervals.reset(new pi_compact_rep); +} + PastIntervals::PastIntervals(const PastIntervals &rhs) : past_intervals(rhs.past_intervals ? rhs.past_intervals->clone() : @@ -3353,8 +3207,7 @@ void PastIntervals::decode(bufferlist::iterator &bl) case 0: break; case 1: - past_intervals.reset(new pi_simple_rep); - past_intervals->decode(bl); + assert(0 == "pi_simple_rep support removed post-luminous"); break; case 2: past_intervals.reset(new pi_compact_rep); @@ -3364,22 +3217,8 @@ void PastIntervals::decode(bufferlist::iterator &bl) DECODE_FINISH(bl); } -void PastIntervals::decode_classic(bufferlist::iterator &bl) -{ - past_intervals.reset(new pi_simple_rep); - past_intervals->decode(bl); -} - void PastIntervals::generate_test_instances(list &o) { - { - list simple; - pi_simple_rep::generate_test_instances(simple); - for (auto &&i: simple) { - // takes ownership of contents - o.push_back(new PastIntervals(i)); - } - } { list compact; pi_compact_rep::generate_test_instances(compact); @@ -3391,34 +3230,6 @@ void PastIntervals::generate_test_instances(list &o) return; } -void PastIntervals::update_type(bool ec_pool, bool compact) -{ - if (!compact) { - if (!past_intervals) { - past_intervals.reset(new pi_simple_rep); - } else { - // we never convert from compact back to classic - assert(is_classic()); - } - } else { - if (!past_intervals) { - past_intervals.reset(new pi_compact_rep); - } else if (is_classic()) { - auto old = std::move(past_intervals); - past_intervals.reset(new pi_compact_rep); - assert(old->has_full_intervals()); - old->iterate_all_intervals([&](const pg_interval_t &i) { - past_intervals->add_interval(ec_pool, i); - }); - } - } -} - -void PastIntervals::update_type_from_map(bool ec_pool, const OSDMap &osdmap) -{ - update_type(ec_pool, osdmap.require_osd_release >= CEPH_RELEASE_LUMINOUS); -} - bool PastIntervals::is_new_interval( int old_acting_primary, int new_acting_primary, diff --git a/src/osd/osd_types.h b/src/osd/osd_types.h index 43d9a98e7375..5465215e4431 100644 --- a/src/osd/osd_types.h +++ b/src/osd/osd_types.h @@ -2591,13 +2591,7 @@ public: static void generate_test_instances(list& o); }; - PastIntervals() = default; - PastIntervals(bool ec_pool, const OSDMap &osdmap) : PastIntervals() { - update_type_from_map(ec_pool, osdmap); - } - PastIntervals(bool ec_pool, bool compact) : PastIntervals() { - update_type(ec_pool, compact); - } + PastIntervals(); PastIntervals(PastIntervals &&rhs) = default; PastIntervals &operator=(PastIntervals &&rhs) = default; @@ -2618,7 +2612,6 @@ public: virtual void encode(bufferlist &bl) const = 0; virtual void decode(bufferlist::iterator &bl) = 0; virtual void dump(Formatter *f) const = 0; - virtual bool is_classic() const = 0; virtual void iterate_mayberw_back_to( bool ec_pool, epoch_t les, @@ -2633,7 +2626,6 @@ public: virtual ~interval_rep() {} }; - friend class pi_simple_rep; friend class pi_compact_rep; private: @@ -2647,15 +2639,10 @@ public: return past_intervals->add_interval(ec_pool, interval); } - bool is_classic() const { - assert(past_intervals); - return past_intervals->is_classic(); - } - void encode(bufferlist &bl) const { ENCODE_START(1, 1, bl); if (past_intervals) { - __u8 type = is_classic() ? 1 : 2; + __u8 type = 2; ::encode(type, bl); past_intervals->encode(bl); } else { @@ -2663,18 +2650,8 @@ public: } ENCODE_FINISH(bl); } - void encode_classic(bufferlist &bl) const { - if (past_intervals) { - assert(past_intervals->is_classic()); - past_intervals->encode(bl); - } else { - // it's a map<> - ::encode((uint32_t)0, bl); - } - } void decode(bufferlist::iterator &bl); - void decode_classic(bufferlist::iterator &bl); void dump(Formatter *f) const { assert(past_intervals); @@ -2871,9 +2848,6 @@ public: friend class PastIntervals; }; - void update_type(bool ec_pool, bool compact); - void update_type_from_map(bool ec_pool, const OSDMap &osdmap); - template PriorSet get_prior_set(Args&&... args) const { return PriorSet(*this, std::forward(args)...); diff --git a/src/test/osd/types.cc b/src/test/osd/types.cc index 2a26c395a70d..16154fb06cac 100644 --- a/src/test/osd/types.cc +++ b/src/test/osd/types.cc @@ -125,8 +125,6 @@ TEST(pg_interval_t, check_new_interval) { // iterate through all 4 combinations for (unsigned i = 0; i < 4; ++i) { - bool compact = i & 1; - bool ec_pool = i & 2; // // Create a situation where osdmaps are the same so that // each test case can diverge from it using minimal code. @@ -175,7 +173,7 @@ for (unsigned i = 0; i < 4; ++i) { // being split // { - PastIntervals past_intervals; past_intervals.update_type(ec_pool, compact); + PastIntervals past_intervals; ASSERT_TRUE(past_intervals.empty()); ASSERT_FALSE(PastIntervals::check_new_interval(old_primary, @@ -204,7 +202,7 @@ for (unsigned i = 0; i < 4; ++i) { int _new_primary = osd_id + 1; new_acting.push_back(_new_primary); - PastIntervals past_intervals; past_intervals.update_type(ec_pool, compact); + PastIntervals past_intervals; ASSERT_TRUE(past_intervals.empty()); ASSERT_TRUE(PastIntervals::check_new_interval(old_primary, @@ -233,7 +231,7 @@ for (unsigned i = 0; i < 4; ++i) { int _new_primary = osd_id + 1; new_up.push_back(_new_primary); - PastIntervals past_intervals; past_intervals.update_type(ec_pool, compact); + PastIntervals past_intervals; ASSERT_TRUE(past_intervals.empty()); ASSERT_TRUE(PastIntervals::check_new_interval(old_primary, @@ -260,7 +258,7 @@ for (unsigned i = 0; i < 4; ++i) { vector new_up; int _new_up_primary = osd_id + 1; - PastIntervals past_intervals; past_intervals.update_type(ec_pool, compact); + PastIntervals past_intervals; ASSERT_TRUE(past_intervals.empty()); ASSERT_TRUE(PastIntervals::check_new_interval(old_primary, @@ -294,7 +292,7 @@ for (unsigned i = 0; i < 4; ++i) { inc.new_pools[pool_id].set_pg_num(new_pg_num); osdmap->apply_incremental(inc); - PastIntervals past_intervals; past_intervals.update_type(ec_pool, compact); + PastIntervals past_intervals; ASSERT_TRUE(past_intervals.empty()); ASSERT_TRUE(PastIntervals::check_new_interval(old_primary, @@ -328,7 +326,7 @@ for (unsigned i = 0; i < 4; ++i) { inc.new_pools[pool_id].set_pg_num(pg_num); osdmap->apply_incremental(inc); - PastIntervals past_intervals; past_intervals.update_type(ec_pool, compact); + PastIntervals past_intervals; ASSERT_TRUE(past_intervals.empty()); ASSERT_TRUE(PastIntervals::check_new_interval(old_primary, @@ -355,7 +353,7 @@ for (unsigned i = 0; i < 4; ++i) { { vector old_acting; - PastIntervals past_intervals; past_intervals.update_type(ec_pool, compact); + PastIntervals past_intervals; ostringstream out; @@ -407,7 +405,7 @@ for (unsigned i = 0; i < 4; ++i) { ostringstream out; - PastIntervals past_intervals; past_intervals.update_type(ec_pool, compact); + PastIntervals past_intervals; ASSERT_TRUE(past_intervals.empty()); ASSERT_TRUE(PastIntervals::check_new_interval(old_primary, @@ -440,7 +438,7 @@ for (unsigned i = 0; i < 4; ++i) { ostringstream out; - PastIntervals past_intervals; past_intervals.update_type(ec_pool, compact); + PastIntervals past_intervals; ASSERT_TRUE(past_intervals.empty()); ASSERT_TRUE(PastIntervals::check_new_interval(old_primary, @@ -483,7 +481,7 @@ for (unsigned i = 0; i < 4; ++i) { ostringstream out; - PastIntervals past_intervals; past_intervals.update_type(ec_pool, compact); + PastIntervals past_intervals; ASSERT_TRUE(past_intervals.empty()); ASSERT_TRUE(PastIntervals::check_new_interval(old_primary, @@ -530,7 +528,7 @@ for (unsigned i = 0; i < 4; ++i) { ostringstream out; - PastIntervals past_intervals; past_intervals.update_type(ec_pool, compact); + PastIntervals past_intervals; ASSERT_TRUE(past_intervals.empty()); ASSERT_TRUE(PastIntervals::check_new_interval(old_primary, @@ -1579,21 +1577,10 @@ struct PITest : ::testing::Test { pg_down, new RequiredPredicate(rec_pred)); - PastIntervals simple, compact; - simple.update_type(ec_pool, false); - compact.update_type(ec_pool, true); + PastIntervals compact; for (auto &&i: intervals) { - simple.add_interval(ec_pool, i); compact.add_interval(ec_pool, i); } - PI::PriorSet simple_ps = simple.get_prior_set( - ec_pool, - last_epoch_started, - new RequiredPredicate(rec_pred), - map_pred, - up, - acting, - nullptr); PI::PriorSet compact_ps = compact.get_prior_set( ec_pool, last_epoch_started, @@ -1602,7 +1589,6 @@ struct PITest : ::testing::Test { up, acting, nullptr); - ASSERT_EQ(correct, simple_ps); ASSERT_EQ(correct, compact_ps); } }; diff --git a/src/tools/RadosDump.h b/src/tools/RadosDump.h index 6ad43f7aa63b..450ad7a7d90f 100644 --- a/src/tools/RadosDump.h +++ b/src/tools/RadosDump.h @@ -330,7 +330,7 @@ struct metadata_section { if (struct_v >= 6) { ::decode(past_intervals, bl); } else if (struct_v > 1) { - past_intervals.decode_classic(bl); + cout << "NOTICE: Older export with classic past_intervals" << std::endl; } else { cout << "NOTICE: Older export without past_intervals" << std::endl; }