]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson: add recovery operations oriented request ---- "RecoverySubRequest"
authorXuehan Xu <xxhdx1985126@163.com>
Wed, 4 Mar 2020 09:57:29 +0000 (17:57 +0800)
committerXuehan Xu <xxhdx1985126@163.com>
Sun, 26 Apr 2020 07:46:35 +0000 (15:46 +0800)
Signed-off-by: Xuehan Xu <xxhdx1985126@163.com>
src/crimson/osd/CMakeLists.txt
src/crimson/osd/osd_operation.h
src/crimson/osd/osd_operations/recovery_subrequest.cc [new file with mode: 0644]
src/crimson/osd/osd_operations/recovery_subrequest.h [new file with mode: 0644]

index ff5ba3aec6caaf85925dd1d9830b04cf3fb403f6..02c0a5678c7f7f3c887cb35283b871af85deab17 100644 (file)
@@ -19,6 +19,7 @@ add_executable(crimson-osd
   osd_operations/pg_advance_map.cc
   osd_operations/replicated_request.cc
   osd_operations/background_recovery.cc
+  osd_operations/recovery_subrequest.cc
   pg_recovery.cc
   recovery_backend.cc
   replicated_recovery_backend.cc
index 6e368384d576c966361fc5353a5fc1ccfd654af8..7fe092f2e92c7b5ba2c2a0934b7322398d5d16a3 100644 (file)
@@ -30,6 +30,7 @@ enum class OperationTypeCode {
   pg_creation,
   replicated_request,
   background_recovery,
+  background_recovery_sub,
   last_op
 };
 
@@ -41,6 +42,7 @@ static constexpr const char* const OP_NAMES[] = {
   "pg_creation",
   "replicated_request",
   "background_recovery",
+  "background_recovery_sub",
 };
 
 // prevent the addition of OperationTypeCode-s with no matching OP_NAMES entry:
diff --git a/src/crimson/osd/osd_operations/recovery_subrequest.cc b/src/crimson/osd/osd_operations/recovery_subrequest.cc
new file mode 100644 (file)
index 0000000..820c7be
--- /dev/null
@@ -0,0 +1,29 @@
+#include <fmt/format.h>
+#include <fmt/ostream.h>
+
+#include "crimson/osd/osd_operations/recovery_subrequest.h"
+
+namespace {
+  seastar::logger& logger() {
+    return crimson::get_logger(ceph_subsys_osd);
+  }
+}
+
+namespace crimson::osd {
+
+seastar::future<> RecoverySubRequest::start() {
+  logger().debug("{}: start", *this);
+
+  IRef opref = this;
+  return with_blocking_future(osd.osdmap_gate.wait_for_map(m->get_min_epoch()))
+  .then([this] (epoch_t epoch) {
+    return with_blocking_future(osd.wait_for_pg(m->get_spg()));
+  }).then([this, opref=std::move(opref)] (Ref<PG> pgref) {
+    return seastar::do_with(std::move(pgref), std::move(opref),
+      [this](auto& pgref, auto& opref) {
+      return pgref->get_recovery_backend()->handle_recovery_op(m);
+    });
+  });
+}
+
+}
diff --git a/src/crimson/osd/osd_operations/recovery_subrequest.h b/src/crimson/osd/osd_operations/recovery_subrequest.h
new file mode 100644 (file)
index 0000000..b151e5c
--- /dev/null
@@ -0,0 +1,45 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#pragma once
+
+#include "osd/osd_op_util.h"
+#include "crimson/net/Connection.h"
+#include "crimson/osd/osd_operation.h"
+#include "crimson/osd/osd.h"
+#include "crimson/common/type_helpers.h"
+#include "messages/MOSDPGPull.h"
+#include "messages/MOSDPGPush.h"
+#include "messages/MOSDPGPushReply.h"
+#include "messages/MOSDPGRecoveryDelete.h"
+#include "messages/MOSDPGRecoveryDeleteReply.h"
+
+namespace crimson::osd {
+
+class OSD;
+class PG;
+
+class RecoverySubRequest final : public OperationT<RecoverySubRequest> {
+public:
+  static constexpr OperationTypeCode type = OperationTypeCode::background_recovery_sub;
+
+  RecoverySubRequest(OSD &osd, crimson::net::ConnectionRef conn, Ref<MOSDFastDispatchOp>&& m)
+    : osd(osd), conn(conn), m(m) {}
+
+  void print(std::ostream& out) const final
+  {
+    out << *m;
+  }
+
+  void dump_detail(Formatter *f) const final
+  {
+  }
+
+  seastar::future<> start();
+private:
+  OSD& osd;
+  crimson::net::ConnectionRef conn;
+  Ref<MOSDFastDispatchOp> m;
+};
+
+}