]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/librbd/operation/TrimRequest.cc
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / librbd / operation / TrimRequest.cc
index 6fda48aa769f4e99d5855ede2840227a69187eb1..6c6685f2b757f2582c25de06ba3c863fca4a7347 100644 (file)
@@ -223,20 +223,30 @@ void TrimRequest<I>::send_copyup_objects() {
 
   IOContext io_context;
   bool has_snapshots;
-  uint64_t parent_overlap;
+  uint64_t copyup_end;
   {
     std::shared_lock image_locker{image_ctx.image_lock};
 
     io_context = image_ctx.get_data_io_context();
     has_snapshots = !image_ctx.snaps.empty();
-    int r = image_ctx.get_parent_overlap(CEPH_NOSNAP, &parent_overlap);
+
+    uint64_t crypto_header_objects = Striper::get_num_objects(
+        image_ctx.layout,
+        image_ctx.get_area_size(io::ImageArea::CRYPTO_HEADER));
+
+    uint64_t raw_overlap;
+    int r = image_ctx.get_parent_overlap(CEPH_NOSNAP, &raw_overlap);
     ceph_assert(r == 0);
+    auto overlap = image_ctx.reduce_parent_overlap(raw_overlap, false);
+    uint64_t data_overlap_objects = Striper::get_num_objects(
+        image_ctx.layout,
+        (overlap.second == io::ImageArea::DATA ? overlap.first : 0));
+
+    // copyup is only required for portion of image that overlaps parent
+    ceph_assert(m_delete_start >= crypto_header_objects);
+    copyup_end = crypto_header_objects + data_overlap_objects;
   }
 
-  // copyup is only required for portion of image that overlaps parent
-  uint64_t copyup_end = Striper::get_num_objects(image_ctx.layout,
-                                                 parent_overlap);
-
   // TODO: protect against concurrent shrink and snap create?
   // skip to remove if no copyup is required.
   if (copyup_end <= m_delete_start || !has_snapshots) {