]> 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)
committerKrunal Chheda <kchheda3@bloomberg.net>
Mon, 2 Feb 2026 21:04:52 +0000 (16:04 -0500)
Signed-off-by: kchheda3 <kchheda3@bloomberg.net>
src/cls/2pc_queue/cls_2pc_queue.cc

index ddc7891bcabd350b723d8cdd3fd00ce8f796284a..64c03cff5ad166b7305224c0f830b3f9a11159a6 100644 (file)
@@ -299,7 +299,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()) {
@@ -385,7 +386,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);
@@ -395,8 +398,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
@@ -492,7 +497,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 {
@@ -521,7 +528,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 {