adoroszlai commented on code in PR #7927:
URL: https://github.com/apache/ozone/pull/7927#discussion_r1965140992


##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/volume/VolumeUsage.java:
##########
@@ -68,23 +68,24 @@ SpaceUsageSource realUsage() {
   /**
    * <pre>
    * {@code
-   * Calculate available space use method B.
-   * |----used----|   (avail)   |++++++++reserved++++++++|
-   *              |     fsAvail      |-------other-------|
-   *                          -&gt;|~~~~|&lt;-
-   *                      remainingReserved
+   * Calculate available space.
+   * |----used----|                 fsFree                 |
+   * |----used----|          fsAvail           |---other---|
+   * |----used----|   (avail)   |+++reserved+++|---other---|
+   * |<-                    fsCapacity                   ->|
+   * |<-           usableCapacity            ->|
+   * |<-       capacity      ->|
    * }
    * </pre>
-   * B) avail = fsAvail - Max(reserved - other, 0);
+   * capacity = max(usableCapacity - reserved, 0);
+   * avail = max(fsAvail - reserved, 0);
    */
   public SpaceUsageSource getCurrentUsage() {
     SpaceUsageSource real = realUsage();
 
-    return reservedInBytes == 0
-        ? real
-        : new SpaceUsageSource.Fixed(
-            Math.max(real.getCapacity() - reservedInBytes, 0),
-            Math.max(real.getAvailable() - getRemainingReserved(real), 0),
+    return new SpaceUsageSource.Fixed(
+            Math.max(getUsableCapacity(real) - reservedInBytes, 0),
+            Math.max(real.getAvailable() - reservedInBytes, 0),
             real.getUsedSpace());

Review Comment:
   `SpaceUsageSource real` reflects capacity from the filesystem 
(`File.getTotalSpace()`).  Now in the value returned from `getCurrentUsage()` 
that information is lost.
   
   If `sysReserved` cannot be used, ever, and total disk space (`fsCapacity`) 
is irrelevant, then we should change the way source calculates capacity here:
   
   
https://github.com/apache/ozone/blob/e0bd2cc71621087e41cbc0b79f72b6487d271264/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/fs/AbstractSpaceUsageSource.java#L88-L89
   
   and change `getCurrentUsage()`:
   
   ```java
     public SpaceUsageSource getCurrentUsage() {
       SpaceUsageSource real = realUsage();
   
       return reservedInBytes == 0
           ? real
           : new SpaceUsageSource.Fixed(
               Math.max(real.getCapacity() - reservedInBytes, 0),
               Math.max(real.getAvailable() - reservedInBytes, 0),
               real.getUsedSpace());
   ```



-- 
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