1
0
Pārlūkot izejas kodu

HDFS-4972. Permission check and operation are done in a separate lock for getBlockLocations(). Contributed by Kihwal Lee.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.23@1503461 13f79535-47bb-0310-9956-ffa450edef68
Kihwal Lee 12 gadi atpakaļ
vecāks
revīzija
df593d5128

+ 4 - 0
hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt

@@ -11,8 +11,12 @@ Release 0.23.10 - UNRELEASED
   OPTIMIZATIONS
   OPTIMIZATIONS
 
 
   BUG FIXES
   BUG FIXES
+
     HDFS-4984. Incorrect Quota counting in INodeFile. (jing9 via kihwal)
     HDFS-4984. Incorrect Quota counting in INodeFile. (jing9 via kihwal)
 
 
+    HDFS-4972. Permission check and operation are done in a separate lock for
+    getBlockLocations(). (kihwal)
+
 Release 0.23.9 - 2013-07-08
 Release 0.23.9 - 2013-07-08
 
 
   INCOMPATIBLE CHANGES
   INCOMPATIBLE CHANGES

+ 10 - 11
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java

@@ -733,11 +733,6 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
   LocatedBlocks getBlockLocations(String src, long offset, long length,
   LocatedBlocks getBlockLocations(String src, long offset, long length,
       boolean doAccessTime, boolean needBlockToken) throws FileNotFoundException,
       boolean doAccessTime, boolean needBlockToken) throws FileNotFoundException,
       UnresolvedLinkException, IOException {
       UnresolvedLinkException, IOException {
-    FSPermissionChecker pc = getPermissionChecker();
-    if (isPermissionEnabled) {
-      checkPathAccess(pc, src, FsAction.READ);
-    }
-
     if (offset < 0) {
     if (offset < 0) {
       throw new HadoopIllegalArgumentException(
       throw new HadoopIllegalArgumentException(
           "Negative offset is not supported. File: " + src);
           "Negative offset is not supported. File: " + src);
@@ -762,7 +757,7 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
                                                        boolean doAccessTime, 
                                                        boolean doAccessTime, 
                                                        boolean needBlockToken)
                                                        boolean needBlockToken)
       throws FileNotFoundException, UnresolvedLinkException, IOException {
       throws FileNotFoundException, UnresolvedLinkException, IOException {
-
+    FSPermissionChecker pc = getPermissionChecker();
     for (int attempt = 0; attempt < 2; attempt++) {
     for (int attempt = 0; attempt < 2; attempt++) {
       if (attempt == 0) { // first attempt is with readlock
       if (attempt == 0) { // first attempt is with readlock
         readLock();
         readLock();
@@ -770,12 +765,16 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
         writeLock(); // writelock is needed to set accesstime
         writeLock(); // writelock is needed to set accesstime
       }
       }
 
 
-      // if the namenode is in safemode, then do not update access time
-      if (isInSafeMode()) {
-        doAccessTime = false;
-      }
-
       try {
       try {
+        if (isPermissionEnabled) {
+          checkPathAccess(pc, src, FsAction.READ);
+        }
+
+        // if the namenode is in safemode, then do not update access time
+        if (isInSafeMode()) {
+          doAccessTime = false;
+        }
+
         long now = now();
         long now = now();
         INodeFile inode = dir.getFileINode(src);
         INodeFile inode = dir.getFileINode(src);
         if (inode == null) {
         if (inode == null) {