Skip to content

Commit 5756bc3

Browse files
committed
fix update quota
1 parent 3c60bf0 commit 5756bc3

File tree

1 file changed

+9
-6
lines changed
  • hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode

1 file changed

+9
-6
lines changed

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1409,12 +1409,15 @@ public INodesInPath addLastINode(INodesInPath existing, INode inode, FsPermissio
14091409
boolean isRename = (inode.getParent() != null);
14101410
final boolean added = parent.addChild(inode, true,
14111411
existing.getLatestSnapshotId());
1412-
if (!added && updateQuota) {
1413-
QuotaCounts counts = quotaCount.orElseGet(() -> inode.
1414-
computeQuotaUsage(getBlockStoragePolicySuite(),
1415-
parent.getStoragePolicyID(), false,
1416-
Snapshot.CURRENT_STATE_ID));
1417-
updateCountNoQuotaCheck(existing, pos, counts.negation());
1412+
if (!added) {
1413+
// When adding INode fails, if 'updateQuota' is true, rollback quotaUsage.
1414+
if (updateQuota) {
1415+
QuotaCounts counts = quotaCount.orElseGet(() -> inode.
1416+
computeQuotaUsage(getBlockStoragePolicySuite(),
1417+
parent.getStoragePolicyID(), false,
1418+
Snapshot.CURRENT_STATE_ID));
1419+
updateCountNoQuotaCheck(existing, pos, counts.negation());
1420+
}
14181421
return null;
14191422
} else {
14201423
if (!isRename) {

0 commit comments

Comments
 (0)