]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/osd: incremental maps groundwork
authorMatan Breizman <mbreizma@redhat.com>
Wed, 22 Nov 2023 08:31:05 +0000 (08:31 +0000)
committerMatan Breizman <mbreizma@redhat.com>
Wed, 27 Dec 2023 10:33:47 +0000 (10:33 +0000)
Note: * no actual users are added yet.
      * load_inc_map returns erroartor since we should handle
        inc maps reading errors (not-fatal).

Signed-off-by: Matan Breizman <mbreizma@redhat.com>
src/crimson/osd/osd_meta.cc
src/crimson/osd/osd_meta.h
src/crimson/osd/shard_services.cc
src/crimson/osd/shard_services.h

index 06d6932bc54faf8e55ec310460a222cf9f6d67a3..551229a4c6eb8fb5076688357657ddb36dd5e8b5 100644 (file)
@@ -12,7 +12,6 @@
 #include "osd/OSDMap.h"
 
 using std::string;
-using read_errorator = crimson::os::FuturizedStore::Shard::read_errorator;
 
 void OSDMeta::create(ceph::os::Transaction& t)
 {
@@ -25,11 +24,22 @@ void OSDMeta::store_map(ceph::os::Transaction& t,
   t.write(coll->get_cid(), osdmap_oid(e), 0, m.length(), m);
 }
 
+void OSDMeta::store_inc_map(ceph::os::Transaction& t,
+                        epoch_t e, const bufferlist& m)
+{
+  t.write(coll->get_cid(), inc_osdmap_oid(e), 0, m.length(), m);
+}
+
 void OSDMeta::remove_map(ceph::os::Transaction& t, epoch_t e)
 {
   t.remove(coll->get_cid(), osdmap_oid(e));
 }
 
+void OSDMeta::remove_inc_map(ceph::os::Transaction& t, epoch_t e)
+{
+  t.remove(coll->get_cid(), inc_osdmap_oid(e));
+}
+
 seastar::future<bufferlist> OSDMeta::load_map(epoch_t e)
 {
   return store.read(coll,
@@ -41,6 +51,13 @@ seastar::future<bufferlist> OSDMeta::load_map(epoch_t e)
     }));
 }
 
+read_errorator::future<ceph::bufferlist> OSDMeta::load_inc_map(epoch_t e)
+{
+  return store.read(coll,
+                    osdmap_oid(e), 0, 0,
+                    CEPH_OSD_OP_FLAG_FADVISE_WILLNEED);
+}
+
 void OSDMeta::store_superblock(ceph::os::Transaction& t,
                                const OSDSuperblock& superblock)
 {
@@ -122,6 +139,12 @@ ghobject_t OSDMeta::osdmap_oid(epoch_t epoch)
   return ghobject_t(hobject_t(sobject_t(object_t(name), 0)));
 }
 
+ghobject_t OSDMeta::inc_osdmap_oid(epoch_t epoch)
+{
+  string name = fmt::format("inc_osdmap.{}", epoch);
+  return ghobject_t(hobject_t(sobject_t(object_t(name), 0)));
+}
+
 ghobject_t OSDMeta::final_pool_info_oid(int64_t pool)
 {
   string name = fmt::format("final_pool_{}", pool);
index 2363671e330d6c99917fbc542085ed6494aa13d3..506007e397d6bdad2d995116f405ee693a14e8cd 100644 (file)
@@ -19,6 +19,8 @@ namespace crimson::os {
   class FuturizedStore;
 }
 
+using read_errorator = crimson::os::FuturizedStore::Shard::read_errorator;
+
 /// metadata shared across PGs, or put in another way,
 /// metadata not specific to certain PGs.
 class OSDMeta {
@@ -40,8 +42,13 @@ public:
 
   void store_map(ceph::os::Transaction& t,
                  epoch_t e, const bufferlist& m);
+  void store_inc_map(ceph::os::Transaction& t,
+                 epoch_t e, const bufferlist& m);
   void remove_map(ceph::os::Transaction& t, epoch_t e);
+  void remove_inc_map(ceph::os::Transaction& t, epoch_t e);
+
   seastar::future<bufferlist> load_map(epoch_t e);
+  read_errorator::future<ceph::bufferlist> load_inc_map(epoch_t e);
 
   void store_superblock(ceph::os::Transaction& t,
                         const OSDSuperblock& sb);
@@ -60,6 +67,7 @@ public:
     std::map<epoch_t, OSDMap*>&);
 private:
   static ghobject_t osdmap_oid(epoch_t epoch);
+  static ghobject_t inc_osdmap_oid(epoch_t epoch);
   static ghobject_t final_pool_info_oid(int64_t pool);
   static ghobject_t superblock_oid();
 };
index 5e50e740fd3ecb9df6d09691fb1553b9180ddcd3..9d9efb8945a659887e7cacf374fae13ea4d341e6 100644 (file)
@@ -379,6 +379,14 @@ void OSDSingletonState::store_map_bl(
   map_bl_cache.insert(e, std::move(bl));
 }
 
+void OSDSingletonState::store_inc_map_bl(
+  ceph::os::Transaction& t,
+  epoch_t e, bufferlist&& bl)
+{
+  meta_coll->store_inc_map(t, e, bl);
+  inc_map_bl_cache.insert(e, std::move(bl));
+}
+
 seastar::future<bufferlist> OSDSingletonState::load_map_bl(
   epoch_t e)
 {
@@ -394,6 +402,21 @@ seastar::future<bufferlist> OSDSingletonState::load_map_bl(
   }
 }
 
+read_errorator::future<ceph::bufferlist> OSDSingletonState::load_inc_map_bl(
+  epoch_t e)
+{
+  if (std::optional<bufferlist> found = inc_map_bl_cache.find(e); found) {
+    logger().debug("{} inc map.{} found in cache", __func__, e);
+    return read_errorator::make_ready_future<bufferlist>(*found);
+  } else {
+    logger().debug("{} loading inc map.{} from disk", __func__, e);
+    return meta_coll->load_inc_map(e).safe_then([this, e](auto&& bl) {
+      inc_map_bl_cache.insert(e, bl);
+      return seastar::make_ready_future<bufferlist>(std::move(bl));
+    }, read_errorator::pass_further{});
+  }
+}
+
 seastar::future<std::map<epoch_t, bufferlist>> OSDSingletonState::load_map_bls(
   epoch_t first,
   epoch_t last)
index 37993a4f67950fd1244435a8435e9a563f7dc858..62f0080e2a7b8e26d309f6db3ddcc26198c7d936 100644 (file)
@@ -218,6 +218,7 @@ class OSDSingletonState : public md_config_obs_t {
   friend class OSD;
   using cached_map_t = OSDMapService::cached_map_t;
   using local_cached_map_t = OSDMapService::local_cached_map_t;
+  using read_errorator = crimson::os::FuturizedStore::Shard::read_errorator;
 
 public:
   OSDSingletonState(
@@ -236,6 +237,7 @@ private:
 
   SharedLRU<epoch_t, OSDMap> osdmaps;
   SimpleLRU<epoch_t, bufferlist, false> map_bl_cache;
+  SimpleLRU<epoch_t, bufferlist, false> inc_map_bl_cache;
 
   cached_map_t osdmap;
   cached_map_t &get_osdmap() { return osdmap; }
@@ -319,9 +321,12 @@ private:
   seastar::future<std::unique_ptr<OSDMap>> load_map(epoch_t e);
   seastar::future<bufferlist> load_map_bl(epoch_t e);
   seastar::future<std::map<epoch_t, bufferlist>>
+  read_errorator::future<ceph::bufferlist> load_inc_map_bl(epoch_t e);
   load_map_bls(epoch_t first, epoch_t last);
   void store_map_bl(ceph::os::Transaction& t,
                     epoch_t e, bufferlist&& bl);
+  void store_inc_map_bl(ceph::os::Transaction& t,
+                    epoch_t e, bufferlist&& bl);
   seastar::future<> store_maps(ceph::os::Transaction& t,
                                epoch_t start, Ref<MOSDMap> m);
   void trim_maps(ceph::os::Transaction& t, OSDSuperblock& superblock);