[
https://issues.apache.org/jira/browse/HDFS-17839?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18022092#comment-18022092
]
ASF GitHub Bot commented on HDFS-17839:
---------------------------------------
huangzhaobo99 commented on code in PR #7989:
URL: https://github.com/apache/hadoop/pull/7989#discussion_r2371522735
##########
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java:
##########
@@ -1379,16 +1398,22 @@ public INodesInPath addLastINode(INodesInPath existing,
INode inode,
// always verify inode name
verifyINodeName(inode.getLocalNameBytes());
- final QuotaCounts counts = quotaCount.orElseGet(() -> inode.
- computeQuotaUsage(getBlockStoragePolicySuite(),
- parent.getStoragePolicyID(), false,
- Snapshot.CURRENT_STATE_ID));
- updateCount(existing, pos, counts, checkQuota);
+ if (updateQuota) {
+ QuotaCounts counts = quotaCount.orElseGet(() -> inode.
+ computeQuotaUsage(getBlockStoragePolicySuite(),
+ parent.getStoragePolicyID(), false,
+ Snapshot.CURRENT_STATE_ID));
+ updateCount(existing, pos, counts, checkQuota);
+ }
boolean isRename = (inode.getParent() != null);
final boolean added = parent.addChild(inode, true,
existing.getLatestSnapshotId());
- if (!added) {
+ if (!added && updateQuota) {
+ QuotaCounts counts = quotaCount.orElseGet(() -> inode.
+ computeQuotaUsage(getBlockStoragePolicySuite(),
+ parent.getStoragePolicyID(), false,
+ Snapshot.CURRENT_STATE_ID));
Review Comment:
When the add failed, it is to restore the quota usage.
If there was no update before, there is no need to update when it failed.
```
updateCountNoQuotaCheck(existing, pos, counts.negation());
```
> Rename skips path without valid 'DirectoryWithQuotaFeature' in FSDirRenameOp
> ----------------------------------------------------------------------------
>
> Key: HDFS-17839
> URL: https://issues.apache.org/jira/browse/HDFS-17839
> Project: Hadoop HDFS
> Issue Type: Improvement
> Reporter: Zhaobo Huang
> Assignee: Zhaobo Huang
> Priority: Major
> Labels: pull-request-available
>
> Calculating quota usage is primarily used to update directories labeled with
> the DirectoryWithQuotaFeature. When there is no valid
> DirectoryWithQuotaFeature in the paths of src and dst (excluding the root
> directory), the quota should not be calculated in rename scenarios:
> 1. rename1 does not change the quota of the root directory, so neither src
> nor dst contains DirectoryWithQuotaFeature (excluding the root directory).
> The operation of calculating quota should be skipped.
> 2. In the scenario of overwriting, rename2 still needs to consider
> calculating quota, otherwise it will affect the quotaUsage value of the root
> directory.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]