]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/osd: add OSD::load_map()
authorKefu Chai <kchai@redhat.com>
Sat, 9 Mar 2019 03:56:30 +0000 (11:56 +0800)
committerKefu Chai <kchai@redhat.com>
Sat, 16 Mar 2019 07:30:16 +0000 (15:30 +0800)
so we can reuse it when we need to load an non-cached osdmap.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/crimson/osd/osd.cc
src/crimson/osd/osd.h

index 3120b2652357c611068d362eab76c53284c6fd08..6b8ae3329b96e955dba4fb60526887b6729a8702 100644 (file)
@@ -391,9 +391,7 @@ seastar::future<OSD::cached_map_t> OSD::get_map(epoch_t e)
   if (auto found = osdmaps.find(e); found) {
     return seastar::make_ready_future<cached_map_t>(std::move(found));
   } else {
-    return load_map_bl(e).then([e, this](bufferlist bl) {
-      auto osdmap = std::make_unique<OSDMap>();
-      osdmap->decode(bl);
+    return load_map(e).then([e, this](unique_ptr<OSDMap> osdmap) {
       return seastar::make_ready_future<cached_map_t>(
         osdmaps.insert(e, std::move(osdmap)));
     });
@@ -416,6 +414,15 @@ seastar::future<bufferlist> OSD::load_map_bl(epoch_t e)
   }
 }
 
+seastar::future<std::unique_ptr<OSDMap>> OSD::load_map(epoch_t e)
+{
+  return load_map_bl(e).then([e, this](bufferlist bl) {
+    auto o = std::make_unique<OSDMap>();
+    o->decode(bl);
+    return seastar::make_ready_future<decltype(o)>(std::move(o));
+  });
+}
+
 seastar::future<> OSD::store_maps(ceph::os::Transaction& t,
                                   epoch_t start, Ref<MOSDMap> m)
 {
index c5aff5e2dd35de4ea00a01b0e16a26dc89c8baef..55336289fbb6216158e961a1bfd6ed1679437961 100644 (file)
@@ -100,7 +100,7 @@ private:
   // OSDMapService methods
   seastar::future<cached_map_t> get_map(epoch_t e) override;
   cached_map_t get_map() const override;
-
+  seastar::future<std::unique_ptr<OSDMap>> load_map(epoch_t e);
   seastar::future<bufferlist> load_map_bl(epoch_t e);
   void store_map_bl(ceph::os::Transaction& t,
                     epoch_t e, bufferlist&& bl);