]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
crimson/osd: apply the errorator along execute_osd_op() path.
authorRadoslaw Zarzynski <rzarzyns@redhat.com>
Mon, 23 Sep 2019 15:45:10 +0000 (17:45 +0200)
committerRadoslaw Zarzynski <rzarzyns@redhat.com>
Wed, 20 Nov 2019 19:37:42 +0000 (20:37 +0100)
Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
src/crimson/osd/exceptions.h
src/crimson/osd/objclass.cc
src/crimson/osd/ops_executer.cc
src/crimson/osd/ops_executer.h
src/crimson/osd/pg.cc

index d1b52333850da18f98d6aacb35d5ab0ed999dc91..1bd1a6a09a0c102b69d30dd4f01d1e239ae9d5b0 100644 (file)
@@ -6,6 +6,8 @@
 #include <exception>
 #include <system_error>
 
+#include "crimson/common/errorator.h"
+
 namespace crimson::osd {
 class error : private std::system_error {
 public:
index 9b61edcb573d172f6ece25af14d1c7d206346591..ef9336da1d7c31146d219453efc67d0101b3d819 100644 (file)
 
 static inline int execute_osd_op(cls_method_context_t hctx, OSDOp& op)
 {
-  try {
-    reinterpret_cast<ceph::osd::OpsExecuter*>(hctx)->execute_osd_op(op).get();
-    return 0;
-  } catch (crimson::osd::error& e) {
-    return -e.code().value();
-  }
+  // we can expect the memory under `ret` will be still fine after
+  // executing the osd op as we're running inside `seastar::thread`
+  // created for us by `seastar::async` in `::do_op_call()`.
+  int ret = 0;
+  using osd_op_errorator = crimson::osd::OpsExecuter::osd_op_errorator;
+  reinterpret_cast<crimson::osd::OpsExecuter*>(hctx)->execute_osd_op(op).safe_then(
+    [] {
+      // TODO: handle it nicer with `::handle_error()` in errorator
+      return seastar::now();
+    }, osd_op_errorator::all_same_way([&ret] (const std::error_code& err) {
+      assert(err.value() > 0);
+      ret = -err.value();
+      return seastar::now();
+    })).get(); // we're blocking here which requires `seastar::thread`.
+  return ret;
 }
 
 int cls_call(cls_method_context_t hctx, const char *cls, const char *method,
index 28006cde05da253fe4eb09dd091cc6a047208dda..9c416786fa4b9ab1909215e04f8ab95ef13d8f0a 100644 (file)
@@ -106,11 +106,7 @@ OpsExecuter::call_errorator::future<> OpsExecuter::do_op_call(OSDOp& osd_op)
       }
       if (ret < 0) {
         return call_errorator::make_plain_exception_future<>(
-<<<<<<< HEAD
-          crimson::stateful_errint{ ret });
-=======
-          ceph::stateful_ec{ std::error_code(-ret, std::generic_category()) });
->>>>>>> 520100f... crimson: use std::error_code instances for errors.
+          crimson::stateful_ec{ std::error_code(-ret, std::generic_category()) });
       }
       return seastar::now();
     }
@@ -358,7 +354,7 @@ static seastar::future<> do_pgnls_filtered(
   });
 }
 
-seastar::future<>
+OpsExecuter::osd_op_errorator::future<>
 OpsExecuter::execute_osd_op(OSDOp& osd_op)
 {
   // TODO: dispatch via call table?
@@ -380,20 +376,7 @@ OpsExecuter::execute_osd_op(OSDOp& osd_op)
           osd_op.rval = bl.length();
           osd_op.outdata = std::move(bl);
           return seastar::now();
-        },
-        // TODO: move this error handling do PG::do_osd_ops().
-        crimson::ct_error::input_output_error::handle([] {
-          throw ceph::osd::input_output_error{};
-        }),
-        crimson::ct_error::object_corrupted::handle([] {
-          throw ceph::osd::object_corrupted{};
-        }),
-        crimson::ct_error::enoent::handle([] {
-          throw ceph::osd::object_not_found{};
-        }),
-        crimson::ct_error::enodata::handle([] {
-          throw ceph::osd::no_message_available{};
-        }));
+        }, read_errorator::pass_further{});
     });
   case CEPH_OSD_OP_GETXATTR:
     return do_read_op([&osd_op] (auto& backend, const auto& os) {
@@ -422,13 +405,7 @@ OpsExecuter::execute_osd_op(OSDOp& osd_op)
       return backend.remove(os, txn);
     });
   case CEPH_OSD_OP_CALL:
-    return this->do_op_call(osd_op).safe_then(
-      [] {
-        return seastar::now();
-      }, call_errorator::all_same_way([] (const std::error_code& err) {
-        assert(err.value() > 0);
-        throw crimson::osd::make_error(err.value());
-      }));
+    return this->do_op_call(osd_op);
   case CEPH_OSD_OP_STAT:
     // note: stat does not require RD
     return do_const_op([&osd_op] (/* const */auto& backend, const auto& os) {
index 483e1c39a96ca46fc5a8257092e09208ce738dab..53a14bcb35c90f75ed4b96117e9a8be6ac066321 100644 (file)
@@ -104,6 +104,9 @@ class OpsExecuter {
     throw crimson::osd::operation_not_supported();
   }
 
+  using read_errorator = PGBackend::read_errorator;
+  using get_attr_errorator = PGBackend::get_attr_errorator;
+
 public:
   OpsExecuter(PGBackend::cached_os_t os, PG& pg, Ref<MOSDOp> msg)
     : os(std::move(os)),
@@ -115,7 +118,11 @@ public:
     : OpsExecuter{PGBackend::cached_os_t{}, pg, std::move(msg)}
   {}
 
-  seastar::future<> execute_osd_op(class OSDOp& osd_op);
+  using osd_op_errorator = crimson::compound_errorator_t<
+    call_errorator,
+    read_errorator,
+    get_attr_errorator>;
+  osd_op_errorator::future<> execute_osd_op(class OSDOp& osd_op);
   seastar::future<> execute_pg_op(class OSDOp& osd_op);
 
   template <typename Func>
index 0a958ee64e62842421068a691d6401410b5770c5..53849847779707f0a4d327af7ab3ef32016873dd 100644 (file)
@@ -442,7 +442,13 @@ seastar::future<Ref<MOSDOpReply>> PG::do_osd_ops(Ref<MOSDOp> m)
                             [this, m] (auto& ox) {
       return seastar::do_for_each(m->ops, [this, &ox](OSDOp& osd_op) {
         logger().debug("will be handling op {}", ceph_osd_op_name(osd_op.op.op));
-        return ox.execute_osd_op(osd_op);
+        return ox.execute_osd_op(osd_op).safe_then(
+          [] {
+            return seastar::now();
+          }, OpsExecuter::osd_op_errorator::all_same_way([] (const std::error_code& err) {
+            assert(err.value() > 0);
+            throw ceph::osd::make_error(err.value());
+          }));
       }).then([this, m, &ox] {
         logger().debug("all operations have been executed successfully");
         return std::move(ox).submit_changes([this, m] (auto&& txn, auto&& os) {