]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw/notification: Prevent reserved_size leak by decrementing overhead on commit/abort.
authorKrunal Chheda <kchheda3@bloomberg.net>
Mon, 2 Feb 2026 21:04:52 +0000 (16:04 -0500)
committerkchheda3 <kchheda3@bloomberg.net>
Fri, 27 Feb 2026 19:05:06 +0000 (19:05 +0000)
Signed-off-by: kchheda3 <kchheda3@bloomberg.net>
(cherry picked from commit 00ad83d3ab23b7da8e9fc1813f7214ffd153e314)

src/cls/2pc_queue/cls_2pc_queue.cc

index 759d360b014846ec0736020b9a004290322bea94..0e4e73f4a32727e871731be599499b32cbb470e7 100644 (file)
@@ -297,7 +297,8 @@ static int cls_2pc_queue_commit(cls_method_context_t hctx, bufferlist *in, buffe
     return ret;
   }
 
-  urgent_data.reserved_size -= res.size;
+  const auto overhead = res.entries * QUEUE_ENTRY_OVERHEAD;
+  urgent_data.reserved_size -= (res.size + overhead);
   urgent_data.committed_entries += res.entries;
 
   if (xattr_reservations.empty()) {
@@ -383,7 +384,9 @@ static int cls_2pc_queue_abort(cls_method_context_t hctx, bufferlist *in, buffer
       CLS_LOG(20, "INFO: cls_2pc_queue_abort: reservation does not exist: %u", abort_op.id);
       return 0;
     }
-    reservation_size = it->second.size;
+    const auto reservation_overhead = it->second.entries *
+        QUEUE_ENTRY_OVERHEAD;
+    reservation_size = it->second.size + reservation_overhead;
     xattr_reservations.erase(it);
     bl_xattrs.clear();
     encode(xattr_reservations, bl_xattrs);
@@ -393,8 +396,10 @@ static int cls_2pc_queue_abort(cls_method_context_t hctx, bufferlist *in, buffer
       return ret;
     }
   } else {
-    reservation_size = it->second.size;
-    urgent_data.reservations.erase(it);
+      const auto reservation_overhead = it->second.entries *
+          QUEUE_ENTRY_OVERHEAD;
+      reservation_size = it->second.size + reservation_overhead;
+      urgent_data.reservations.erase(it);
   }
 
   // remove the reservation
@@ -490,7 +495,9 @@ static int cls_2pc_queue_expire_reservations(cls_method_context_t hctx, bufferli
   for (auto it = urgent_data.reservations.begin(); it != urgent_data.reservations.end();) {
     if (it->second.timestamp < expire_op.stale_time) {
       CLS_LOG(5, "WARNING: cls_2pc_queue_expire_reservations: stale reservation %u will be removed", it->first);
-      reservation_size += it->second.size;
+      const auto reservation_overhead = it->second.entries *
+          QUEUE_ENTRY_OVERHEAD;
+      reservation_size += it->second.size + reservation_overhead;
       it = urgent_data.reservations.erase(it);
       stale_found = true;
     } else {
@@ -519,7 +526,9 @@ static int cls_2pc_queue_expire_reservations(cls_method_context_t hctx, bufferli
       for (auto it = xattr_reservations.begin(); it != xattr_reservations.end();) {
         if (it->second.timestamp < expire_op.stale_time) {
           CLS_LOG(5, "WARNING: cls_2pc_queue_expire_reservations: stale reservation %u will be removed", it->first);
-          reservation_size += it->second.size;
+          const auto reservation_overhead = it->second.entries *
+              QUEUE_ENTRY_OVERHEAD;
+          reservation_size += it->second.size + reservation_overhead;
           it = xattr_reservations.erase(it);
           xattr_stale_found = true;
         } else {