]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson:add more futurized store API for alien store
authorChunmei Liu <chunmei.liu@intel.com>
Tue, 21 Jan 2020 19:48:08 +0000 (11:48 -0800)
committerChunmei Liu <chunmei.liu@intel.com>
Fri, 28 Feb 2020 03:57:08 +0000 (19:57 -0800)
since alien store is futurized store, need change all store
API to be futurized.

Signed-off-by: Chunmei Liu <chunmei.liu@intel.com>
src/crimson/os/cyanstore/cyan_object.h
src/crimson/os/cyanstore/cyan_store.cc
src/crimson/os/cyanstore/cyan_store.h
src/crimson/os/futurized_collection.h
src/crimson/os/futurized_store.h
src/crimson/osd/osd.cc
src/crimson/osd/osd_meta.cc
src/crimson/osd/osd_meta.h
src/crimson/osd/pg_backend.h

index 993fb903b92fa5d326e0f97c167c466b345fff51..912629de067ea78b2f3ceb4f35020c13f2dfd5f0 100644 (file)
@@ -37,4 +37,6 @@ struct Object : public boost::intrusive_ref_counter<
   void encode(bufferlist& bl) const;
   void decode(bufferlist::const_iterator& p);
 };
+using ObjectRef = boost::intrusive_ptr<Object>;
+
 }
index 0cd89953743d23db6f8e63dc2e780b0063436dfb..b08859a43196de8c109a83312fc2362e50ac0cd5 100644 (file)
@@ -115,13 +115,13 @@ seastar::future<> CyanStore::mkfs(uuid_d new_osd_fsid)
   });
 }
 
-store_statfs_t CyanStore::stat() const
+seastar::future<store_statfs_t> CyanStore::stat() const
 {
   logger().debug("{}", __func__);
   store_statfs_t st;
   st.total = crimson::common::local_conf().get_val<Option::size_t>("memstore_device_bytes");
   st.available = st.total - used_bytes;
-  return st;
+  return seastar::make_ready_future<store_statfs_t>(std::move(st));
 }
 
 seastar::future<std::vector<ghobject_t>, ghobject_t>
index 977cf2ff92937cbbe41f37de4c37044233a6d21e..d1172c679cfb6c9129b118c37305bc1b9e36342b 100644 (file)
@@ -11,6 +11,7 @@
 
 #include <optional>
 #include <seastar/core/future.hh>
+#include <seastar/core/future-util.hh>
 
 #include "osd/osd_types.h"
 #include "include/uuid.h"
@@ -38,11 +39,12 @@ public:
   CyanStore(const std::string& path);
   ~CyanStore() final;
 
+  seastar::future<> stop() final {return seastar::now();}
   seastar::future<> mount() final;
   seastar::future<> umount() final;
 
   seastar::future<> mkfs(uuid_d new_osd_fsid) final;
-  store_statfs_t stat() const final;
+  seastar::future<store_statfs_t> stat() const final;
 
   read_errorator::future<ceph::bufferlist> read(
     CollectionRef c,
index 2226a53aa1cee8fc605e953e2e5f85b61bf18072..06f7d2f47d5f27f104eafd74ee699894383ea29e 100644 (file)
@@ -10,6 +10,7 @@
 #include "osd/osd_types.h"
 
 namespace crimson::os {
+class FuturizedStore;
 
 class FuturizedCollection
   : public boost::intrusive_ref_counter<FuturizedCollection,
@@ -20,7 +21,7 @@ public:
     : cid{cid} {}
   virtual ~FuturizedCollection() {}
   virtual seastar::future<> flush() {
-    return seastar::now();
+    return seastar::make_ready_future<>();
   }
   virtual seastar::future<bool> flush_commit() {
     return seastar::make_ready_future<bool>(true);
index 388b965148ee5379d70c881c90df68b7a459e53e..6bc228a00d0030a6e7cda2669d84072f045dbbc1 100644 (file)
@@ -35,14 +35,19 @@ public:
   explicit FuturizedStore(const FuturizedStore& o) = delete;
   const FuturizedStore& operator=(const FuturizedStore& o) = delete;
 
+  virtual seastar::future<> start() {
+    return seastar::now();
+  }
+  virtual seastar::future<> stop() = 0;
   virtual seastar::future<> mount() = 0;
   virtual seastar::future<> umount() = 0;
 
   virtual seastar::future<> mkfs(uuid_d new_osd_fsid) = 0;
-  virtual store_statfs_t stat() const = 0;
+  virtual seastar::future<store_statfs_t> stat() const = 0;
 
   using CollectionRef = boost::intrusive_ptr<FuturizedCollection>;
-  using read_errorator = crimson::errorator<crimson::ct_error::enoent>;
+  using read_errorator = crimson::errorator<crimson::ct_error::enoent,
+                                            crimson::ct_error::input_output_error>;
   virtual read_errorator::future<ceph::bufferlist> read(
     CollectionRef c,
     const ghobject_t& oid,
index e609990ad876589c3127569af0b44bb2f4026733..147e6b9d3d8d355e958e7291a307dce2c00afbcc 100644 (file)
@@ -125,7 +125,9 @@ CompatSet get_osd_initial_compat_set()
 
 seastar::future<> OSD::mkfs(uuid_d osd_uuid, uuid_d cluster_fsid)
 {
-  return store->mkfs(osd_uuid).then([this] {
+  return store->start().then([this, osd_uuid] {
+    return store->mkfs(osd_uuid);
+  }).then([this] {
     return store->mount();
   }).then([cluster_fsid, this] {
     superblock.cluster_fsid = cluster_fsid;
@@ -204,7 +206,9 @@ seastar::future<> OSD::start()
 
   startup_time = ceph::mono_clock::now();
 
-  return store->mount().then([this] {
+  return store->start().then([this] {
+    return store->mount();
+  }).then([this] {
     return store->open_collection(coll_t::meta());
   }).then([this](auto ch) {
     meta_coll = make_unique<OSDMeta>(ch, store.get());
@@ -346,33 +350,38 @@ seastar::future<> OSD::_add_me_to_crush()
   if (!local_conf().get_val<bool>("osd_crush_update_on_start")) {
     return seastar::now();
   }
-  const double weight = [this] {
+  auto get_weight = [this] {
     if (auto w = local_conf().get_val<double>("osd_crush_initial_weight");
        w >= 0) {
-      return w;
+      return seastar::make_ready_future<double>(w);
     } else {
-      auto total = store->stat().total;
-      return std::max(.00001, double(total) / double(1ull << 40)); // TB
+       return store->stat().then([](auto st) {
+         auto total = st.total;
+        return seastar::make_ready_future<double>(
+           std::max(.00001,
+                   double(total) / double(1ull << 40))); // TB
+       });
     }
-  }();
-  const crimson::crush::CrushLocation loc{make_unique<CephContext>().get()};
-  logger().info("{} crush location is {}", __func__, loc);
-  string cmd = fmt::format(R"({{
-    "prefix": "osd crush create-or-move",
-    "id": {},
-    "weight": {:.4f},
-    "args": [{}]
-  }})", whoami, weight, loc);
-  return monc->run_command({cmd}, {}).then(
-    [](int32_t code, string message, bufferlist) {
-      if (code) {
-       logger().warn("fail to add to crush: {} ({})", message, code);
-       throw std::runtime_error("fail to add to crush");
-      } else {
-       logger().info("added to crush: {}", message);
-      }
-      return seastar::now();
-    });
+  };
+  return get_weight().then([this](auto weight) {
+    const crimson::crush::CrushLocation loc{make_unique<CephContext>().get()};
+    logger().info("{} crush location is {}", __func__, loc);
+    string cmd = fmt::format(R"({{
+      "prefix": "osd crush create-or-move",
+      "id": {},
+      "weight": {:.4f},
+      "args": [{}]
+    }})", whoami, weight, loc);
+    return monc->run_command({cmd}, {});
+  }).then([](int32_t code, string message, bufferlist) {
+    if (code) {
+      logger().warn("fail to add to crush: {} ({})", message, code);
+      throw std::runtime_error("fail to add to crush");
+    } else {
+      logger().info("added to crush: {}", message);
+    }
+    return seastar::now();
+  });
 }
 
 seastar::future<> OSD::_send_alive()
@@ -436,6 +445,8 @@ seastar::future<> OSD::stop()
       cluster_msgr->shutdown());
   }).then([this] {
     return store->umount();
+  }).then([this] {
+    return store->stop();
   }).handle_exception([](auto ep) {
     logger().error("error while stopping osd: {}", ep);
   });
index 56b627e7441a25740c5c207dd7ef5ec8e5f4eccf..bd5880540be8f2ecb377387a3fe757698c03badb 100644 (file)
@@ -28,7 +28,7 @@ seastar::future<bufferlist> OSDMeta::load_map(epoch_t e)
   return store->read(coll,
                      osdmap_oid(e), 0, 0,
                      CEPH_OSD_OP_FLAG_FADVISE_WILLNEED).handle_error(
-    crimson::ct_error::enoent::handle([e] {
+    read_errorator::all_same_way([e] {
       throw std::runtime_error(fmt::format("read gave enoent on {}",
                                            osdmap_oid(e)));
     }));
@@ -50,7 +50,7 @@ seastar::future<OSDSuperblock> OSDMeta::load_superblock()
       OSDSuperblock superblock;
       decode(superblock, p);
       return seastar::make_ready_future<OSDSuperblock>(std::move(superblock));
-    }, crimson::ct_error::enoent::handle([] {
+    }, read_errorator::all_same_way([] {
       throw std::runtime_error(fmt::format("read gave enoent on {}",
                                            superblock_oid()));
     }));
@@ -74,7 +74,7 @@ OSDMeta::load_final_pool_info(int64_t pool) {
                                       ec_profile_t>(std::move(pi),
                                                     std::move(name),
                                                     std::move(ec_profile));
-  }, crimson::ct_error::enoent::handle([pool] {
+  },read_errorator::all_same_way([pool] {
     throw std::runtime_error(fmt::format("read gave enoent on {}",
                                          final_pool_info_oid(pool)));
   }));
index 35e9a9c22f2fd71364825632462a1e3e592eaebf..e4043c768cd53862488919049e49a35e4e5c9844 100644 (file)
@@ -7,6 +7,7 @@
 #include <string>
 #include <seastar/core/future.hh>
 #include "osd/osd_types.h"
+#include "crimson/os/futurized_collection.h"
 
 namespace ceph::os {
   class Transaction;
@@ -31,7 +32,6 @@ public:
     : store{store}, coll{coll}
   {}
 
-
   auto collection() {
     return coll;
   }
index d72997eff66ab51697c1496f4a39a9665e752326..ae55fd289bf57f097dfdd2f722b33e9e12c3cafb 100644 (file)
@@ -45,7 +45,6 @@ public:
                                           const ec_profile_t& ec_profile);
 
   using read_errorator = ll_read_errorator::extend<
-    crimson::ct_error::input_output_error,
     crimson::ct_error::object_corrupted>;
   read_errorator::future<ceph::bufferlist> read(
     const object_info_t& oi,