You are viewing a plain text version of this content. The canonical link for it is here.
Posted to hdfs-commits@hadoop.apache.org by br...@apache.org on 2013/08/17 23:58:20 UTC
svn commit: r1515044 - in
/hadoop/common/branches/branch-2.1-beta/hadoop-hdfs-project/hadoop-hdfs: ./
src/main/java/org/apache/hadoop/hdfs/
src/main/java/org/apache/hadoop/hdfs/server/namenode/
src/test/java/org/apache/hadoop/hdfs/server/namenode/
Author: brandonli
Date: Sat Aug 17 21:58:20 2013
New Revision: 1515044
URL: http://svn.apache.org/r1515044
Log:
HDFS-5104. Merging change r1515043 from branch-2
Modified:
hadoop/common/branches/branch-2.1-beta/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
hadoop/common/branches/branch-2.1-beta/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSUtil.java
hadoop/common/branches/branch-2.1-beta/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java
hadoop/common/branches/branch-2.1-beta/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestINodeFile.java
Modified: hadoop/common/branches/branch-2.1-beta/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2.1-beta/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt?rev=1515044&r1=1515043&r2=1515044&view=diff
==============================================================================
--- hadoop/common/branches/branch-2.1-beta/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt (original)
+++ hadoop/common/branches/branch-2.1-beta/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt Sat Aug 17 21:58:20 2013
@@ -15,6 +15,8 @@ Release 2.1.1-beta - UNRELEASED
HDFS-5076 Add MXBean methods to query NN's transaction information and
JournalNode's journal status. (jing9)
+ HDFS-5104 Support dotdot name in NFS LOOKUP operation (brandonli)
+
IMPROVEMENTS
HDFS-4513. Clarify in the WebHDFS REST API that all JSON respsonses may
Modified: hadoop/common/branches/branch-2.1-beta/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSUtil.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2.1-beta/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSUtil.java?rev=1515044&r1=1515043&r2=1515044&view=diff
==============================================================================
--- hadoop/common/branches/branch-2.1-beta/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSUtil.java (original)
+++ hadoop/common/branches/branch-2.1-beta/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSUtil.java Sat Aug 17 21:58:20 2013
@@ -73,6 +73,7 @@ import org.apache.hadoop.hdfs.protocol.H
import org.apache.hadoop.hdfs.protocol.LocatedBlock;
import org.apache.hadoop.hdfs.protocol.LocatedBlocks;
import org.apache.hadoop.hdfs.protocolPB.ClientDatanodeProtocolTranslatorPB;
+import org.apache.hadoop.hdfs.server.namenode.FSDirectory;
import org.apache.hadoop.hdfs.server.namenode.NameNode;
import org.apache.hadoop.io.retry.RetryPolicies;
import org.apache.hadoop.io.retry.RetryPolicy;
@@ -210,13 +211,20 @@ public class DFSUtil {
String[] components = StringUtils.split(src, '/');
for (int i = 0; i < components.length; i++) {
String element = components[i];
- if (element.equals("..") ||
- element.equals(".") ||
+ if (element.equals(".") ||
(element.indexOf(":") >= 0) ||
(element.indexOf("/") >= 0)) {
return false;
}
-
+ // ".." is allowed in path starting with /.reserved/.inodes
+ if (element.equals("..")) {
+ if (components.length > 4
+ && components[1].equals(FSDirectory.DOT_RESERVED_STRING)
+ && components[2].equals(FSDirectory.DOT_INODES_STRING)) {
+ continue;
+ }
+ return false;
+ }
// The string may start or end with a /, but not have
// "//" in the middle.
if (element.isEmpty() && i != components.length - 1 &&
Modified: hadoop/common/branches/branch-2.1-beta/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2.1-beta/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java?rev=1515044&r1=1515043&r2=1515044&view=diff
==============================================================================
--- hadoop/common/branches/branch-2.1-beta/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java (original)
+++ hadoop/common/branches/branch-2.1-beta/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java Sat Aug 17 21:58:20 2013
@@ -2731,6 +2731,19 @@ public class FSDirectory implements Clos
throw new FileNotFoundException(
"File for given inode path does not exist: " + src);
}
+
+ // Handle single ".." for NFS lookup support.
+ if ((pathComponents.length > 4)
+ && DFSUtil.bytes2String(pathComponents[4]).equals("..")) {
+ INode parent = inode.getParent();
+ if (parent == null || parent.getId() == INodeId.ROOT_INODE_ID) {
+ // inode is root, or its parent is root.
+ return Path.SEPARATOR;
+ } else {
+ return parent.getFullPathName();
+ }
+ }
+
StringBuilder path = id == INodeId.ROOT_INODE_ID ? new StringBuilder()
: new StringBuilder(inode.getFullPathName());
for (int i = 4; i < pathComponents.length; i++) {
Modified: hadoop/common/branches/branch-2.1-beta/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestINodeFile.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2.1-beta/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestINodeFile.java?rev=1515044&r1=1515043&r2=1515044&view=diff
==============================================================================
--- hadoop/common/branches/branch-2.1-beta/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestINodeFile.java (original)
+++ hadoop/common/branches/branch-2.1-beta/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestINodeFile.java Sat Aug 17 21:58:20 2013
@@ -44,6 +44,7 @@ import org.apache.hadoop.fs.PathIsNotDir
import org.apache.hadoop.fs.RemoteIterator;
import org.apache.hadoop.fs.permission.FsPermission;
import org.apache.hadoop.fs.permission.PermissionStatus;
+import org.apache.hadoop.hdfs.DFSClient;
import org.apache.hadoop.hdfs.DFSConfigKeys;
import org.apache.hadoop.hdfs.DFSTestUtil;
import org.apache.hadoop.hdfs.DFSUtil;
@@ -892,4 +893,34 @@ public class TestINodeFile {
assertTrue(e instanceof FileNotFoundException);
}
}
+
+ @Test
+ public void testDotdotInodePath() throws Exception {
+ final Configuration conf = new Configuration();
+ MiniDFSCluster cluster = null;
+ try {
+ cluster = new MiniDFSCluster.Builder(conf).numDataNodes(1).build();
+ cluster.waitActive();
+ final DistributedFileSystem hdfs = cluster.getFileSystem();
+ final FSDirectory fsdir = cluster.getNamesystem().getFSDirectory();
+
+ final Path dir = new Path("/dir");
+ hdfs.mkdirs(dir);
+ long dirId = fsdir.getINode(dir.toString()).getId();
+ long parentId = fsdir.getINode("/").getId();
+ String testPath = "/.reserved/.inodes/" + dirId + "/..";
+
+ DFSClient client = new DFSClient(NameNode.getAddress(conf), conf);
+ HdfsFileStatus status = client.getFileInfo(testPath);
+ assertTrue(parentId == status.getFileId());
+
+ // Test root's parent is still root
+ testPath = "/.reserved/.inodes/" + parentId + "/..";
+ status = client.getFileInfo(testPath);
+ assertTrue(parentId == status.getFileId());
+
+ } finally {
+ cluster.shutdown();
+ }
+ }
}