]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
crimson/osd: reply if pg is absent when handling MQuery
authorKefu Chai <kchai@redhat.com>
Mon, 16 Sep 2019 10:48:23 +0000 (18:48 +0800)
committerKefu Chai <kchai@redhat.com>
Mon, 16 Sep 2019 11:03:42 +0000 (19:03 +0800)
in previous commit, the support of `MOSDPGQuery` was dropped. but
if we want to handle `MOSDPGQuery2` properly, we should take
`on_pg_absent()` into consideration when handling `MOSDPGQuery2`.

in this change, we handle `MOSDPGQuery2` by checking the boost event
against `MQuery`, so we don't need to create a new class derived from
`RemotePeeringEvent` for specializing the behavior.

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

index 79584fe4e2397e8215b2f38f6c79c045f19e1589..67a3c38a96364826bd30b7065c94a57973797b13 100644 (file)
@@ -3,9 +3,11 @@
 
 #include <seastar/core/future.hh>
 
+#include "messages/MOSDPGLog.h"
+
+#include "common/Formatter.h"
 #include "crimson/osd/pg.h"
 #include "crimson/osd/osd.h"
-#include "common/Formatter.h"
 #include "crimson/osd/osd_operations/peering_event.h"
 #include "crimson/osd/osd_connection_priv.h"
 
@@ -94,7 +96,40 @@ RemotePeeringEvent::ConnectionPipeline &RemotePeeringEvent::cp()
   return get_osd_priv(conn.get()).peering_request_conn_pipeline;
 }
 
-seastar::future<Ref<PG>> RemotePeeringEvent::get_pg() {
+void RemotePeeringEvent::on_pg_absent()
+{
+  if (auto& e = get_event().get_event();
+      e.dynamic_type() == MQuery::static_type()) {
+    const auto map_epoch =
+      shard_services.get_osdmap_service().get_map()->get_epoch();
+    const auto& q = static_cast<const MQuery&>(e);
+    const pg_info_t empty{spg_t{pgid.pgid, q.query.to}};
+    if (q.query.type == q.query.LOG ||
+       q.query.type == q.query.FULLLOG)  {
+      auto m = new MOSDPGLog{q.query.from, q.query.to,
+                            map_epoch, empty,
+                            q.query.epoch_sent};
+      ctx.send_osd_message(q.from.osd, m);
+    } else {
+      ctx.send_notify(q.from.osd, {q.query.from, q.query.to,
+                                  q.query.epoch_sent,
+                                  map_epoch, empty,
+                                  PastIntervals{}});
+    }
+  }
+}
+
+seastar::future<> RemotePeeringEvent::complete_rctx(Ref<PG> pg)
+{
+  if (pg) {
+    return PeeringEvent::complete_rctx(pg);
+  } else {
+    return shard_services.dispatch_context_messages(std::move(ctx));
+  }
+}
+
+seastar::future<Ref<PG>> RemotePeeringEvent::get_pg()
+{
   return with_blocking_future(
     handle.enter(cp().await_map)
   ).then([this] {
index 7f32953a9e928eb350f46349376f6b2ab033e6ce..1beb5f2612b96186b93c7471a931be2ccebdc7dc 100644 (file)
@@ -81,6 +81,8 @@ protected:
   OSD &osd;
   ceph::net::ConnectionRef conn;
 
+  void on_pg_absent() final;
+  seastar::future<> complete_rctx(Ref<PG> pg) override;
   seastar::future<Ref<PG>> get_pg() final;
 
 public: