Update quota usage for snapshots.
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/1d8590d9 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/1d8590d9 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/1d8590d9 Branch: refs/heads/feature-HDFS-8286 Commit: 1d8590d949e5ed30afadcb67d4781dc188115564 Parents: 2bace6f Author: Haohui Mai <whe...@apache.org> Authored: Tue May 5 14:22:54 2015 -0700 Committer: Haohui Mai <whe...@apache.org> Committed: Fri Jun 12 13:56:56 2015 -0700 ---------------------------------------------------------------------- .../apache/hadoop/hdfs/server/namenode/FSEditLogLoader.java | 5 ++--- .../org/apache/hadoop/hdfs/server/namenode/INodeFile.java | 7 +++---- .../server/namenode/snapshot/FileWithSnapshotFeature.java | 4 +--- 3 files changed, 6 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/1d8590d9/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLogLoader.java ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLogLoader.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLogLoader.java index 950b5ce..5f87f11 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLogLoader.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLogLoader.java @@ -1051,14 +1051,13 @@ public class FSEditLogLoader { // what about an old-version fsync() where fsync isn't called // until several blocks in? newBI = new BlockInfoContiguousUnderConstruction( - newBlock, file.getPreferredBlockReplication()); + newBlock, file.getFileReplication()); } else { // OP_CLOSE should add finalized blocks. This code path // is only executed when loading edits written by prior // versions of Hadoop. Current versions always log // OP_ADD operations as each block is allocated. - newBI = new BlockInfoContiguous(newBlock, - file.getPreferredBlockReplication()); + newBI = new BlockInfoContiguous(newBlock, file.getFileReplication()); } fsNamesys.getBlockManager().addBlockCollection(newBI, file); file.addBlock(newBI); http://git-wip-us.apache.org/repos/asf/hadoop/blob/1d8590d9/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/INodeFile.java ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/INodeFile.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/INodeFile.java index b97ea90..fb25e9d 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/INodeFile.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/INodeFile.java @@ -595,12 +595,12 @@ public class INodeFile extends INodeWithAdditionalFields if (bsp != null) { List<StorageType> storageTypes = bsp.chooseStorageTypes(replication); for (StorageType t : storageTypes) { - if (!t.supportTypeQuota()) { - continue; + if (t.supportTypeQuota()) { + counts.addTypeSpace(t, ssDeltaNoReplication); } - counts.addTypeSpace(t, ssDeltaNoReplication); } } + return counts; } @@ -727,7 +727,6 @@ public class INodeFile extends INodeWithAdditionalFields blocks = allBlocks; } - final short replication = getPreferredBlockReplication(); for (BlockInfoContiguous b : blocks) { long blockSize = b.isComplete() ? b.getNumBytes() : getPreferredBlockSize(); http://git-wip-us.apache.org/repos/asf/hadoop/blob/1d8590d9/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/snapshot/FileWithSnapshotFeature.java ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/snapshot/FileWithSnapshotFeature.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/snapshot/FileWithSnapshotFeature.java index 555a662..3ff4dbb 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/snapshot/FileWithSnapshotFeature.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/snapshot/FileWithSnapshotFeature.java @@ -150,9 +150,7 @@ public class FileWithSnapshotFeature implements INode.Feature { bsp = reclaimContext.storagePolicySuite().getPolicy(file.getStoragePolicyID()); } - QuotaCounts oldCounts = file.storagespaceConsumed(null); - long oldStoragespace; if (removed.snapshotINode != null) { short replication = removed.snapshotINode.getFileReplication(); short currentRepl = file.getPreferredBlockReplication(); @@ -161,7 +159,7 @@ public class FileWithSnapshotFeature implements INode.Feature { ? file.computeFileSize(true, true) : oldCounts.getStorageSpace() / file.getPreferredBlockReplication(); - oldStoragespace = oldFileSizeNoRep * replication; + long oldStoragespace = oldFileSizeNoRep * replication; oldCounts.setStorageSpace(oldStoragespace); if (bsp != null) {