]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/os, crimson/osd: apply errorator along the read path, part 1.
authorRadoslaw Zarzynski <rzarzyns@redhat.com>
Mon, 9 Sep 2019 12:48:19 +0000 (14:48 +0200)
committerRadoslaw Zarzynski <rzarzyns@redhat.com>
Wed, 20 Nov 2019 19:36:15 +0000 (20:36 +0100)
Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
src/crimson/os/cyan_store.cc
src/crimson/os/cyan_store.h
src/crimson/os/futurized_store.h
src/crimson/osd/osd_meta.cc
src/crimson/osd/replicated_backend.cc

index 1ccc78d33fa7bf1ccc86c80e959f7598087d012c..75795c0639ed2ea69dfabfdb0b9c71c8f4f3c453 100644 (file)
@@ -171,22 +171,22 @@ seastar::future<std::vector<coll_t>> CyanStore::list_collections()
   return seastar::make_ready_future<std::vector<coll_t>>(std::move(collections));
 }
 
-seastar::future<ceph::bufferlist> CyanStore::read(CollectionRef ch,
-                                            const ghobject_t& oid,
-                                            uint64_t offset,
-                                            size_t len,
-                                            uint32_t op_flags)
+CyanStore::read_errorator::future<ceph::bufferlist> CyanStore::read(
+  CollectionRef ch,
+  const ghobject_t& oid,
+  uint64_t offset,
+  size_t len,
+  uint32_t op_flags)
 {
   auto c = static_cast<Collection*>(ch.get());
   logger().debug("{} {} {} {}~{}",
                 __func__, c->get_cid(), oid, offset, len);
   if (!c->exists) {
-    throw std::runtime_error(fmt::format("collection does not exist: {}",
-                                        c->get_cid()));
+    return crimson::make_error<ceph::ct_error::enoent>();
   }
   ObjectRef o = c->get_object(oid);
   if (!o) {
-    throw std::runtime_error(fmt::format("object does not exist: {}", oid));
+    return crimson::make_error<ceph::ct_error::enoent>();
   }
   if (offset >= o->get_size())
     return seastar::make_ready_future<ceph::bufferlist>();
index 96f3eb84a231e428513ccd1cfa411beae9c6bf4c..fa40692e59af83fe1c8db9969fdfde3c001f84d8 100644 (file)
@@ -44,11 +44,12 @@ public:
   seastar::future<> mkfs(uuid_d new_osd_fsid) final;
   store_statfs_t stat() const final;
 
-  seastar::future<ceph::bufferlist> read(CollectionRef c,
-                                  const ghobject_t& oid,
-                                  uint64_t offset,
-                                  size_t len,
-                                  uint32_t op_flags = 0) final;
+  read_errorator::future<ceph::bufferlist> read(
+    CollectionRef c,
+    const ghobject_t& oid,
+    uint64_t offset,
+    size_t len,
+    uint32_t op_flags = 0) final;
   get_attr_errorator::future<ceph::bufferptr> get_attr(
     CollectionRef c,
     const ghobject_t& oid,
index 401f9d456d183806cc2aea685492bdb028f17cbc..10bf6874c253dda18d33956976aee614f14f6bce 100644 (file)
@@ -42,11 +42,24 @@ public:
   virtual store_statfs_t stat() const = 0;
 
   using CollectionRef = boost::intrusive_ptr<FuturizedCollection>;
-  virtual seastar::future<ceph::bufferlist> read(CollectionRef c,
-                                  const ghobject_t& oid,
-                                  uint64_t offset,
-                                  size_t len,
-                                  uint32_t op_flags = 0) = 0;
+
+  // TODO: using read_errorator = ceph::errorator<...>
+  struct read_errorator : crimson::errorator<crimson::ct_error::enoent> {
+    // just for the makeshift period of switching to errorator
+    struct throw_as_runtime_error : discard_all {
+      auto operator()(const auto& e) {
+        throw std::runtime_error("legacy throwing");
+        return discard_all::operator()(e);
+      }
+    };
+  };
+  virtual read_errorator::future<ceph::bufferlist> read(
+    CollectionRef c,
+    const ghobject_t& oid,
+    uint64_t offset,
+    size_t len,
+    uint32_t op_flags = 0) = 0;
+
   using get_attr_errorator = crimson::errorator<
     crimson::ct_error::enoent,
     crimson::ct_error::enodata>;
index fd2e63319ba743f5f1e1b2a5326d9369306073d2..6baaf07d154386ca14a050a5fbf98e117c554fb7 100644 (file)
@@ -6,6 +6,8 @@
 #include "crimson/os/futurized_store.h"
 #include "os/Transaction.h"
 
+using read_errorator = crimson::os::FuturizedStore::read_errorator;
+
 void OSDMeta::create(ceph::os::Transaction& t)
 {
   t.create_collection(coll->get_cid(), 0);
@@ -21,7 +23,9 @@ seastar::future<bufferlist> OSDMeta::load_map(epoch_t e)
 {
   return store->read(coll,
                      osdmap_oid(e), 0, 0,
-                     CEPH_OSD_OP_FLAG_FADVISE_WILLNEED);
+                     CEPH_OSD_OP_FLAG_FADVISE_WILLNEED).safe_then(
+    [] (auto&& bl) { return bl; },
+    read_errorator::throw_as_runtime_error{});
 }
 
 void OSDMeta::store_superblock(ceph::os::Transaction& t,
@@ -35,12 +39,12 @@ void OSDMeta::store_superblock(ceph::os::Transaction& t,
 seastar::future<OSDSuperblock> OSDMeta::load_superblock()
 {
   return store->read(coll, superblock_oid(), 0, 0)
-    .then([this] (bufferlist&& bl) {
+    .safe_then([this] (bufferlist&& bl) {
       auto p = bl.cbegin();
       OSDSuperblock superblock;
       decode(superblock, p);
       return seastar::make_ready_future<OSDSuperblock>(std::move(superblock));
-  });
+  }, read_errorator::throw_as_runtime_error{});
 }
 
 seastar::future<pg_pool_t,
@@ -48,7 +52,7 @@ seastar::future<pg_pool_t,
                 OSDMeta::ec_profile_t>
 OSDMeta::load_final_pool_info(int64_t pool) {
   return store->read(coll, final_pool_info_oid(pool),
-                     0, 0).then([this] (bufferlist&& bl) {
+                     0, 0).safe_then([this] (bufferlist&& bl) {
     auto p = bl.cbegin();
     pg_pool_t pi;
     string name;
@@ -61,7 +65,7 @@ OSDMeta::load_final_pool_info(int64_t pool) {
                                       ec_profile_t>(std::move(pi),
                                                     std::move(name),
                                                     std::move(ec_profile));
-  });
+  }, read_errorator::throw_as_runtime_error{});
 }
 
 ghobject_t OSDMeta::osdmap_oid(epoch_t epoch)
index a72d3f19462fb64ed8c91e15dbbbc36e1926e5c8..1955049bd4c4ea6c65fe51823636b60bfcbc88fa 100644 (file)
@@ -28,7 +28,10 @@ seastar::future<bufferlist> ReplicatedBackend::_read(const hobject_t& hoid,
                                                      uint64_t len,
                                                      uint32_t flags)
 {
-  return store->read(coll, ghobject_t{hoid}, off, len, flags);
+  using read_errorator = ceph::os::FuturizedStore::read_errorator;
+  return store->read(coll, ghobject_t{hoid}, off, len, flags).safe_then(
+    [] (auto&& bl) { return bl; },
+    read_errorator::throw_as_runtime_error{});
 }
 
 seastar::future<crimson::osd::acked_peers_t>