Browse Source

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

git-svn-id: https://svn.apache.org/repos/asf/hadoop/hdfs/trunk@960949 13f79535-47bb-0310-9956-ffa450edef68
Tsz-wo Sze 15 years ago
parent
commit
a2e5acccfd

+ 3 - 0
CHANGES.txt

@@ -1043,6 +1043,9 @@ Release 0.20.3 - Unreleased
     HDFS-909. Wait until edits syncing is finishes before purging edits.
     HDFS-909. Wait until edits syncing is finishes before purging edits.
     (Todd Lipcon via shv)
     (Todd Lipcon via shv)
 
 
+    HDFS-1258. Clearing namespace quota on "/" corrupts fs image.
+    (Aaron T. Myers via szetszwo)
+
 Release 0.20.2 - Unreleased
 Release 0.20.2 - Unreleased
 
 
   IMPROVEMENTS
   IMPROVEMENTS

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

@@ -1699,6 +1699,8 @@ class FSDirectory implements Closeable {
         throw new FileNotFoundException("Directory does not exist: " + srcs);
         throw new FileNotFoundException("Directory does not exist: " + srcs);
       } else if (!targetNode.isDirectory()) {
       } else if (!targetNode.isDirectory()) {
         throw new FileNotFoundException("Cannot set quota on a file: " + srcs);  
         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
       } else { // a directory inode
         INodeDirectory dirNode = (INodeDirectory)targetNode;
         INodeDirectory dirNode = (INodeDirectory)targetNode;
         long oldNsQuota = dirNode.getNsQuota();
         long oldNsQuota = dirNode.getNsQuota();

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

@@ -268,6 +268,12 @@ public class TestQuota extends TestCase {
           return null;
           return null;
         }
         }
       });
       });
+
+      // 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 {
     } finally {
       cluster.shutdown();
       cluster.shutdown();
     }
     }