]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
crimson/os/seastore/Onode: support get object/clone prefix
authorZhang Song <zhangsong02@qianxin.com>
Thu, 22 May 2025 08:58:14 +0000 (16:58 +0800)
committerXuehan Xu <xuxuehan@qianxin.com>
Thu, 21 May 2026 07:32:55 +0000 (15:32 +0800)
Signed-off-by: Zhang Song <zhangsong02@qianxin.com>
Signed-off-by: Xuehan Xu <xuxuehan@qianxin.com>
src/crimson/os/seastore/onode.h

index d3e828eb32d1c17b5f432a8adf0fab614561384a..82e2b37f994ed01a4d1f6bb58c2be8e1c12af5cb 100644 (file)
@@ -117,6 +117,44 @@ public:
   const omap_root_le_t& get_root(omap_type_t type) const {
     return get_layout().get_root(type);
   }
+  std::optional<laddr_t> get_clone_prefix() const {
+    std::optional<laddr_t> prefix = std::nullopt;
+
+    const auto &layout = get_layout();
+    auto omap_root = layout.omap_root.get(L_ADDR_NULL);
+    if (!omap_root.is_null()) {
+      prefix.emplace(omap_root.addr.get_clone_prefix());
+    }
+
+    auto xattr_root = layout.xattr_root.get(L_ADDR_NULL);
+    if (!xattr_root.is_null()) {
+      auto laddr = xattr_root.addr.get_clone_prefix();
+      if (prefix) {
+        ceph_assert(*prefix == laddr);
+      } else {
+        prefix.emplace(laddr);
+      }
+    }
+
+    auto obj_data = layout.object_data.get();
+    if (!obj_data.is_null()) {
+      auto laddr = obj_data.get_reserved_data_base().get_clone_prefix();
+      if (prefix) {
+        ceph_assert(*prefix == laddr);
+      } else {
+        prefix.emplace(laddr);
+      }
+    }
+
+    return prefix;
+  }
+  std::optional<laddr_t> get_object_prefix() const {
+    auto prefix = get_clone_prefix();
+    if (prefix) {
+      return prefix->get_object_prefix();
+    }
+    return std::nullopt;
+  }
   friend std::ostream& operator<<(std::ostream &out, const Onode &rhs);
 };