]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: remove support for pre-luminous past_intervals
authorSage Weil <sage@redhat.com>
Thu, 24 Aug 2017 18:30:50 +0000 (14:30 -0400)
committerSage Weil <sage@redhat.com>
Tue, 29 Aug 2017 03:10:32 +0000 (23:10 -0400)
Signed-off-by: Sage Weil <sage@redhat.com>
src/osd/OSD.cc
src/osd/PG.cc
src/osd/osd_types.cc
src/osd/osd_types.h
src/test/osd/types.cc
src/tools/RadosDump.h

index 59f0740d8afdffed249554c521c7fefae88f375a..f2c5125f47c6addf6235367255de36f5b4c89528 100644 (file)
@@ -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);
index bdbd4982d9d724dfd6a3cb64753438ada79da874..b9f62f415d033be5305195bf4787f9e0c22fedc0 100644 (file)
@@ -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<snapid_t> actual_removed_snaps;
     const pg_pool_t *pi = osdmap->get_pg_pool(info.pgid.pool());
index 393cd7097d23fdb9483949fd2571e506fc31f629..a4d7d31504010ae8901be6719c35e633f262f6a1 100644 (file)
@@ -2957,154 +2957,6 @@ void PastIntervals::pg_interval_t::generate_test_instances(list<pg_interval_t*>&
 
 WRITE_CLASS_ENCODER(PastIntervals::pg_interval_t)
 
-class pi_simple_rep : public PastIntervals::interval_rep {
-  map<epoch_t, PastIntervals::pg_interval_t> interval_map;
-
-  pi_simple_rep(
-    bool ec_pool,
-    std::list<PastIntervals::pg_interval_t> &&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<epoch_t, epoch_t> 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<pg_shard_t> get_all_participants(
-    bool ec_pool) const override {
-    set<pg_shard_t> 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<int>::const_iterator a = interval.acting.begin();
-      std::vector<int>::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<PastIntervals::interval_rep> clone() const override {
-    return unique_ptr<PastIntervals::interval_rep>(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<pi_simple_rep*> &o) {
-    using ival = PastIntervals::pg_interval_t;
-    using ivallst = std::list<ival>;
-    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<void(epoch_t, const set<pg_shard_t> &)> &&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<pg_shard_t> 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<void(const PastIntervals::pg_interval_t &)> &&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<pi_compact_rep*> &o) {
     using ival = PastIntervals::pg_interval_t;
     using ivallst = std::list<ival>;
@@ -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<PastIntervals*> &o)
 {
-  {
-    list<pi_simple_rep *> simple;
-    pi_simple_rep::generate_test_instances(simple);
-    for (auto &&i: simple) {
-      // takes ownership of contents
-      o.push_back(new PastIntervals(i));
-    }
-  }
   {
     list<pi_compact_rep *> compact;
     pi_compact_rep::generate_test_instances(compact);
@@ -3391,34 +3230,6 @@ void PastIntervals::generate_test_instances(list<PastIntervals*> &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,
index 43d9a98e73753ea8bb14c45ba32f01ea19a24d0b..5465215e44316ed65f0942af16cef408d31f92d2 100644 (file)
@@ -2591,13 +2591,7 @@ public:
     static void generate_test_instances(list<pg_interval_t*>& 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 <typename... Args>
   PriorSet get_prior_set(Args&&... args) const {
     return PriorSet(*this, std::forward<Args>(args)...);
index 2a26c395a70df2d22ebdd1cea4ea5ebd298d9a86..16154fb06cac0b149d28200a271257f2227939f7 100644 (file)
@@ -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<int> 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<int> 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);
   }
 };
index 6ad43f7aa63b0a48791ce89e3a39f8bb68080a8d..450ad7a7d90f5b60c71ed7d8e5a17cf34f0d9549 100644 (file)
@@ -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;
     }