Преглед на файлове

HDFS-1258. Clearing namespace quota on "/" corrupts fs image. Contributed by Aaron T. Myers

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.20@960946 13f79535-47bb-0310-9956-ffa450edef68
Tsz-wo Sze преди 15 години
родител
ревизия
f44c47f5b4
променени са 3 файла, в които са добавени 11 реда и са изтрити 0 реда
  1. 3 0
      CHANGES.txt
  2. 2 0
      src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java
  3. 6 0
      src/test/org/apache/hadoop/hdfs/TestQuota.java

+ 3 - 0
CHANGES.txt

@@ -36,6 +36,9 @@ Release 0.20.3 - Unreleased
 
     MAPREDUCE-1880. Fix BigDecimal.divide(..) in the pi example.  (szetszwo)
 
+    HDFS-1258. Clearing namespace quota on "/" corrupts fs image.  
+    (Aaron T. Myers via szetszwo)
+
   IMPROVEMENTS
 
     MAPREDUCE-1407. Update javadoc in mapreduce.{Mapper,Reducer} to match

+ 2 - 0
src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java

@@ -1244,6 +1244,8 @@ class FSDirectory implements FSConstants, Closeable {
       throw new FileNotFoundException("Directory does not exist: " + srcs);
     } else if (!targetNode.isDirectory()) {
       throw new FileNotFoundException("Cannot set quota on a file: " + srcs);  
+    } else if (targetNode.isRoot() && nsQuota == FSConstants.QUOTA_RESET) {
+      throw new IllegalArgumentException("Cannot clear namespace quota on root.");
     } else { // a directory inode
       INodeDirectory dirNode = (INodeDirectory)targetNode;
       long oldNsQuota = dirNode.getNsQuota();

+ 6 - 0
src/test/org/apache/hadoop/hdfs/TestQuota.java

@@ -253,6 +253,12 @@ public class TestQuota extends TestCase {
       args = new String[] {"-clrQuota", parent.toString()};
       runCommand(userAdmin, args, true);
       runCommand(userAdmin, true, "-clrSpaceQuota",  args[1]);      
+
+      // 19: clrQuota on the root directory ("/") should fail
+      runCommand(admin, true, "-clrQuota", "/");
+
+      // 20: setQuota on the root directory ("/") should succeed
+      runCommand(admin, false, "-setQuota", "1000000", "/");
     } finally {
       cluster.shutdown();
     }