]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/os/seastore: Introduce check_full_extent_integrity helper
authorMatan Breizman <mbreizma@redhat.com>
Wed, 3 Dec 2025 13:02:27 +0000 (13:02 +0000)
committerMatan Breizman <mbreizma@redhat.com>
Sun, 7 Dec 2025 11:18:28 +0000 (11:18 +0000)
This is an intermediate step to move the crc checks to Cache logic.

Signed-off-by: Matan Breizman <mbreizma@redhat.com>
src/crimson/os/seastore/transaction_manager.cc
src/crimson/os/seastore/transaction_manager.h

index ca1a45af9a77431ae68831c2d138406413c31414..f62c8a774ba13524ecae4776d53b16660e84884a 100644 (file)
@@ -625,6 +625,32 @@ TransactionManager::do_submit_transaction(
   );
 }
 
+void TransactionManager::check_full_extent_integrity(
+  Transaction &t, uint32_t ref_crc, uint32_t pin_crc)
+{
+  LOG_PREFIX(TransactionManager::check_full_extent_integrity);
+  SUBDEBUGT(seastore_tm,
+    "checksum in the lba tree: 0x{:x}, actual checksum: 0x{:x}",
+    t,
+    pin_crc,
+    ref_crc);
+  bool inconsistent = false;
+  if (full_extent_integrity_check) {
+    inconsistent = (pin_crc != ref_crc);
+  } else { // !full_extent_integrity_check: remapped extent may be skipped
+    inconsistent = !(pin_crc == 0 ||
+                     pin_crc == ref_crc);
+  }
+  if (unlikely(inconsistent)) {
+    SUBERRORT(seastore_tm,
+      "extent checksum inconsistent, recorded: 0x{:x}, actual: 0x{:x}",
+      t,
+      pin_crc,
+      ref_crc);
+      ceph_abort_msg("extent checksum inconsistent");
+  }
+}
+
 seastar::future<> TransactionManager::flush(OrderingHandle &handle)
 {
   LOG_PREFIX(TransactionManager::flush);
index 0a4b0ce36ada6a21a6be49c77d0549ad2eb444b7..884b8fe3f0c2beed2ade8a209c624ce0f56d196f 100644 (file)
@@ -1475,30 +1475,7 @@ private:
       }
     ).si_then([FNAME, &t, pin=pin, this](auto ref) mutable -> ret {
       if (ref->is_fully_loaded()) {
-        auto crc = ref->calc_crc32c();
-        SUBTRACET(
-         seastore_tm,
-         "got extent -- {}, chksum in the lba tree: 0x{:x}, actual chksum: 0x{:x}",
-         t,
-         *ref,
-         pin.get_checksum(),
-         crc);
-        bool inconsistent = false;
-        if (full_extent_integrity_check) {
-         inconsistent = (pin.get_checksum() != crc);
-        } else { // !full_extent_integrity_check: remapped extent may be skipped
-         inconsistent = !(pin.get_checksum() == 0 ||
-                           pin.get_checksum() == crc);
-        }
-        if (unlikely(inconsistent)) {
-         SUBERRORT(seastore_tm,
-           "extent checksum inconsistent, recorded: 0x{:x}, actual: 0x{:x}, {}",
-           t,
-           pin.get_checksum(),
-           crc,
-           *ref);
-         ceph_abort();
-        }
+        check_full_extent_integrity(t, ref->calc_crc32c(), pin.get_checksum());
       } else {
         assert(!full_extent_integrity_check);
       }
@@ -1508,6 +1485,9 @@ private:
     });
   }
 
+  void check_full_extent_integrity(
+    Transaction &t, uint32_t ref_crc, uint32_t pin_crc);
+
   /**
    * pin_to_extent_by_type
    *
@@ -1557,22 +1537,7 @@ private:
        pin.get_checksum(),
        crc);
       assert(ref->is_fully_loaded());
-      bool inconsistent = false;
-      if (full_extent_integrity_check) {
-       inconsistent = (pin.get_checksum() != crc);
-      } else { // !full_extent_integrity_check: remapped extent may be skipped
-       inconsistent = !(pin.get_checksum() == 0 ||
-                        pin.get_checksum() == crc);
-      }
-      if (unlikely(inconsistent)) {
-       SUBERRORT(seastore_tm,
-         "extent checksum inconsistent, recorded: 0x{:x}, actual: 0x{:x}, {}",
-         t,
-         pin.get_checksum(),
-         crc,
-         *ref);
-       ceph_abort();
-      }
+      check_full_extent_integrity(t, ref->calc_crc32c(), pin.get_checksum());
       return pin_to_extent_by_type_ret(
        interruptible::ready_future_marker{},
        std::move(ref->template cast<LogicalChildNode>()));