]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/os/seastore: more accurate usages to is_mutable() vs is_data_stable()
authorYingxin Cheng <yingxin.cheng@intel.com>
Wed, 21 May 2025 03:54:05 +0000 (11:54 +0800)
committerYingxin Cheng <yingxin.cheng@intel.com>
Wed, 4 Jun 2025 02:17:52 +0000 (10:17 +0800)
Generally, prefer is_mutable() than !is_data_stable(), and
is_data_stable() than !is_mutable().

Signed-off-by: Yingxin Cheng <yingxin.cheng@intel.com>
src/crimson/os/seastore/cache.cc
src/crimson/os/seastore/cache.h
src/crimson/os/seastore/cached_extent.h
src/crimson/os/seastore/onode_manager/staged-fltree/node_extent_accessor.h
src/crimson/os/seastore/transaction_manager.h

index db2ff1ff0a615de3e51871aa942d56c6a733e6c9..dacadba80314ae8a029d93a4e24c9d23ee8dc27c 100644 (file)
@@ -1162,6 +1162,7 @@ CachedExtentRef Cache::duplicate_for_write(
   Transaction &t,
   CachedExtentRef i) {
   LOG_PREFIX(Cache::duplicate_for_write);
+  ceph_assert(i->is_valid());
   assert(i->is_fully_loaded());
 
 #ifndef NDEBUG
index 049df6f8202919c1f40d5dff3a0286e1d98921e2..9d3193b9e9cbf169cc45b8de689c212320edde09 100644 (file)
@@ -633,7 +633,7 @@ private:
     //
     // TODO(implement fine-grained-wait)
     assert(!extent->is_range_loaded(partial_off, partial_len));
-    assert(!extent->is_mutable());
+    assert(extent->is_data_stable());
     if (extent->is_pending_io()) {
       std::optional<Transaction::src_t> src;
       if (p_src) {
@@ -1685,7 +1685,7 @@ private:
       CachedExtent &extent,
       extent_len_t increased_length,
       const Transaction::src_t* p_src) {
-      assert(!extent.is_mutable());
+      assert(extent.is_data_stable());
 
       if (extent.primary_ref_list_hook.is_linked()) {
         assert(extent.is_stable_clean() && !extent.is_placeholder());
index 8775a69444a5d7d1def78d8af5a4182ae2affa14..38f44502db89c30d61ed996cad5b6503555337a4 100644 (file)
@@ -542,7 +542,8 @@ public:
     return TCachedExtentRef<const T>(static_cast<const T*>(this));
   }
 
-  /// Returns true if extent can be mutated in an open transaction
+  /// Returns true if extent can be mutated in an open transaction,
+  /// normally equivalent to !is_data_stable.
   bool is_mutable() const {
     return state == extent_state_t::INITIAL_WRITE_PENDING ||
       state == extent_state_t::MUTATION_PENDING ||
@@ -578,6 +579,8 @@ public:
     return is_stable_written() || is_stable_writting();
   }
 
+  /// Returns true if extent can not be mutated,
+  /// normally equivalent to !is_mutable.
   bool is_data_stable() const {
     return is_stable() || is_exist_clean();
   }
index 14cd2ef3a8db1038d50005e1a4884c32187e7cf2..49c29710bc29c434ef01be51f9d253ed07451176 100644 (file)
@@ -305,7 +305,7 @@ class NodeExtentAccessorT {
       assert(p_recorder->node_type() == NODE_TYPE);
       assert(p_recorder->field_type() == FIELD_TYPE);
       recorder = static_cast<recorder_t*>(p_recorder);
-    } else if (!extent->is_mutable() && extent->is_valid()) {
+    } else if (extent->is_stable()) {
       state = nextent_state_t::READ_ONLY;
       // mut is empty
       assert(extent->get_recorder() == nullptr ||
@@ -355,7 +355,7 @@ class NodeExtentAccessorT {
   void prepare_mutate(context_t c) {
     assert(!is_retired());
     if (state == nextent_state_t::READ_ONLY) {
-      assert(!extent->is_mutable());
+      assert(extent->is_stable());
       auto ref_recorder = recorder_t::create_for_encode(c.vb);
       recorder = static_cast<recorder_t*>(ref_recorder.get());
       extent = extent->mutate(c, std::move(ref_recorder));
index 8e3fe2e9f078568067c127e60f5d8c87acb8621a..0238307a9745db994331d8205d5314289eb250e1 100644 (file)
@@ -563,7 +563,7 @@ public:
          std::optional<ceph::bufferptr> original_bptr;
          // TODO: preserve the bufferspace if partially loaded
          if (ext && ext->is_fully_loaded()) {
-           ceph_assert(!ext->is_mutable());
+           ceph_assert(ext->is_data_stable());
            ceph_assert(ext->get_length() >= original_len);
            ceph_assert(ext->get_paddr() == original_paddr);
            original_bptr = ext->get_bptr();