Skip to content

Commit f96079b

Browse files
committed
fix update quota
1 parent 3c60bf0 commit f96079b

File tree

1 file changed

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

1 file changed

+7
-7
lines changed

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1398,8 +1398,9 @@ public INodesInPath addLastINode(INodesInPath existing, INode inode, FsPermissio
13981398
// always verify inode name
13991399
verifyINodeName(inode.getLocalNameBytes());
14001400

1401+
QuotaCounts counts = null;
14011402
if (updateQuota) {
1402-
QuotaCounts counts = quotaCount.orElseGet(() -> inode.
1403+
counts = quotaCount.orElseGet(() -> inode.
14031404
computeQuotaUsage(getBlockStoragePolicySuite(),
14041405
parent.getStoragePolicyID(), false,
14051406
Snapshot.CURRENT_STATE_ID));
@@ -1409,12 +1410,11 @@ public INodesInPath addLastINode(INodesInPath existing, INode inode, FsPermissio
14091410
boolean isRename = (inode.getParent() != null);
14101411
final boolean added = parent.addChild(inode, true,
14111412
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());
1413+
if (!added) {
1414+
// When adding INode fails, if 'updateQuota' is true, rollback quotaUsage.
1415+
if (updateQuota) {
1416+
updateCountNoQuotaCheck(existing, pos, counts.negation());
1417+
}
14181418
return null;
14191419
} else {
14201420
if (!isRename) {

0 commit comments

Comments
 (0)