[ https://issues.apache.org/jira/browse/HDFS-7957?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14370905#comment-14370905 ]
Tsz Wo Nicholas Sze commented on HDFS-7957: ------------------------------------------- In INodeFile.computeQuotaDeltaForTruncate, when sf != null, I think the code can be simplified to below: {code} if (sf != null) { FileDiff diff = sf.getDiffs().getLast(); if (diff != null) { final BlockInfoContiguous[] last = diff.getBlocks(); if (last != null) { for (int i = (onBoundary ? n : n-1); i < blocks.length && i < last.length && last[i].equals(blocks[i]); i++) { truncateSize -= blocks[i].getNumBytes(); } } } } {code} The file could be appended and truncated previously so that it is impossible to have last\[i].equals(blocks\[j]) for i != j. Also if last\[i].equals(blocks\[i]) == false for some i, then last\[j].equals(blocks\[j]) == false for all j >= i. Do you agree? > Truncate should verify quota before making changes > -------------------------------------------------- > > Key: HDFS-7957 > URL: https://issues.apache.org/jira/browse/HDFS-7957 > Project: Hadoop HDFS > Issue Type: Bug > Components: namenode > Affects Versions: 2.7.0 > Reporter: Jing Zhao > Assignee: Jing Zhao > Priority: Critical > Attachments: HDFS-7957.000.patch, HDFS-7957.001.patch > > > This is a similar issue with HDFS-7587: for truncate we should also verify > quota in the beginning and update quota in the end. -- This message was sent by Atlassian JIRA (v6.3.4#6332)