]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/os/seastore: misc cleanups and asserts
authorYingxin Cheng <yingxin.cheng@intel.com>
Wed, 23 Oct 2024 08:40:26 +0000 (16:40 +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/cache.h
src/crimson/os/seastore/transaction_manager.h

index e93e0f91a9b4f6ec89aaf0575ef7700346f2f767..6303f50b3cc1a198c7d31849d79544d6227a1fe3 100644 (file)
@@ -400,6 +400,7 @@ public:
                 t, T::TYPE, offset, length, *ret);
       ceph_abort("impossible");
     } else if (result == Transaction::get_extent_ret::PRESENT) {
+      assert(ret->get_length() == length);
       if (ret->is_fully_loaded()) {
         SUBTRACET(seastore_cache, "{} {}~{} is present on t -- {}",
                   t, T::TYPE, offset, length, *ret);
@@ -584,6 +585,7 @@ public:
     // user should not see RETIRED_PLACEHOLDER extents
     ceph_assert(!is_retired_placeholder_type(p_extent->get_type()));
     if (!p_extent->is_fully_loaded()) {
+      assert(is_logical_type(p_extent->get_type()));
       assert(!p_extent->is_mutable());
       ++access_stats.load_present;
       ++stats.access.s.load_present;
@@ -689,30 +691,26 @@ private:
       extent_init_func(*ret);
       return read_extent<T>(
        std::move(ret));
-    } else if (!cached->is_fully_loaded()) {
-      auto ret = TCachedExtentRef<T>(static_cast<T*>(cached.get()));
-      on_cache(*ret);
+    }
+
+    auto ret = TCachedExtentRef<T>(static_cast<T*>(cached.get()));
+    on_cache(*ret);
+    if (ret->is_fully_loaded()) {
+      SUBTRACE(seastore_cache,
+          "{} {}~{} is present in cache -- {}",
+          T::TYPE, offset, length, *ret);
+      return ret->wait_io().then([ret] {
+        // ret may be invalid, caller must check
+        return seastar::make_ready_future<TCachedExtentRef<T>>(ret);
+      });
+    } else {
       SUBDEBUG(seastore_cache,
-        "{} {}~{} is present without been fully loaded, reading ... -- {}",
-        T::TYPE, offset, length, *ret);
+          "{} {}~{} is present without been fully loaded, reading ... -- {}",
+          T::TYPE, offset, length, *ret);
       auto bp = create_extent_ptr_rand(length);
       ret->set_bptr(std::move(bp));
       return read_extent<T>(
         std::move(ret));
-    } else {
-      SUBTRACE(seastore_cache,
-          "{} {}~{} is present in cache -- {}",
-          T::TYPE, offset, length, *cached);
-      auto ret = TCachedExtentRef<T>(static_cast<T*>(cached.get()));
-      on_cache(*ret);
-      return ret->wait_io(
-      ).then([ret=std::move(ret)]() mutable
-            -> read_extent_ret<T> {
-        // ret may be invalid, caller must check
-        return read_extent_ret<T>(
-          get_extent_ertr::ready_future_marker{},
-          std::move(ret));
-      });
     }
   }
 
@@ -781,6 +779,7 @@ private:
                 t, type, offset, length, laddr, *ret);
       ceph_abort("impossible");
     } else if (status == Transaction::get_extent_ret::PRESENT) {
+      assert(ret->get_length() == length);
       if (ret->is_fully_loaded()) {
         SUBTRACET(seastore_cache, "{} {}~{} {} is present on t -- {}",
                   t, type, offset, length, laddr, *ret);
index 841c5638abc351821376ecee8d1d1c297b2c3722..5cba9c4ab38f28240b953f88bc47334b9e9300ce 100644 (file)
@@ -214,7 +214,7 @@ public:
       pin->maybe_fix_pos();
       fut = base_iertr::make_ready_future<LBAMappingRef>(std::move(pin));
     }
-    return fut.si_then([&t, this](auto npin) mutable {
+    return fut.si_then([&t, this](auto npin) {
       // checking the lba child must be atomic with creating
       // and linking the absent child
       auto ret = get_extent_if_linked<T>(t, std::move(npin));