sadanand48 commented on code in PR #4124:
URL: https://github.com/apache/ozone/pull/4124#discussion_r1063185608


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/key/OMKeyRequest.java:
##########
@@ -536,6 +538,40 @@ protected void checkBucketQuotaInBytes(OmBucketInfo 
omBucketInfo,
             + allocateSize) + " Bytes.",
             OMException.ResultCodes.QUOTA_EXCEEDED);
       }
+    } else {
+      checkVolumeQuotaInBytes(metadataManager, omBucketInfo.getVolumeName(),
+          allocateSize);
+    }
+  }
+
+  private void checkVolumeQuotaInBytes(
+      OMMetadataManager metadataManager, String volumeName,
+      long allocateSize) throws IOException {
+    String volumeKey = metadataManager.getVolumeKey(volumeName);
+    OmVolumeArgs omVolumeArgs = metadataManager.getVolumeTable()
+        .get(volumeKey);
+    if (omVolumeArgs.getQuotaInBytes() <= OzoneConsts.QUOTA_RESET) {
+      return;
+    }
+
+    long totalBucketQuota = 0L;
+    List<OmBucketInfo> bucketList = metadataManager.listBuckets(
+        volumeName, null, null, Integer.MAX_VALUE);
+    for (OmBucketInfo bucketInfo : bucketList) {
+      long nextQuotaInBytes = bucketInfo.getQuotaInBytes();
+      if (nextQuotaInBytes > OzoneConsts.QUOTA_RESET) {
+        totalBucketQuota += nextQuotaInBytes;

Review Comment:
   Lets say there is a single volume vol1 and 2 buckets with quota enabled 
buck1 and buck2, The quota on volume set is 2GB and each bucket has a quota set 
of 1GB , In this case , the totalBuckeQuota will be 2GB and  we try to write a 
non-zero size key `(omVolumeArgs.getQuotaInBytes() - totalBucketQuota < 
allocateSize) `will return true throwing exception even though the space is not 
fully utilized?



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