]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/onode-staged-tree: implement a ghobject_t constructor
authorYingxin Cheng <yingxin.cheng@intel.com>
Thu, 3 Dec 2020 01:58:02 +0000 (09:58 +0800)
committerYingxin Cheng <yingxin.cheng@intel.com>
Thu, 3 Dec 2020 01:58:02 +0000 (09:58 +0800)
Signed-off-by: Yingxin Cheng <yingxin.cheng@intel.com>
src/common/hobject.h
src/crimson/os/seastore/onode_manager/staged-fltree/tree_utils.h
src/test/crimson/seastore/onode_tree/test_staged_fltree.cc

index a3812b9b1542f076f89ea43312809edfdc8f7211..b7d4895c33ed0678a3ec63621a568ee68575f61e 100644 (file)
@@ -397,6 +397,14 @@ public:
       shard_id(shard),
       max(false) {}
 
+  ghobject_t(shard_id_t shard, int64_t pool, uint32_t hash,
+             const std::string& nspace, const std::string& oid,
+             snapid_t snap, gen_t gen)
+    : hobj(object_t(oid), "", snap, hash, pool, nspace),
+      generation(gen),
+      shard_id(shard),
+      max(false) {}
+
   static ghobject_t make_pgmeta(int64_t pool, uint32_t hash, shard_id_t shard) {
     hobject_t h(object_t(), std::string(), CEPH_NOSNAP, hash, pool, std::string());
     return ghobject_t(h, NO_GEN, shard);
index cdefd1ae1293fd08ca9b6ddcd5dfb94d8d994f10..b7ca22a8256ad45d60165788fa6611c6705c2f12 100644 (file)
 #include "stages/key_layout.h"
 #include "tree.h"
 
-namespace crimson::os::seastore::onode {
+/**
+ * tree_utils
+ *
+ * Contains shared logic for unit tests and perf tool.
+ */
 
-ghobject_t make_ghobj(
-    int shard, unsigned pool, unsigned crush,
-    std::string ns, std::string oid, unsigned snap, unsigned gen) {
-  assert(shard <= std::numeric_limits<shard_t>::max());
-  assert(shard >= std::numeric_limits<shard_t>::min());
-  assert(pool <= std::numeric_limits<pool_t>::max());
-  assert(crush <= std::numeric_limits<crush_hash_t>::max());
-  assert(snap <= std::numeric_limits<snap_t>::max());
-  assert(gen <= std::numeric_limits<gen_t>::max());
-  ghobject_t ghobj;
-  ghobj.shard_id.id = shard;
-  ghobj.hobj.pool = pool;
-  ghobj.hobj.set_hash(crush);
-  ghobj.hobj.nspace = ns;
-  ghobj.hobj.oid.name = oid;
-  ghobj.hobj.snap = snap;
-  ghobj.generation = gen;
-  return ghobj;
-}
+namespace crimson::os::seastore::onode {
 
 class Onodes {
  public:
@@ -130,7 +116,7 @@ class KVPool {
       assert(oid_size >= current_size);
       os_oid << std::string(oid_size - current_size, '_');
 
-      return make_ghobj(index2, index2, index2,
+      return ghobject_t(shard_id_t(index2), index2, index2,
                         os_ns.str(), os_oid.str(), index0, index0);
     }
   };
index 3441a6698de96036ca1665a7e0393299aa353bc9..e29481c23e3029e8047841b25a2631a1c59910c5 100644 (file)
@@ -27,6 +27,12 @@ namespace {
     return crimson::get_logger(ceph_subsys_test);
   }
 
+  ghobject_t make_ghobj(
+      shard_t shard, pool_t pool, crush_hash_t crush,
+      std::string ns, std::string oid, snap_t snap, gen_t gen) {
+    return ghobject_t{shard_id_t{shard}, pool, crush, ns, oid, snap, gen};
+  }
+
   // return a key_view_t and its underlying memory buffer.
   // the buffer needs to be freed manually.
   std::pair<key_view_t, void*> build_key_view(const ghobject_t& hobj) {