@@ -1398,8 +1398,9 @@ public INodesInPath addLastINode(INodesInPath existing, INode inode, FsPermissio
1398
1398
// always verify inode name
1399
1399
verifyINodeName (inode .getLocalNameBytes ());
1400
1400
1401
+ QuotaCounts counts = null ;
1401
1402
if (updateQuota ) {
1402
- QuotaCounts counts = quotaCount .orElseGet (() -> inode .
1403
+ counts = quotaCount .orElseGet (() -> inode .
1403
1404
computeQuotaUsage (getBlockStoragePolicySuite (),
1404
1405
parent .getStoragePolicyID (), false ,
1405
1406
Snapshot .CURRENT_STATE_ID ));
@@ -1409,12 +1410,11 @@ public INodesInPath addLastINode(INodesInPath existing, INode inode, FsPermissio
1409
1410
boolean isRename = (inode .getParent () != null );
1410
1411
final boolean added = parent .addChild (inode , true ,
1411
1412
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
+ }
1418
1418
return null ;
1419
1419
} else {
1420
1420
if (!isRename ) {
0 commit comments