priyeshkaratha commented on code in PR #10105:
URL: https://github.com/apache/ozone/pull/10105#discussion_r3122374772


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/DeletedBlockLogImpl.java:
##########
@@ -169,12 +169,45 @@ private DeletedBlocksTransaction constructNewTransaction(
       // even when HDDSLayoutFeature.STORAGE_SPACE_DISTRIBUTION is finalized, 
old OM can still call the old API
       if (replicatedSize >= 0) {
         builder.setTotalBlockReplicatedSize(replicatedSize);
-        
builder.setTotalBlockSize(blocks.stream().mapToLong(DeletedBlock::getSize).sum());
+        builder.setTotalBlockSize(computePerReplicaBlockSize(containerID, 
replicatedSize, blocks));
       }
     }
     return builder.build();
   }
 
+  /**
+   * Computes the per-replica block size for a delete transaction.
+   *
+   * <p>Each DN replica receives the same {@link DeletedBlocksTransaction} and
+   * increments its local pending-deletion byte counter by
+   * {@code totalBlockSize}. DN then sums these counters across all replicas.
+   * To make that sum equal the total physical bytes being freed
+   * ({@code totalBlockReplicatedSize}), each replica must track
+   * {@code totalBlockReplicatedSize / replicationFactor}.
+   *
+   * <p>For Ratis(N) this is algebraically identical to the logical block size
+   * (no change in behaviour). For EC(k+m) it corrects the previous k+m-fold
+   * over-count.
+   */
+  private long computePerReplicaBlockSize(long containerID, long 
replicatedSize,
+      List<DeletedBlock> blocks) {
+    if (replicatedSize > 0) {
+      try {
+        int requiredNodes = containerManager

Review Comment:
   Yes, the > 0 check is intentional.
   
   When replicatedSize == 0 it means old OM did not set the replicated-size 
field. We have no basis to compute the per-replica size, so we fall back to 
sum(block.getSize()) — the same value that was used before this fix. This 
avoids a regression (zeroing out totalBlockSize) for old OM clients, even 
though the EC inflation is not fixed in that path. The fix only applies when 
new OM provides a valid replicatedSize > 0



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to