Bläddra i källkod

Update quota usage for snapshots.

Haohui Mai 10 år sedan
förälder
incheckning
1d8590d949

+ 2 - 3
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
           // what about an old-version fsync() where fsync isn't called
           // until several blocks in?
           // until several blocks in?
           newBI = new BlockInfoContiguousUnderConstruction(
           newBI = new BlockInfoContiguousUnderConstruction(
-              newBlock, file.getPreferredBlockReplication());
+              newBlock, file.getFileReplication());
         } else {
         } else {
           // OP_CLOSE should add finalized blocks. This code path
           // OP_CLOSE should add finalized blocks. This code path
           // is only executed when loading edits written by prior
           // is only executed when loading edits written by prior
           // versions of Hadoop. Current versions always log
           // versions of Hadoop. Current versions always log
           // OP_ADD operations as each block is allocated.
           // 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);
         fsNamesys.getBlockManager().addBlockCollection(newBI, file);
         file.addBlock(newBI);
         file.addBlock(newBI);

+ 3 - 4
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) {
     if (bsp != null) {
       List<StorageType> storageTypes = bsp.chooseStorageTypes(replication);
       List<StorageType> storageTypes = bsp.chooseStorageTypes(replication);
       for (StorageType t : storageTypes) {
       for (StorageType t : storageTypes) {
-        if (!t.supportTypeQuota()) {
-          continue;
+        if (t.supportTypeQuota()) {
+          counts.addTypeSpace(t, ssDeltaNoReplication);
         }
         }
-        counts.addTypeSpace(t, ssDeltaNoReplication);
       }
       }
     }
     }
+
     return counts;
     return counts;
   }
   }
 
 
@@ -727,7 +727,6 @@ public class INodeFile extends INodeWithAdditionalFields
       blocks = allBlocks;
       blocks = allBlocks;
     }
     }
 
 
-    final short replication = getPreferredBlockReplication();
     for (BlockInfoContiguous b : blocks) {
     for (BlockInfoContiguous b : blocks) {
       long blockSize = b.isComplete() ? b.getNumBytes() :
       long blockSize = b.isComplete() ? b.getNumBytes() :
           getPreferredBlockSize();
           getPreferredBlockSize();

+ 1 - 3
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());
       bsp = reclaimContext.storagePolicySuite().getPolicy(file.getStoragePolicyID());
     }
     }
 
 
-
     QuotaCounts oldCounts = file.storagespaceConsumed(null);
     QuotaCounts oldCounts = file.storagespaceConsumed(null);
-    long oldStoragespace;
     if (removed.snapshotINode != null) {
     if (removed.snapshotINode != null) {
       short replication = removed.snapshotINode.getFileReplication();
       short replication = removed.snapshotINode.getFileReplication();
       short currentRepl = file.getPreferredBlockReplication();
       short currentRepl = file.getPreferredBlockReplication();
@@ -161,7 +159,7 @@ public class FileWithSnapshotFeature implements INode.Feature {
             ? file.computeFileSize(true, true)
             ? file.computeFileSize(true, true)
             : oldCounts.getStorageSpace() /
             : oldCounts.getStorageSpace() /
             file.getPreferredBlockReplication();
             file.getPreferredBlockReplication();
-        oldStoragespace = oldFileSizeNoRep * replication;
+        long oldStoragespace = oldFileSizeNoRep * replication;
         oldCounts.setStorageSpace(oldStoragespace);
         oldCounts.setStorageSpace(oldStoragespace);
 
 
         if (bsp != null) {
         if (bsp != null) {