]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/osd/shard_services: retain map references in OSDSingletonState::store_maps 55266/head
authorSamuel Just <sjust@redhat.com>
Wed, 10 Jan 2024 17:43:45 +0000 (09:43 -0800)
committerSamuel Just <sjust@redhat.com>
Thu, 25 Jan 2024 03:02:06 +0000 (03:02 +0000)
Introduced: 3f11cd94
Fixes: https://tracker.ceph.com/issues/63996
Signed-off-by: Samuel Just <sjust@redhat.com>
src/crimson/osd/osd_meta.cc
src/crimson/osd/osd_meta.h
src/crimson/osd/shard_services.cc

index 551229a4c6eb8fb5076688357657ddb36dd5e8b5..0317da84020f027f5df931161d777ed57efcebb3 100644 (file)
@@ -105,31 +105,31 @@ OSDMeta::load_final_pool_info(int64_t pool) {
 
 void OSDMeta::store_final_pool_info(
   ceph::os::Transaction &t,
-  OSDMap* lastmap,
-  std::map<epoch_t, OSDMap*> &added_map)
+  LocalOSDMapRef previous,
+  std::map<epoch_t, LocalOSDMapRef> &added_map)
 {
   for (auto [e, map] : added_map) {
-    if (!lastmap) {
-      lastmap = map;
+    if (!previous) {
+      previous = map;
       continue;
     }
-    for (auto &[pool_id, pool] : lastmap->get_pools()) {
+    for (auto &[pool_id, pool] : previous->get_pools()) {
       if (!map->have_pg_pool(pool_id)) {
        ghobject_t obj = final_pool_info_oid(pool_id);
        bufferlist bl;
        encode(pool, bl, CEPH_FEATURES_ALL);
-       string name = lastmap->get_pool_name(pool_id);
+       string name = previous->get_pool_name(pool_id);
        encode(name, bl);
        std::map<string, string> profile;
        if (pool.is_erasure()) {
-         profile = lastmap->get_erasure_code_profile(
+         profile = previous->get_erasure_code_profile(
            pool.erasure_code_profile);
        }
        encode(profile, bl);
        t.write(coll->get_cid(), obj, 0, bl.length(), bl);
       }
     }
-    lastmap = map;
+    previous = map;
   }
 }
 
index 506007e397d6bdad2d995116f405ee693a14e8cd..0c6738aed8fe18a80f7ac926d62c3b7d54f2669f 100644 (file)
@@ -6,6 +6,7 @@
 #include <map>
 #include <string>
 #include <seastar/core/future.hh>
+#include "osd/OSDMap.h"
 #include "osd/osd_types.h"
 #include "crimson/os/futurized_collection.h"
 #include "crimson/os/futurized_store.h"
@@ -63,8 +64,8 @@ public:
                             ec_profile_t>> load_final_pool_info(int64_t pool);
   void store_final_pool_info(
     ceph::os::Transaction&,
-    OSDMap* lastmap,
-    std::map<epoch_t, OSDMap*>&);
+    LocalOSDMapRef lastmap,
+    std::map<epoch_t, LocalOSDMapRef>&);
 private:
   static ghobject_t osdmap_oid(epoch_t epoch);
   static ghobject_t inc_osdmap_oid(epoch_t epoch);
index 26993daa659e2f57a1537e2aa35d0c8194775960..0a6a739af274b521681fb6fb23a6f9ef710f5042 100644 (file)
@@ -466,12 +466,13 @@ seastar::future<std::unique_ptr<OSDMap>> OSDSingletonState::load_map(epoch_t e)
   });
 }
 
-seastar::future<> OSDSingletonState::store_maps(ceph::os::Transaction& t,
-                                  epoch_t start, Ref<MOSDMap> m)
+seastar::future<> OSDSingletonState::store_maps(
+  ceph::os::Transaction& t,
+  epoch_t start, Ref<MOSDMap> m)
 {
   LOG_PREFIX(OSDSingletonState::store_maps);
   return seastar::do_with(
-    std::map<epoch_t, OSDMap*>(),
+    std::map<epoch_t, local_cached_map_t>(),
     [&t, FNAME, m, start, this](auto &added_maps) {
     return seastar::do_for_each(
       boost::make_counting_iterator(start),
@@ -482,8 +483,7 @@ seastar::future<> OSDSingletonState::store_maps(ceph::os::Transaction& t,
        o->decode(p->second);
        INFO("storing osdmap.{}", e);
        store_map_bl(t, e, std::move(std::move(p->second)));
-       added_maps.emplace(e, o.get());
-       osdmaps.insert(e, std::move(o));
+       added_maps.emplace(e, osdmaps.insert(e, std::move(o)));
        return seastar::now();
       } else if (auto p = m->incremental_maps.find(e);
                 p != m->incremental_maps.end()) {
@@ -500,8 +500,7 @@ seastar::future<> OSDSingletonState::store_maps(ceph::os::Transaction& t,
          o->encode(fbl, inc.encode_features | CEPH_FEATURE_RESERVED);
          INFO("storing osdmap.{}", o->get_epoch());
          store_map_bl(t, e, std::move(fbl));
-         added_maps.emplace(e, o.get());
-         osdmaps.insert(e, std::move(o));
+         added_maps.emplace(e, osdmaps.insert(e, std::move(o)));
          return seastar::now();
        });
       } else {
@@ -509,10 +508,19 @@ seastar::future<> OSDSingletonState::store_maps(ceph::os::Transaction& t,
        return seastar::now();
       }
     }).then([&t, FNAME, this, &added_maps] {
-      auto [e, map] = *added_maps.begin();
-      auto lastmap = osdmaps.find(e - 1).get();
-      meta_coll->store_final_pool_info(t, lastmap, added_maps);
-      return seastar::now();
+      epoch_t last_map_epoch = superblock.get_newest_map();
+      auto last_map_fut = last_map_epoch > 0
+       ? get_local_map(last_map_epoch)
+       : seastar::make_ready_future<local_cached_map_t>();
+      return last_map_fut.then(
+       [&t, FNAME, last_map_epoch, this, &added_maps](auto lastmap) {
+       INFO("storing final pool info lastmap epoch {}, added maps {}->{}",
+            last_map_epoch,
+            added_maps.begin()->first,
+            added_maps.rbegin()->first);
+       meta_coll->store_final_pool_info(t, lastmap, added_maps);
+       return seastar::now();
+      });
     });
   });
 }