]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/osd/backfill_state: consider backfills as complete when all
authorXuehan Xu <xuxuehan@qianxin.com>
Fri, 25 Aug 2023 06:42:52 +0000 (14:42 +0800)
committerXuehan Xu <xxhdx1985126@gmail.com>
Mon, 28 Aug 2023 03:13:50 +0000 (11:13 +0800)
replicas have acknowledged the finish of the backfill

Signed-off-by: Xuehan Xu <xuxuehan@qianxin.com>
src/crimson/osd/backfill_state.cc
src/crimson/osd/backfill_state.h
src/crimson/osd/pg_recovery.h
src/crimson/osd/recovery_backend.cc
src/test/crimson/test_backfill.cc

index 46a270ffe54db9b821c9bf4020f2f56a3be3981a..f5f9eb37f95497da5dff183bce13b5a5b991b9bc 100644 (file)
@@ -73,6 +73,8 @@ BackfillState::Initial::Initial(my_context ctx)
   }
   ceph_assert(peering_state().get_backfill_targets().size());
   ceph_assert(!backfill_state().last_backfill_started.is_max());
+  backfill_state().replicas_in_backfill =
+    peering_state().get_backfill_targets().size();
 }
 
 boost::statechart::result
@@ -470,8 +472,6 @@ BackfillState::Waiting::react(ObjectPushed evt)
                                backfill_state().backfill_info,
                                backfill_state().peer_backfill_info)) {
     return transit<Enqueuing>();
-  } else if (backfill_state().progress_tracker->tracked_objects_completed()) {
-    return transit<Done>();
   } else {
     // we still have something to wait on
     logger().debug("Waiting::react() on ObjectPushed; still waiting");
index 4bd2991fb62c3955354b23b453c368461fe71584..8c441f01abb14e5b1ae98e0af70eb4b30afc74ac 100644 (file)
@@ -55,6 +55,9 @@ struct BackfillState {
   struct Triggered : sc::event<Triggered> {
   };
 
+  struct RequestDone : sc::event<RequestDone> {
+  };
+
 private:
   // internal events
   struct RequestPrimaryScanning : sc::event<RequestPrimaryScanning> {
@@ -66,9 +69,6 @@ private:
   struct RequestWaiting : sc::event<RequestWaiting> {
   };
 
-  struct RequestDone : sc::event<RequestDone> {
-  };
-
   class ProgressTracker;
 
 public:
@@ -149,7 +149,6 @@ public:
       sc::transition<RequestPrimaryScanning, PrimaryScanning>,
       sc::transition<RequestReplicasScanning, ReplicasScanning>,
       sc::transition<RequestWaiting, Waiting>,
-      sc::transition<RequestDone, Done>,
       sc::transition<sc::event_base, Crashed>>;
     explicit Enqueuing(my_context);
 
@@ -206,6 +205,7 @@ public:
     using reactions = boost::mpl::list<
       sc::custom_reaction<ObjectPushed>,
       sc::custom_reaction<PrimaryScanned>,
+      sc::transition<RequestDone, Done>,
       sc::transition<sc::event_base, Crashed>>;
     explicit PrimaryScanning(my_context);
     sc::result react(ObjectPushed);
@@ -218,6 +218,7 @@ public:
     using reactions = boost::mpl::list<
       sc::custom_reaction<ObjectPushed>,
       sc::custom_reaction<ReplicaScanned>,
+      sc::transition<RequestDone, Done>,
       sc::transition<sc::event_base, Crashed>>;
     explicit ReplicasScanning(my_context);
     // collect scanning result; if all results are collected, transition
@@ -241,6 +242,7 @@ public:
                    StateHelper<Waiting> {
     using reactions = boost::mpl::list<
       sc::custom_reaction<ObjectPushed>,
+      sc::transition<RequestDone, Done>,
       sc::transition<sc::event_base, Crashed>>;
     explicit Waiting(my_context);
     sc::result react(ObjectPushed);
@@ -266,12 +268,21 @@ public:
   hobject_t get_last_backfill_started() const {
     return last_backfill_started;
   }
+
+  void backfill_target_done() {
+    ceph_assert(replicas_in_backfill > 0);
+    replicas_in_backfill--;
+    if (!replicas_in_backfill) {
+      backfill_machine.process_event(RequestDone{});
+    }
+  }
 private:
   hobject_t last_backfill_started;
   BackfillInterval backfill_info;
   std::map<pg_shard_t, BackfillInterval> peer_backfill_info;
   BackfillMachine backfill_machine;
   std::unique_ptr<ProgressTracker> progress_tracker;
+  size_t replicas_in_backfill = 0;
 };
 
 // BackfillListener -- an interface used by the backfill FSM to request
index 719d0ad2d34c8a08e5e7118bf9348ff661d5e703..a23f97004e20ac7eddba18cd8e26c55a66fc3973 100644 (file)
@@ -36,6 +36,9 @@ public:
   void on_backfill_reserved();
   void dispatch_backfill_event(
     boost::intrusive_ptr<const boost::statechart::event_base> evt);
+  void backfill_target_finished() {
+    backfill_state->backfill_target_done();
+  }
 
   seastar::future<> stop() { return seastar::now(); }
 private:
index b5394bfdc485dfc63b21e28cb7fc7cbd780a56e1..9d4805370898744ae33edc259fd6024789868153 100644 (file)
@@ -117,8 +117,8 @@ RecoveryBackend::handle_backfill_finish_ack(
   logger().debug("{}", __func__);
   ceph_assert(pg.is_primary());
   ceph_assert(crimson::common::local_conf()->osd_kill_backfill_at != 3);
-  // TODO:
-  // finish_recovery_op(hobject_t::get_max());
+  auto recovery_handler = pg.get_recovery_handler();
+  recovery_handler->backfill_target_finished();
   return seastar::now();
 }
 
index 6d7d62ce5be4b567bbd64c0160afe566ef4a23b8..1ce9b42ad381fcd6512d20e989673f770d5e4798 100644 (file)
@@ -1,3 +1,6 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
 #include <algorithm>
 #include <cstdlib>
 #include <deque>
@@ -308,6 +311,9 @@ void BackfillFixture::maybe_flush()
 void BackfillFixture::update_peers_last_backfill(
   const hobject_t& new_last_backfill)
 {
+  if (new_last_backfill.is_max()) {
+    schedule_event(crimson::osd::BackfillState::RequestDone{});
+  }
 }
 
 bool BackfillFixture::budget_available() const
@@ -355,6 +361,7 @@ TEST(backfill, same_primary_same_replica)
     reference_store.objs
   ).get_result();
 
+  cluster_fixture.next_round();
   cluster_fixture.next_round();
   EXPECT_CALL(cluster_fixture, backfilled);
   cluster_fixture.next_round();
@@ -377,6 +384,7 @@ TEST(backfill, one_empty_replica)
   cluster_fixture.next_round();
   cluster_fixture.next_round();
   cluster_fixture.next_round(2);
+  cluster_fixture.next_round();
   EXPECT_CALL(cluster_fixture, backfilled);
   cluster_fixture.next_round();
   EXPECT_TRUE(cluster_fixture.all_stores_look_like(reference_store));