diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DirectoryScanner.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DirectoryScanner.java index 083ca31da3..0e51cecf2b 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DirectoryScanner.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DirectoryScanner.java @@ -902,8 +902,7 @@ private LinkedList compileReport(FsVolumeSpi vol, break; } } - verifyFileLocation(blockFile.getParentFile(), bpFinalizedDir, - blockId); + verifyFileLocation(blockFile, bpFinalizedDir, blockId); report.add(new ScanInfo(blockId, blockFile, metaFile, vol)); } return report; @@ -913,12 +912,15 @@ private LinkedList compileReport(FsVolumeSpi vol, * Verify whether the actual directory location of block file has the * expected directory path computed using its block ID. */ - private void verifyFileLocation(File actualBlockDir, + private void verifyFileLocation(File actualBlockFile, File bpFinalizedDir, long blockId) { File blockDir = DatanodeUtil.idToBlockDir(bpFinalizedDir, blockId); - if (actualBlockDir.compareTo(blockDir) != 0) { + if (actualBlockFile.getParentFile().compareTo(blockDir) != 0) { + File expBlockFile = new File(blockDir, actualBlockFile.getName()); LOG.warn("Block: " + blockId - + " has to be upgraded to block ID-based layout"); + + " has to be upgraded to block ID-based layout. " + + "Actual block file path: " + actualBlockFile + + ", expected block file path: " + expBlockFile); } }