]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/onode-staged-tree: define and use _MIN/_MAX_OID internally
authorYingxin Cheng <yingxin.cheng@intel.com>
Thu, 29 Apr 2021 02:08:17 +0000 (10:08 +0800)
committerYingxin Cheng <yingxin.cheng@intel.com>
Sat, 8 May 2021 02:04:46 +0000 (10:04 +0800)
Signed-off-by: Yingxin Cheng <yingxin.cheng@intel.com>
src/crimson/os/seastore/onode_manager/staged-fltree/stages/key_layout.h
src/test/crimson/seastore/onode_tree/test_staged_fltree.cc

index 425c8cd59526bc909929a8a13107ba3bea3edba0..83afad7e6177100a033736d1134ab4a4c768a5ad 100644 (file)
@@ -464,6 +464,22 @@ inline MatchKindCMP compare_to(const ns_oid_view_t& l, const ns_oid_view_t& r) {
                     string_view_masked_t{r.oid});
 }
 
+inline const ghobject_t _MIN_OID() {
+  assert(ghobject_t().is_min());
+  // don't extern _MIN_OID
+  return ghobject_t();
+}
+
+/*
+ * Unfortunally the ghobject_t representitive as tree key doesn't have max
+ * field, so we define our own _MAX_OID and translate it from/to
+ * ghobject_t::get_max() if necessary.
+ */
+inline const ghobject_t _MAX_OID() {
+  return ghobject_t(shard_id_t(MAX_SHARD), MAX_POOL, MAX_CRUSH,
+                    "MAX", "MAX", MAX_SNAP, MAX_GEN);
+}
+
 /**
  * key_hobj_t
  *
@@ -472,7 +488,17 @@ inline MatchKindCMP compare_to(const ns_oid_view_t& l, const ns_oid_view_t& r) {
  */
 class key_hobj_t {
  public:
-  explicit key_hobj_t(const ghobject_t& ghobj) : ghobj{ghobj} {}
+  explicit key_hobj_t(const ghobject_t& _ghobj) {
+    if (_ghobj.is_max()) {
+      ghobj = _MAX_OID();
+    } else {
+      // including when _ghobj.is_min()
+      ghobj = _ghobj;
+    }
+    // I can be in the range of [_MIN_OID, _MAX_OID]
+    assert(ghobj >= _MIN_OID());
+    assert(ghobj <= _MAX_OID());
+  }
   /*
    * common interfaces as a full_key_t
    */
index 52160c766b6960e0d8d99eab99d4da34dccceff6..c621fc9df0bcff9f21793e185643503e03f59bc3 100644 (file)
@@ -202,9 +202,8 @@ TEST_F(b_dummy_tree_test_t, 3_random_insert_erase_leaf_node)
   run_async([this] {
     logger().info("\n---------------------------------------------"
                   "\nrandomized leaf node insert:\n");
-    auto key_s = make_ghobj(0, 0, 0, "ns", "oid", 0, 0);
-    auto key_e = make_ghobj(
-        std::numeric_limits<shard_t>::max(), 0, 0, "ns", "oid", 0, 0);
+    auto key_s = ghobject_t();
+    auto key_e = ghobject_t::get_max();
     ASSERT_TRUE(tree.find(t, key_s).unsafe_get0().is_end());
     ASSERT_TRUE(tree.begin(t).unsafe_get0().is_end());
     ASSERT_TRUE(tree.last(t).unsafe_get0().is_end());