]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
crimson: move snapmapper object into INTERNAL_PG_LOCAL_NS
authorSamuel Just <sjust@redhat.com>
Tue, 26 Mar 2024 05:44:37 +0000 (22:44 -0700)
committerMatan Breizman <mbreizma@redhat.com>
Wed, 15 May 2024 15:00:50 +0000 (18:00 +0300)
Signed-off-by: Samuel Just <sjust@redhat.com>
(cherry picked from commit 1b7e3c4fb773a6e0a16145114013a07aa85edcc5)

src/common/hobject.h
src/crimson/osd/ops_executer.cc
src/crimson/osd/pg.cc
src/crimson/osd/pg.h
src/osd/osd_types.h

index 5d78b7a8f80c420809c78aac7023c2dd1b445e97..7e3e26b980a793cc7896e7579ef90e25bc3ea74d 100644 (file)
@@ -454,6 +454,26 @@ struct ghobject_t {
     return hobj.is_internal_pg_local();
   }
 
+  /**
+   * SNAPMAPPER_OID, make_snapmapper, is_snapmapper
+   *
+   * Used exclusively by crimson at this time.
+   * 
+   * Unlike classic, crimson uses a snap mapper object for each pg.
+   * The snapmapper object provides an index for efficient trimming of clones as
+   * snapshots are removed.
+   *
+   * As with the pgmeta object, we pin the hash to the pg hash.
+   */
+  static constexpr std::string_view SNAPMAPPER_OID = "snapmapper";
+  static ghobject_t make_snapmapper(
+    int64_t pool, uint32_t hash, shard_id_t shard) {
+    hobject_t h(object_t(SNAPMAPPER_OID), std::string(),
+               CEPH_NOSNAP, hash, pool,
+               std::string(hobject_t::INTERNAL_PG_LOCAL_NS));
+    return ghobject_t(h, NO_GEN, shard);
+  }
+
   bool match(uint32_t bits, uint32_t match) const {
     return hobj.match_hash(hobj.hash, bits, match);
   }
index 7e11868d0abb33ce6af8af0d7b2f27079115a917..91db2a58b97512dc2e9573b90b6685b1dc9dc846 100644 (file)
@@ -1166,10 +1166,6 @@ static PG::interruptible_future<hobject_t> pgls_filter(
   }
 }
 
-static inline bool is_snapmapper_oid(const hobject_t &obj) {
-  return obj.oid.name == SNAPMAPPER_OID;
-}
-
 static PG::interruptible_future<ceph::bufferlist> do_pgnls_common(
   const hobject_t& pg_start,
   const hobject_t& pg_end,
@@ -1190,13 +1186,6 @@ static PG::interruptible_future<ceph::bufferlist> do_pgnls_common(
     [&backend, filter, nspace](auto&& ret)
     -> PG::interruptible_future<std::tuple<std::vector<hobject_t>, hobject_t>> {
       auto& [objects, next] = ret;
-      auto is_snapmapper = [](const hobject_t &obj) {
-       if (is_snapmapper_oid(obj)) {
-         return false;
-       } else {
-         return true;
-       }
-      };
       auto in_my_namespace = [&nspace](const hobject_t& obj) {
         using crimson::common::local_conf;
         if (obj.get_namespace() == local_conf()->osd_hit_set_namespace) {
@@ -1224,8 +1213,7 @@ static PG::interruptible_future<ceph::bufferlist> do_pgnls_common(
         }
       };
 
-      auto range = objects | boost::adaptors::filtered(is_snapmapper)
-                          | boost::adaptors::filtered(in_my_namespace)
+      auto range = objects | boost::adaptors::filtered(in_my_namespace)
                            | boost::adaptors::transformed(to_pglsed);
       logger().debug("do_pgnls_common: finishing the 1st stage of pgls");
       return seastar::when_all_succeed(std::begin(range),
@@ -1358,9 +1346,6 @@ static PG::interruptible_future<ceph::bufferlist> do_pgls_common(
         PG::interruptor::map_reduce(std::move(objects),
           [&backend, filter, nspace](const hobject_t& obj)
          -> PG::interruptible_future<hobject_t>{
-           if (is_snapmapper_oid(obj)) {
-             return seastar::make_ready_future<hobject_t>();
-           }
             if (obj.get_namespace() == nspace) {
               if (filter) {
                 return pgls_filter(*filter, backend, obj);
index f5541da96194d18121ca0b709295db4d921d86cb..04ab572ff717cdc17d30b53829efcdb74129843c 100644 (file)
@@ -136,7 +136,7 @@ PG::PG(
     osdriver(
       &shard_services.get_store(),
       coll_ref,
-      make_snapmapper_oid()),
+      pgid.make_snapmapper_oid()),
     snap_mapper(
       this->shard_services.get_cct(),
       &osdriver,
@@ -609,10 +609,10 @@ seastar::future<> PG::init(
     new_acting_primary, history, pi, t);
   assert(coll_ref);
   return shard_services.get_store().exists(
-    get_collection_ref(), make_snapmapper_oid()
+    get_collection_ref(), pgid.make_snapmapper_oid()
   ).safe_then([&t, this](bool existed) {
       if (!existed) {
-        t.touch(coll_ref->get_cid(), make_snapmapper_oid());
+        t.touch(coll_ref->get_cid(), pgid.make_snapmapper_oid());
       }
     },
     ::crimson::ct_error::assert_all{"unexpected eio"}
index 0552d49f2ad495cfc01b0576c8ca95c204380096..1b607fca0c75f190d28034ce4c8b0a16a2931411 100644 (file)
@@ -41,8 +41,6 @@
 #include "crimson/osd/object_context_loader.h"
 #include "crimson/osd/scrub/pg_scrubber.h"
 
-#define SNAPMAPPER_OID "snapmapper"
-
 class MQuery;
 class OSDMap;
 class PGBackend;
@@ -649,16 +647,6 @@ 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;
index b283f4b9b2aa1e561f9711d8ab5439a67a2da596..4a80101c2697769a4330f211d18a08764083dfe3 100644 (file)
@@ -589,6 +589,10 @@ struct spg_t {
     return ghobject_t::make_pgmeta(pgid.pool(), pgid.ps(), shard);
   }
 
+  ghobject_t make_snapmapper_oid() const {
+    return ghobject_t::make_snapmapper(pgid.pool(), pgid.ps(), shard);
+  }
+
   void encode(ceph::buffer::list &bl) const {
     ENCODE_START(1, 1, bl);
     encode(pgid, bl);