@@ -331,7 +331,7 @@ TransactionManager::update_lba_mappings(
331331 std::list<LogicalCachedExtentRef>(),
332332 std::list<CachedExtentRef>(),
333333 [this , &t, &pre_allocated_extents](auto &lextents, auto &pextents) {
334- auto chksum_func = [&lextents, &pextents](auto &extent) {
334+ auto chksum_func = [&lextents, &pextents, this ](auto &extent) {
335335 if (!extent->is_valid () ||
336336 !extent->is_fully_loaded () ||
337337 // EXIST_MUTATION_PENDING extents' crc will be calculated when
@@ -343,10 +343,20 @@ TransactionManager::update_lba_mappings(
343343 // for rewritten extents, last_committed_crc should have been set
344344 // because the crc of the original extent may be reused.
345345 // also see rewrite_logical_extent()
346- if (!extent->get_last_committed_crc ()) {
347- extent->set_last_committed_crc (extent->calc_crc32c ());
348- }
349- assert (extent->calc_crc32c () == extent->get_last_committed_crc ());
346+ if (!extent->get_last_committed_crc ()) {
347+ if (get_checksum_needed (extent->get_paddr ())) {
348+ extent->set_last_committed_crc (extent->calc_crc32c ());
349+ } else {
350+ extent->set_last_committed_crc (CRC_NULL);
351+ }
352+ }
353+ #ifndef NDEBUG
354+ if (get_checksum_needed (extent->get_paddr ())) {
355+ assert (extent->get_last_committed_crc () == extent->calc_crc32c ());
356+ } else {
357+ assert (extent->get_last_committed_crc () == CRC_NULL);
358+ }
359+ #endif
350360 lextents.emplace_back (extent->template cast <LogicalCachedExtent>());
351361 } else {
352362 pextents.emplace_back (extent);
@@ -367,15 +377,20 @@ TransactionManager::update_lba_mappings(
367377
368378 return lba_manager->update_mappings (
369379 t, lextents
370- ).si_then ([&pextents] {
380+ ).si_then ([&pextents, this ] {
371381 for (auto &extent : pextents) {
372382 assert (!extent->is_logical () && extent->is_valid ());
373383 // for non-logical extents, we update its last_committed_crc
374384 // and in-extent checksum fields
375385 // For pre-allocated fresh physical extents, update in-extent crc.
376- auto crc = extent->calc_crc32c ();
377- extent->set_last_committed_crc (crc);
378- extent->update_in_extent_chksum_field (crc);
386+ checksum_t crc;
387+ if (get_checksum_needed (extent->get_paddr ())) {
388+ crc = extent->calc_crc32c ();
389+ } else {
390+ crc = CRC_NULL;
391+ }
392+ extent->set_last_committed_crc (crc);
393+ extent->update_in_extent_chksum_field (crc);
379394 }
380395 });
381396 });
@@ -516,7 +531,13 @@ TransactionManager::rewrite_logical_extent(
516531
517532 DEBUGT (" rewriting logical extent -- {} to {}" , t, *lextent, *nlextent);
518533
519- assert (lextent->get_last_committed_crc () == lextent->calc_crc32c ());
534+ #ifndef NDEBUG
535+ if (get_checksum_needed (lextent->get_paddr ())) {
536+ assert (lextent->get_last_committed_crc () == lextent->calc_crc32c ());
537+ } else {
538+ assert (lextent->get_last_committed_crc () == CRC_NULL);
539+ }
540+ #endif
520541 nlextent->set_last_committed_crc (lextent->get_last_committed_crc ());
521542 /* This update_mapping is, strictly speaking, unnecessary for delayed_alloc
522543 * extents since we're going to do it again once we either do the ool write
0 commit comments