]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/osd: convert PG::wait_for_active to a blocking_future 31202/head
authorSamuel Just <sjust@redhat.com>
Wed, 16 Oct 2019 18:12:12 +0000 (11:12 -0700)
committerSamuel Just <sjust@redhat.com>
Tue, 3 Dec 2019 05:35:36 +0000 (21:35 -0800)
Signed-off-by: Samuel Just <sjust@redhat.com>
src/crimson/osd/osd_operations/client_request.cc
src/crimson/osd/pg.cc
src/crimson/osd/pg.h

index 320de1469478d158feeb5bf8c7fa1c596fbb689c..3661d04273434b0b98ded02ba82643d44d810553 100644 (file)
@@ -76,7 +76,7 @@ seastar::future<> ClientRequest::start()
            return with_blocking_future(
              handle.enter(pp(pg).wait_for_active));
          }).then([this, &pg]() mutable {
-           return pg.wait_for_active();
+           return with_blocking_future(pg.wait_for_active_blocker.wait());
          }).then([this, &pg]() mutable {
            if (m->finish_decode()) {
              m->clear_payload();
index 9db75b01053636a7926c399ecaf4c3126779803b..01cad4a2d2e9a97e432dd91e00bfce6cfb02343f 100644 (file)
@@ -110,7 +110,8 @@ PG::PG(
        osdmap->get_pool_name(pgid.pool())),
       osdmap,
       this,
-      this)
+      this),
+    wait_for_active_blocker(this)
 {
   peering_state.set_backend_predicates(
     new ReadablePredicate(pg_whoami),
@@ -200,8 +201,7 @@ void PG::on_activate(interval_set<snapid_t>)
 
 void PG::on_activate_complete()
 {
-  active_promise.set_value();
-  active_promise = {};
+  wait_for_active_blocker.on_active();
 
   if (peering_state.needs_recovery()) {
     shard_services.start_operation<LocalPeeringEvent>(
@@ -402,13 +402,23 @@ std::ostream& operator<<(std::ostream& os, const PG& pg)
   return os;
 }
 
-seastar::future<> PG::wait_for_active()
+void PG::WaitForActiveBlocker::dump_detail(Formatter *f) const
 {
-  logger().debug("wait_for_active: {}", peering_state.get_pg_state_string());
-  if (peering_state.is_active()) {
-    return seastar::now();
+  f->dump_stream("pgid") << pg->pgid;
+}
+
+void PG::WaitForActiveBlocker::on_active()
+{
+  p.set_value();
+  p = {};
+}
+
+blocking_future<> PG::WaitForActiveBlocker::wait()
+{
+  if (pg->peering_state.is_active()) {
+    return make_blocking_future(seastar::now());
   } else {
-    return active_promise.get_shared_future();
+    return make_blocking_future(p.get_shared_future());
   }
 }
 
index fd6c90dbadf93d2ca6abe85f105bee8c34dfe028..462d77a771b66ae1121f5527755ac5663aafc3c7 100644 (file)
@@ -515,8 +515,22 @@ private:
   PeeringState peering_state;
   eversion_t projected_last_update;
 
-  seastar::shared_promise<> active_promise;
-  seastar::future<> wait_for_active();
+  class WaitForActiveBlocker : public BlockerT<WaitForActiveBlocker> {
+    PG *pg;
+
+    const spg_t pgid;
+    seastar::shared_promise<> p;
+
+  protected:
+    void dump_detail(Formatter *f) const;
+
+  public:
+    static constexpr const char *type_name = "WaitForActiveBlocker";
+
+    WaitForActiveBlocker(PG *pg) : pg(pg) {}
+    void on_active();
+    blocking_future<> wait();
+  } wait_for_active_blocker;
 
   friend std::ostream& operator<<(std::ostream&, const PG& pg);
   friend class ClientRequest;