]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
crimson/osd: exceptions derive from std::system_error now.
authorRadoslaw Zarzynski <rzarzyns@redhat.com>
Wed, 31 Jul 2019 17:38:30 +0000 (19:38 +0200)
committerRadoslaw Zarzynski <rzarzyns@redhat.com>
Fri, 23 Aug 2019 23:27:44 +0000 (01:27 +0200)
This change is be useful especially for CEPH_OSD_OP_CALL
which will be brought by further commits. The issue here
is that the Ceph Classes will be based on existing iface
handling errors with usual, int-based ret codes. These
codes needs to be glued with the existing handling  in
pg::do_osd_ops().

Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
src/crimson/osd/exceptions.h
src/crimson/osd/pg.cc

index 7437ae4b88705f0267d97fcb2e97285bb5880872..06063c41582883d1f824b4abd09ceeadc83653a8 100644 (file)
@@ -4,12 +4,33 @@
 #pragma once
 
 #include <exception>
+#include <system_error>
 
-class object_not_found : public std::exception {
+class crimson_error : private std::system_error {
+public:
+  crimson_error(const std::errc ec)
+    : system_error(std::make_error_code(ec)) {
+  }
+
+  using system_error::code;
+  using system_error::what;
+
+private:
+  crimson_error(const int ret) noexcept
+    : system_error(ret, std::system_category()) {
+  }
+};
+
+
+struct object_not_found : public crimson_error {
+  object_not_found() : crimson_error(std::errc::no_such_file_or_directory) {}
 };
 
-class object_corrupted : public std::exception {
+struct object_corrupted : public crimson_error {
+  object_corrupted() : crimson_error(std::errc::illegal_byte_sequence) {}
 };
 
-class invalid_argument : public std::exception {
+struct invalid_argument : public crimson_error {
+  invalid_argument() : crimson_error(std::errc::invalid_argument) {}
 };
+
index d224555685d18eaa8796e0284f29204896f56707..b87ffae86f4ddd7261f0b43b270483d1dc284e48 100644 (file)
@@ -463,12 +463,13 @@ seastar::future<Ref<MOSDOpReply>> PG::do_osd_ops(Ref<MOSDOp> m)
                                              0, false);
       reply->add_flags(CEPH_OSD_FLAG_ACK | CEPH_OSD_FLAG_ONDISK);
       return seastar::make_ready_future<Ref<MOSDOpReply>>(std::move(reply));
-    }).handle_exception_type([=](const object_not_found& dne) {
-      logger().debug("got object_not_found for {}", oid);
+    }).handle_exception_type([=](const crimson_error& ce) {
+      logger().debug("got crimson_error while handling object {}: {} ({})",
+                     oid, ce.code(), ce.what());
 
       backend->evict_object_state(oid);
-      auto reply = make_message<MOSDOpReply>(m.get(), -ENOENT, get_osdmap_epoch(),
-                                             0, false);
+      auto reply = make_message<MOSDOpReply>(
+        m.get(), -ce.code().value(), get_osdmap_epoch(), 0, false);
       reply->set_enoent_reply_versions(peering_state.get_info().last_update,
                                        peering_state.get_info().last_user_version);
       return seastar::make_ready_future<Ref<MOSDOpReply>>(std::move(reply));