]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/osd: put snapmapper's key-value pairs into dedicated objs
authorXuehan Xu <xuxuehan@qianxin.com>
Fri, 30 Jun 2023 04:33:35 +0000 (12:33 +0800)
committerXuehan Xu <xuxuehan@qianxin.com>
Wed, 21 Feb 2024 09:44:50 +0000 (17:44 +0800)
Otherwise, PG::read_log_and_missing() will meet those key-values and
won't know what to do with them. This is modeling what the classic
osd is doing

Signed-off-by: Xuehan Xu <xuxuehan@qianxin.com>
src/crimson/osd/pg.cc
src/crimson/osd/pg.h
src/crimson/osd/shard_services.cc

index 54c8101cd115be2db8972104045d06a291662b13..f5541da96194d18121ca0b709295db4d921d86cb 100644 (file)
@@ -136,7 +136,7 @@ PG::PG(
     osdriver(
       &shard_services.get_store(),
       coll_ref,
-      pgid.make_pgmeta_oid()),
+      make_snapmapper_oid()),
     snap_mapper(
       this->shard_services.get_cct(),
       &osdriver,
@@ -596,7 +596,7 @@ void PG::schedule_renew_lease(epoch_t last_peering_reset, ceph::timespan delay)
 }
 
 
-void PG::init(
+seastar::future<> PG::init(
   int role,
   const vector<int>& newup, int new_up_primary,
   const vector<int>& newacting, int new_acting_primary,
@@ -607,6 +607,16 @@ void PG::init(
   peering_state.init(
     role, newup, new_up_primary, newacting,
     new_acting_primary, history, pi, t);
+  assert(coll_ref);
+  return shard_services.get_store().exists(
+    get_collection_ref(), make_snapmapper_oid()
+  ).safe_then([&t, this](bool existed) {
+      if (!existed) {
+        t.touch(coll_ref->get_cid(), make_snapmapper_oid());
+      }
+    },
+    ::crimson::ct_error::assert_all{"unexpected eio"}
+  );
 }
 
 seastar::future<> PG::read_state(crimson::os::FuturizedStore::Shard* store)
index e103d3bb5eec1a09b2113cfb734ec29edfdccafc..0552d49f2ad495cfc01b0576c8ca95c204380096 100644 (file)
@@ -41,6 +41,8 @@
 #include "crimson/osd/object_context_loader.h"
 #include "crimson/osd/scrub/pg_scrubber.h"
 
+#define SNAPMAPPER_OID "snapmapper"
+
 class MQuery;
 class OSDMap;
 class PGBackend;
@@ -471,7 +473,7 @@ public:
   }
 
   /// initialize created PG
-  void init(
+  seastar::future<> init(
     int role,
     const std::vector<int>& up,
     int up_primary,
@@ -647,12 +649,22 @@ public:
 private:
   OSDriver osdriver;
   SnapMapper snap_mapper;
-
+  ghobject_t make_snapmapper_oid() const {
+    return ghobject_t(hobject_t(
+      sobject_t(
+       object_t(SNAPMAPPER_OID),
+       0),
+      std::string(),
+      pgid.ps(),
+      pgid.pool(),
+      std::string()));
+  }
 public:
   // PeeringListener
   void publish_stats_to_osd() final;
   void clear_publish_stats() final;
   pg_stat_t get_stats() const;
+
 private:
   std::optional<pg_stat_t> pg_stats;
 
index 604c045eb9b86d743addde22b7c6b06489b8d1fd..d34ee1977c60da9ebb817f882c39b8456f7d72f7 100644 (file)
@@ -671,17 +671,17 @@ seastar::future<Ref<PG>> ShardServices::handle_pg_create_info(
            pg_shard_t(local_state.whoami, info->pgid.shard),
            acting);
 
-         PeeringCtx rctx;
+         std::unique_ptr<PeeringCtx> rctx = std::make_unique<PeeringCtx>();
          create_pg_collection(
-           rctx.transaction,
+           rctx->transaction,
            info->pgid,
            info->pgid.get_split_bits(pp->get_pg_num()));
          init_pg_ondisk(
-           rctx.transaction,
+           rctx->transaction,
            info->pgid,
            pp);
 
-         pg->init(
+         return pg->init(
            role,
            up,
            up_primary,
@@ -689,12 +689,13 @@ seastar::future<Ref<PG>> ShardServices::handle_pg_create_info(
            acting_primary,
            info->history,
            info->past_intervals,
-           rctx.transaction);
-
-         return start_operation<PGAdvanceMap>(
-           pg, *this, get_map()->get_epoch(), std::move(rctx), true
-         ).second.then([pg=pg] {
-           return seastar::make_ready_future<Ref<PG>>(pg);
+           rctx->transaction
+         ).then([this, pg=pg, rctx=std::move(rctx)] {
+           return start_operation<PGAdvanceMap>(
+             pg, *this, get_map()->get_epoch(), std::move(*rctx), true
+           ).second.then([pg=pg] {
+             return seastar::make_ready_future<Ref<PG>>(pg);
+           });
          });
        });
     });