]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/os/seastore: convert transaction related paths with interruptor
authorYingxin Cheng <yingxin.cheng@intel.com>
Wed, 20 Nov 2024 02:18:58 +0000 (10:18 +0800)
committerYingxin Cheng <yingxin.cheng@intel.com>
Thu, 28 Nov 2024 01:32:51 +0000 (09:32 +0800)
Signed-off-by: Yingxin Cheng <yingxin.cheng@intel.com>
src/crimson/os/seastore/backref/btree_backref_manager.cc
src/crimson/os/seastore/btree/fixed_kv_btree.h
src/crimson/os/seastore/cache.h
src/crimson/os/seastore/cached_extent.h
src/crimson/os/seastore/lba_manager/btree/btree_lba_manager.cc
src/crimson/os/seastore/transaction_manager.h
src/test/crimson/seastore/test_transaction_manager.cc

index f89698d602aed09689efd792e477f5fab18da919..9cbf65f403319a9311301c464fa050d5f90f45f7 100644 (file)
@@ -28,28 +28,22 @@ const get_phy_tree_root_node_ret get_phy_tree_root_node<
     ceph_assert(backref_root->is_initial_pending()
       == root_block->is_pending());
     return {true,
-           trans_intr::make_interruptible(
-             c.cache.get_extent_viewable_by_trans(c.trans, backref_root))};
+            c.cache.get_extent_viewable_by_trans(c.trans, backref_root)};
   } else if (root_block->is_pending()) {
     auto &prior = static_cast<RootBlock&>(*root_block->get_prior_instance());
     backref_root = prior.backref_root_node;
     if (backref_root) {
       return {true,
-             trans_intr::make_interruptible(
-               c.cache.get_extent_viewable_by_trans(c.trans, backref_root))};
+              c.cache.get_extent_viewable_by_trans(c.trans, backref_root)};
     } else {
       c.cache.account_absent_access(c.trans.get_src());
       return {false,
-             trans_intr::make_interruptible(
-               Cache::get_extent_ertr::make_ready_future<
-                 CachedExtentRef>())};
+              Cache::get_extent_iertr::make_ready_future<CachedExtentRef>()};
     }
   } else {
     c.cache.account_absent_access(c.trans.get_src());
     return {false,
-           trans_intr::make_interruptible(
-             Cache::get_extent_ertr::make_ready_future<
-               CachedExtentRef>())};
+            Cache::get_extent_iertr::make_ready_future<CachedExtentRef>()};
   }
 }
 
index cb4fff327501bafe6952d2eac69e8adebe6b2e67..04ebcc7e2ca10bc04e6b0d6a55c54a2736ec47ce 100644 (file)
@@ -32,10 +32,6 @@ inline ChildableCachedExtent* get_reserved_ptr() {
 template <typename T>
 phy_tree_root_t& get_phy_tree_root(root_t& r);
 
-using get_child_iertr =
-  ::crimson::interruptible::interruptible_errorator<
-    typename trans_intr::condition,
-    get_child_ertr>;
 using get_phy_tree_root_node_ret =
   std::pair<bool, get_child_iertr::future<CachedExtentRef>>;
 
@@ -1501,7 +1497,7 @@ private:
     // checking the lba child must be atomic with creating
     // and linking the absent child
     if (v.has_child()) {
-      return trans_intr::make_interruptible(std::move(v.get_child_fut())
+      return std::move(v.get_child_fut()
       ).si_then([on_found=std::move(on_found), node_iter, c,
                 parent_entry](auto child) {
         LOG_PREFIX(FixedKVBtree::lookup_internal_level);
@@ -1571,7 +1567,7 @@ private:
     // checking the lba child must be atomic with creating
     // and linking the absent child
     if (v.has_child()) {
-      return trans_intr::make_interruptible(std::move(v.get_child_fut())
+      return std::move(v.get_child_fut()
       ).si_then([on_found=std::move(on_found), node_iter, c,
                 parent_entry](auto child) {
         LOG_PREFIX(FixedKVBtree::lookup_leaf);
@@ -2126,7 +2122,7 @@ private:
     // checking the lba child must be atomic with creating
     // and linking the absent child
     if (v.has_child()) {
-      return trans_intr::make_interruptible(std::move(v.get_child_fut())
+      return std::move(v.get_child_fut()
       ).si_then([do_merge=std::move(do_merge), &pos,
                 donor_iter, donor_is_left, c, parent_pos](auto child) {
         LOG_PREFIX(FixedKVBtree::merge_level);
index b8542c393b046c5aecb5c84bbdd8f0ff26b5e9cb..520df473f2f64ac417271e7d69f70079a61d8556 100644 (file)
@@ -527,8 +527,7 @@ public:
     return view->is_data_stable();
   }
 
-  using get_extent_ertr = base_ertr;
-  get_extent_ertr::future<CachedExtentRef>
+  get_extent_iertr::future<CachedExtentRef>
   get_extent_viewable_by_trans(
     Transaction &t,
     CachedExtentRef extent)
@@ -553,7 +552,7 @@ public:
         if (p_extent->is_mutable()) {
           assert(p_extent->is_fully_loaded());
           assert(!p_extent->is_pending_io());
-          return get_extent_ertr::make_ready_future<CachedExtentRef>(
+          return get_extent_iertr::make_ready_future<CachedExtentRef>(
             CachedExtentRef(p_extent));
         } else {
           assert(p_extent->is_exist_clean());
@@ -588,7 +587,7 @@ public:
       if (extent->is_mutable()) {
         assert(extent->is_fully_loaded());
         assert(!extent->is_pending_io());
-        return get_extent_ertr::make_ready_future<CachedExtentRef>(extent);
+        return get_extent_iertr::make_ready_future<CachedExtentRef>(extent);
       } else {
         assert(extent->is_exist_clean());
         p_extent = extent.get();
@@ -601,30 +600,31 @@ public:
     // also see read_extent_maybe_partial() and get_absent_extent()
     assert(is_logical_type(p_extent->get_type()) ||
            p_extent->is_fully_loaded());
-    return p_extent->wait_io(
-    ).then([p_extent] {
-      return get_extent_ertr::make_ready_future<CachedExtentRef>(
+
+    return trans_intr::make_interruptible(
+      p_extent->wait_io()
+    ).then_interruptible([p_extent] {
+      return get_extent_iertr::make_ready_future<CachedExtentRef>(
         CachedExtentRef(p_extent));
     });
   }
 
   template <typename T>
-  using read_extent_ret = get_extent_ertr::future<TCachedExtentRef<T>>;
-
-  template <typename T>
-  read_extent_ret<T> get_extent_viewable_by_trans(
+  get_extent_iertr::future<TCachedExtentRef<T>>
+  get_extent_viewable_by_trans(
     Transaction &t,
     TCachedExtentRef<T> extent)
   {
     return get_extent_viewable_by_trans(t, CachedExtentRef(extent.get())
-    ).safe_then([](auto p_extent) {
+    ).si_then([](auto p_extent) {
       return p_extent->template cast<T>();
     });
   }
 
   // wait extent io or do partial reads
   template <typename T>
-  read_extent_ret<T> read_extent_maybe_partial(
+  get_extent_iertr::future<TCachedExtentRef<T>>
+  read_extent_maybe_partial(
     Transaction &t,
     TCachedExtentRef<T> extent,
     extent_len_t partial_off,
@@ -642,13 +642,16 @@ public:
         extent->get_type());
       ++access_stats.load_present;
       ++stats.access.s.load_present;
-      return do_read_extent_maybe_partial(
-          std::move(extent), partial_off, partial_len, &t_src);
+      return trans_intr::make_interruptible(
+        do_read_extent_maybe_partial(
+          std::move(extent), partial_off, partial_len, &t_src));
     } else {
       // TODO(implement fine-grained-wait):
       // the range might be already loaded, but we don't know
-      return extent->wait_io().then([extent]() -> read_extent_ret<T> {
-        return seastar::make_ready_future<TCachedExtentRef<T>>(extent);
+      return trans_intr::make_interruptible(
+        extent->wait_io()
+      ).then_interruptible([extent] {
+        return get_extent_iertr::make_ready_future<TCachedExtentRef<T>>(extent);
       });
     }
   }
@@ -664,6 +667,9 @@ public:
   }
 
 private:
+  using get_extent_ertr = base_ertr;
+  template <typename T>
+  using read_extent_ret = get_extent_ertr::future<TCachedExtentRef<T>>;
   /// Implements exclusive call to read_extent() for the extent
   template <typename T>
   read_extent_ret<T> do_read_extent_maybe_partial(
index 0df66e37d1169cbef83a019ec7bb491666f7041e..2a54e8ded771783df2a6c04f445705e43a603932 100644 (file)
@@ -12,9 +12,8 @@
 #include "seastar/core/shared_future.hh"
 
 #include "include/buffer.h"
-#include "crimson/common/errorator.h"
-#include "crimson/common/interruptible_future.h"
 #include "crimson/os/seastore/seastore_types.h"
+#include "crimson/os/seastore/transaction_interruptor.h"
 
 struct btree_lba_manager_test;
 struct lba_btree_test;
@@ -23,7 +22,6 @@ struct cache_test_t;
 
 namespace crimson::os::seastore {
 
-class Transaction;
 class CachedExtent;
 using CachedExtentRef = boost::intrusive_ptr<CachedExtent>;
 class SegmentedAllocator;
@@ -1303,14 +1301,17 @@ private:
   uint16_t pos = std::numeric_limits<uint16_t>::max();
 };
 
-using get_child_ertr = crimson::errorator<
-  crimson::ct_error::input_output_error>;
+using get_child_iertr = trans_iertr<crimson::errorator<
+  crimson::ct_error::input_output_error>>;
+template <typename T>
+using get_child_ifut = get_child_iertr::future<TCachedExtentRef<T>>;
+
 template <typename T>
 struct get_child_ret_t {
-  std::variant<child_pos_t, get_child_ertr::future<TCachedExtentRef<T>>> ret;
+  std::variant<child_pos_t, get_child_ifut<T>> ret;
   get_child_ret_t(child_pos_t pos)
     : ret(std::move(pos)) {}
-  get_child_ret_t(get_child_ertr::future<TCachedExtentRef<T>> child)
+  get_child_ret_t(get_child_ifut<T> child)
     : ret(std::move(child)) {}
 
   bool has_child() const {
@@ -1322,7 +1323,7 @@ struct get_child_ret_t {
     return std::get<0>(ret);
   }
 
-  get_child_ertr::future<TCachedExtentRef<T>> &get_child_fut() {
+  get_child_ifut<T> &get_child_fut() {
     ceph_assert(ret.index() == 1);
     return std::get<1>(ret);
   }
index b7a1d8f8ba96686aad04f9201a765be3fd6afe51..007737ff450cc7a0b3f6ff22a0680c67d6fdf238 100644 (file)
@@ -52,28 +52,22 @@ const get_phy_tree_root_node_ret get_phy_tree_root_node<
     ceph_assert(lba_root->is_initial_pending()
       == root_block->is_pending());
     return {true,
-           trans_intr::make_interruptible(
-             c.cache.get_extent_viewable_by_trans(c.trans, lba_root))};
+            c.cache.get_extent_viewable_by_trans(c.trans, lba_root)};
   } else if (root_block->is_pending()) {
     auto &prior = static_cast<RootBlock&>(*root_block->get_prior_instance());
     lba_root = prior.lba_root_node;
     if (lba_root) {
       return {true,
-             trans_intr::make_interruptible(
-               c.cache.get_extent_viewable_by_trans(c.trans, lba_root))};
+              c.cache.get_extent_viewable_by_trans(c.trans, lba_root)};
     } else {
       c.cache.account_absent_access(c.trans.get_src());
       return {false,
-             trans_intr::make_interruptible(
-               Cache::get_extent_ertr::make_ready_future<
-                 CachedExtentRef>())};
+              Cache::get_extent_iertr::make_ready_future<CachedExtentRef>()};
     }
   } else {
     c.cache.account_absent_access(c.trans.get_src());
     return {false,
-           trans_intr::make_interruptible(
-             Cache::get_extent_ertr::make_ready_future<
-               CachedExtentRef>())};
+            Cache::get_extent_iertr::make_ready_future<CachedExtentRef>()};
   }
 }
 
index c9ce635ee8c001e904510ae15d33b84e7445005b..5bd3c679dda23753b6dc529ddc48291dbfe6830b 100644 (file)
@@ -954,7 +954,7 @@ private:
   shard_stats_t& shard_stats;
 
   template <typename T>
-  std::variant<LBAMappingRef, base_iertr::future<TCachedExtentRef<T>>>
+  std::variant<LBAMappingRef, get_child_ifut<T>>
   get_extent_if_linked(
     Transaction &t,
     LBAMappingRef pin)
@@ -964,7 +964,8 @@ private:
     // and linking the absent child
     auto v = pin->get_logical_extent(t);
     if (v.has_child()) {
-      return v.get_child_fut().safe_then([pin=std::move(pin)](auto extent) {
+      return v.get_child_fut(
+      ).si_then([pin=std::move(pin)](auto extent) {
 #ifndef NDEBUG
         auto lextent = extent->template cast<LogicalCachedExtent>();
         auto pin_laddr = pin->get_key();
index 012d1819d85a88c3bade687c14360cbf48721f2f..6e0fe65c3457bff34a2cc39cc6fed018ece4f3f5 100644 (file)
@@ -2209,9 +2209,11 @@ TEST_P(tm_single_device_test_t, invalid_lba_mapping_detect)
       assert(pin->is_parent_viewable());
       assert(pin->parent_modified());
       pin->maybe_fix_pos();
-      auto v = pin->get_logical_extent(*t.t);
-      assert(v.has_child());
-      auto extent2 = v.get_child_fut().unsafe_get();
+      auto extent2 = with_trans_intr(*(t.t), [&pin](auto& trans) {
+        auto v = pin->get_logical_extent(trans);
+        assert(v.has_child());
+        return std::move(v.get_child_fut());
+      }).unsafe_get();
       assert(extent.get() == extent2.get());
       submit_transaction(std::move(t));
     }