]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/osd/pg: add peer_activated
authorKefu Chai <kchai@redhat.com>
Tue, 5 Mar 2019 12:55:45 +0000 (20:55 +0800)
committerKefu Chai <kchai@redhat.com>
Fri, 22 Mar 2019 05:21:33 +0000 (13:21 +0800)
add facilities for updating peer_activated. it is used for tracking the
peers has activated and committed. once all of them ack the activation
proposed by primary, the PG is considered activated.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/crimson/osd/pg.cc
src/crimson/osd/pg.h

index 7310b49314b49b78241e952cc642db882e7f699d..bc53e4c995d2fba0c9f5cf8fe8239fe1f302e6b2 100644 (file)
@@ -524,6 +524,25 @@ pg_notify_t PG::get_notify(epoch_t query_epoch) const
                      info};
 }
 
+bool PG::is_last_activated_peer(pg_shard_t peer)
+{
+  if (!acting_recovery_backfill.count(peer))
+    return false;
+  if (!peer_activated.insert(peer).second)
+    return false;
+  logger().info("peer osd.{} activated and committed", peer);
+  return peer_activated.size() == acting_recovery_backfill.size();
+}
+
+
+void PG::clear_primary_state()
+{
+  peer_info.clear();
+  want_acting.clear();
+  need_up_thru = 0;
+  peer_activated.clear();
+}
+
 seastar::future<> PG::do_peering_event(std::unique_ptr<PGPeeringEvent> evt)
 {
   // todo
index f39e806e0c36c805df1bb1678d048f85bdf98bc3..1f3ec6dc0afbcc55ceb29860b356b9f62324388e 100644 (file)
@@ -80,6 +80,9 @@ public:
   // peering/recovery
   bool should_send_notify() const;
   pg_notify_t get_notify(epoch_t query_epoch) const;
+  bool is_last_activated_peer(pg_shard_t peer);
+  void clear_primary_state();
+
   seastar::future<> do_peering_event(std::unique_ptr<PGPeeringEvent> evt);
   seastar::future<> handle_advance_map(cached_map_t next_map);
   seastar::future<> handle_activate_map();
@@ -99,8 +102,10 @@ private:
 
   bool should_notify_primary = false;
 
+  using pg_shard_set_t = std::set<pg_shard_t>;
   // peer_info    -- projected (updates _before_ replicas ack)
   peer_info_t peer_info; //< info from peers (stray or prior)
+  pg_shard_set_t peer_activated;
 
   //< pg state
   pg_info_t info;
@@ -108,7 +113,6 @@ private:
   pg_info_t last_written_info;
   PastIntervals past_intervals;
   // primary state
-  using pg_shard_set_t = std::set<pg_shard_t>;
   pg_shard_t primary, up_primary;
   std::vector<int> acting, up;
   pg_shard_set_t actingset, upset;