]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
osd: Fix incorrect invalidate_crc during slice iterate
authorAlex Ainscow <aainscow@uk.ibm.com>
Fri, 20 Jun 2025 10:48:59 +0000 (11:48 +0100)
committerAlex Ainscow <aainscow@uk.ibm.com>
Sun, 7 Sep 2025 23:10:41 +0000 (00:10 +0100)
The CRCs were being invalidate at the wrong point, so the last CRC was
not being invalidated.

Signed-off-by: Alex Ainscow <aainscow@uk.ibm.com>
(cherry picked from commit 564b53c446201ed33b5345c936c3c4b5d32bdaab)

src/osd/ECUtil.h

index 0d02130f93c4f28a94f9f60cde05bf8b37473ff8..89ed7878bb07220ac89b44901124670ba9ec06f6 100644 (file)
@@ -211,22 +211,26 @@ class slice_iterator {
 
         // If we have reached the end of the extent, we need to move that on too.
         if (bl_iter == emap_iter.get_val().end()) {
+          // NOTE: Despite appearances, the following is happening BEFORE
+          // the caller gets to use the buffer pointers (since the in/out is
+          // set a few lines above).  This means that the caller must not
+          // check the CRC.
+          if (out_set.contains(shard)) {
+            invalidate_crcs(shard);
+          }
           ++emap_iter;
           if (emap_iter == input[shard].end()) {
             erase = true;
           } else {
-            if (out_set.contains(shard)) {
-              bufferlist bl = emap_iter.get_val();
-              bl.invalidate_crc();
-            }
             iters.at(shard).second = emap_iter.get_val().begin();
             if (zeros) {
               zeros->emplace(shard, emap_iter.get_off(), emap_iter.get_len());
             }
           }
         }
-      } else
+      } else {
         ceph_assert(iter_offset > start);
+      }
 
       if (erase) {
         iter = iters.erase(iter);
@@ -249,6 +253,11 @@ class slice_iterator {
     }
   }
 
+  void invalidate_crcs(shard_id_t shard) {
+    bufferlist bl = iters.at(shard).first.get_val();
+    bl.invalidate_crc();
+  }
+
 public:
   slice_iterator(
       mini_flat_map<shard_id_t, extent_map> &_input,