]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/osd/pg: wait until pg is active
authorKefu Chai <kchai@redhat.com>
Wed, 13 Mar 2019 04:44:18 +0000 (12:44 +0800)
committerKefu Chai <kchai@redhat.com>
Mon, 25 Mar 2019 15:34:00 +0000 (23:34 +0800)
hold i/o request until pg is active

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

index d43ac29d6f989d4551effdba0c94fc5eb33fccc9..2997305acbcffbf485af0c764e935d660ba3390d 100644 (file)
@@ -944,9 +944,24 @@ seastar::future<> PG::share_pg_info()
     });
 }
 
+seastar::future<> PG::wait_for_active()
+{
+  logger().info("wait_for_active: {}", pg_state_string(info.stats.state));
+  if (test_state(PG_STATE_ACTIVE)) {
+    return seastar::now();
+  } else {
+    if (!active_promise) {
+      active_promise = seastar::shared_promise<>();
+    }
+    return active_promise->get_shared_future();
+  }
+}
+
 seastar::future<> PG::handle_op(ceph::net::ConnectionRef conn,
                                 Ref<MOSDOp> m)
 {
-  // todo
-  return seastar::now();
+  return wait_for_active().then([conn, m, this] {
+    // todo
+    return seastar::now();
+  });
 }
index ae1aa70c49feeb64216acc5b45c2eaca683488a0..06a186a865c16f790d1e783d7dca8b7e2e4b3f8c 100644 (file)
@@ -151,6 +151,9 @@ private:
   pg_shard_set_t acting_recovery_backfill;
   std::vector<int> want_acting;
 
+  seastar::future<> wait_for_active();
+  std::optional<seastar::shared_promise<>> active_promise;
+
   cached_map_t osdmap;
   ceph::net::Messenger& msgr;
 };