]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/os/seastore/cache: cleanup to use Cache::invalidate(t, conflicting_extent)
authorYingxin Cheng <yingxin.cheng@intel.com>
Wed, 14 Jul 2021 08:05:20 +0000 (16:05 +0800)
committerYingxin Cheng <yingxin.cheng@intel.com>
Tue, 20 Jul 2021 08:19:44 +0000 (16:19 +0800)
Signed-off-by: Yingxin Cheng <yingxin.cheng@intel.com>
src/crimson/os/seastore/cache.cc
src/crimson/os/seastore/cache.h

index 565f6fa8489c114bbb5f092a9cc701840637ca72..10c38d066f584da9e140429007a6585e41d25fb1 100644 (file)
@@ -417,23 +417,32 @@ void Cache::replace_extent(CachedExtentRef next, CachedExtentRef prev)
   invalidate(*prev);
 }
 
-void Cache::invalidate(CachedExtent &extent) {
+void Cache::invalidate(CachedExtent &extent)
+{
   LOG_PREFIX(Cache::invalidate);
   DEBUG("invalidate begin -- extent {}", extent);
   for (auto &&i: extent.transactions) {
     if (!i.t->conflicted) {
-      DEBUGT("set conflict", *i.t);
-      i.t->conflicted = true;
       assert(!i.t->is_weak());
-      auto m_key = std::make_pair(i.t->get_src(), extent.get_type());
-      assert(stats.trans_invalidated.count(m_key));
-      ++(stats.trans_invalidated[m_key]);
+      invalidate(*i.t, extent);
     }
   }
   DEBUG("invalidate end");
   extent.state = CachedExtent::extent_state_t::INVALID;
 }
 
+void Cache::invalidate(Transaction& t, CachedExtent& conflicting_extent)
+{
+  LOG_PREFIX(Cache::invalidate);
+  assert(!t.conflicted);
+  DEBUGT("set conflict", t);
+  t.conflicted = true;
+  auto m_key = std::make_pair(
+      t.get_src(), conflicting_extent.get_type());
+  assert(stats.trans_invalidated.count(m_key));
+  ++(stats.trans_invalidated[m_key]);
+}
+
 CachedExtentRef Cache::alloc_new_extent_by_type(
   Transaction &t,       ///< [in, out] current transaction
   extent_types_t type,  ///< [in] type tag
index 9c51cf446bb150edf6612acf62b96879eb54b3d8..f7389158d4c21c40fd694b8a07e1666d8e24922f 100644 (file)
@@ -307,10 +307,7 @@ public:
          if (!ref->is_valid()) {
            LOG_PREFIX(Cache::get_extent);
            DEBUGT("got invalid extent: {}", t, ref);
-           t.conflicted = true;
-           auto m_key = std::make_pair(t.get_src(), T::TYPE);
-           assert(stats.trans_invalidated.count(m_key));
-           ++(stats.trans_invalidated[m_key]);
+           invalidate(t, *ref.get());
            return get_extent_iertr::make_ready_future<TCachedExtentRef<T>>();
          } else {
            t.add_to_read_set(ref);
@@ -359,10 +356,7 @@ public:
         if (!ret->is_valid()) {
           LOG_PREFIX(Cache::get_extent_by_type);
           DEBUGT("got invalid extent: {}", t, ret);
-          t.conflicted = true;
-          auto m_key = std::make_pair(t.get_src(), type);
-          assert(stats.trans_invalidated.count(m_key));
-          ++(stats.trans_invalidated[m_key]);
+          invalidate(t, *ret.get());
           return get_extent_ertr::make_ready_future<CachedExtentRef>();
         } else {
           t.add_to_read_set(ret);
@@ -647,6 +641,9 @@ private:
   /// Invalidate extent and mark affected transactions
   void invalidate(CachedExtent &extent);
 
+  /// Mark a valid transaction as conflicted
+  void invalidate(Transaction& t, CachedExtent& conflicting_extent);
+
   template <typename T>
   get_extent_ret<T> read_extent(
     TCachedExtentRef<T>&& extent