]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/os/seastore/cache: add maybe_wait_accessible() for lba bottom-up
authorXuehan Xu <xuxuehan@qianxin.com>
Wed, 11 Jun 2025 07:26:23 +0000 (15:26 +0800)
committerXuehan Xu <xuxuehan@qianxin.com>
Tue, 1 Jul 2025 07:36:37 +0000 (15:36 +0800)
search

Signed-off-by: Xuehan Xu <xuxuehan@qianxin.com>
src/crimson/os/seastore/cache.h
src/crimson/os/seastore/linked_tree_node.h

index e7a78fe23832726fdd2cc66518d9179728aab9ba..f0e65ee9235aa0e1c83b923d49c252e57bb88db2 100644 (file)
@@ -464,6 +464,73 @@ public:
     return view->is_data_stable();
   }
 
+  get_extent_iertr::future<> maybe_wait_accessible(
+    Transaction &t,
+    CachedExtent &extent) final {
+    // as of now, only lba tree nodes can go in here,
+    // so it must be fully loaded.
+    assert(extent.is_valid());
+    assert(extent.is_fully_loaded());
+    const auto t_src = t.get_src();
+    auto ext_type = extent.get_type();
+    assert(!is_retired_placeholder_type(ext_type));
+    cache_access_stats_t& access_stats = get_by_ext(
+      get_by_src(stats.access_by_src_ext, t_src),
+      ext_type);
+    if (extent.is_stable()) {
+      // stable from trans-view
+      bool needs_touch = false, needs_step_2 = false;
+      assert(!extent.is_pending_in_trans(t.get_trans_id()));
+      auto ret = t.maybe_add_to_read_set(&extent);
+      if (ret.added) {
+       if (extent.is_stable_dirty()) {
+         ++access_stats.cache_dirty;
+         ++stats.access.cache_dirty;
+       } else {
+         ++access_stats.cache_lru;
+         ++stats.access.cache_lru;
+       }
+       if (ret.is_paddr_known) {
+         touch_extent(extent, &t_src, t.get_cache_hint());
+       } else {
+         needs_touch = true;
+       }
+      } else {
+       // already exists
+       if (extent.is_stable_dirty()) {
+         ++access_stats.trans_dirty;
+         ++stats.access.trans_dirty;
+       } else {
+         ++access_stats.trans_lru;
+         ++stats.access.trans_lru;
+       }
+      }
+      // step 2 maybe reordered after wait_io(),
+      // always try step 2 if paddr unknown
+      needs_step_2 = !ret.is_paddr_known;
+
+      return trans_intr::make_interruptible(
+       extent.wait_io()
+      ).then_interruptible([&extent, needs_touch,
+                           needs_step_2, &t, this, t_src] {
+       if (needs_step_2) {
+         t.maybe_add_to_read_set_step_2(&extent);
+       }
+       if (needs_touch) {
+         touch_extent(extent, &t_src, t.get_cache_hint());
+       }
+       return get_extent_iertr::now();
+      });
+    } else {
+      assert(extent.is_mutable());
+      assert(!extent.is_pending_io());
+      assert(extent.is_pending_in_trans(t.get_trans_id()));
+      ++access_stats.trans_pending;
+      ++stats.access.trans_pending;
+      return get_extent_iertr::now();
+    }
+  }
+
   get_extent_iertr::future<CachedExtentRef>
   get_extent_viewable_by_trans(
     Transaction &t,
index 61415c75934567ae8ea23d4649e3667702e7a91b..809268d8a61310f61a33dec2a44768548bbc95f1 100644 (file)
@@ -249,6 +249,8 @@ public:
       return ext->template cast<T>();
     });
   }
+  virtual get_child_iertr::future<> maybe_wait_accessible(
+    Transaction &, CachedExtent&) = 0;
   virtual bool is_viewable_extent_data_stable(Transaction &, CachedExtentRef) = 0;
   virtual bool is_viewable_extent_stable(Transaction &, CachedExtentRef) = 0;
   virtual ~ExtentTransViewRetriever() {}