HDFS-10975. fsck -list-corruptfileblocks does not report corrupt EC files. Contributed by Takanobu Asanuma.

This commit is contained in:
Wei-Chiu Chuang 2016-10-21 15:43:12 -07:00
parent be72372248
commit df857f0d10
2 changed files with 14 additions and 7 deletions

View File

@ -660,6 +660,13 @@ public class NamenodeFsck implements DataEncryptionKeyFactory {
decommissioningReplicas; decommissioningReplicas;
res.totalReplicas += totalReplicasPerBlock; res.totalReplicas += totalReplicasPerBlock;
boolean isMissing;
if (storedBlock.isStriped()) {
isMissing = totalReplicasPerBlock < minReplication;
} else {
isMissing = totalReplicasPerBlock == 0;
}
// count expected replicas // count expected replicas
short targetFileReplication; short targetFileReplication;
if (file.getErasureCodingPolicy() != null) { if (file.getErasureCodingPolicy() != null) {
@ -697,7 +704,7 @@ public class NamenodeFsck implements DataEncryptionKeyFactory {
res.numMinReplicatedBlocks++; res.numMinReplicatedBlocks++;
// count missing replicas / under replicated blocks // count missing replicas / under replicated blocks
if (totalReplicasPerBlock < targetFileReplication && totalReplicasPerBlock > 0) { if (totalReplicasPerBlock < targetFileReplication && !isMissing) {
res.missingReplicas += (targetFileReplication - totalReplicasPerBlock); res.missingReplicas += (targetFileReplication - totalReplicasPerBlock);
res.numUnderReplicatedBlocks += 1; res.numUnderReplicatedBlocks += 1;
underReplicatedPerFile++; underReplicatedPerFile++;
@ -737,12 +744,6 @@ public class NamenodeFsck implements DataEncryptionKeyFactory {
String blkName = block.toString(); String blkName = block.toString();
report.append(blockNumber + ". " + blkName + " len=" + report.append(blockNumber + ". " + blkName + " len=" +
block.getNumBytes()); block.getNumBytes());
boolean isMissing;
if (storedBlock.isStriped()) {
isMissing = totalReplicasPerBlock < minReplication;
} else {
isMissing = totalReplicasPerBlock == 0;
}
if (isMissing && !isCorrupt) { if (isMissing && !isCorrupt) {
// If the block is corrupted, it means all its available replicas are // If the block is corrupted, it means all its available replicas are
// corrupted in the case of replication, and it means the state of the // corrupted in the case of replication, and it means the state of the

View File

@ -2013,6 +2013,9 @@ public class TestFsck {
String outStr = runFsck(conf, 1, true, "/"); String outStr = runFsck(conf, 1, true, "/");
assertTrue(outStr.contains(NamenodeFsck.CORRUPT_STATUS)); assertTrue(outStr.contains(NamenodeFsck.CORRUPT_STATUS));
assertTrue(outStr.contains("Under-erasure-coded block groups:\t0"));
outStr = runFsck(conf, -1, true, "/", "-list-corruptfileblocks");
assertTrue(outStr.contains("has 1 CORRUPT files"));
} }
@Test (timeout = 300000) @Test (timeout = 300000)
@ -2053,6 +2056,9 @@ public class TestFsck {
"-locations"); "-locations");
assertTrue(outStr.contains(NamenodeFsck.CORRUPT_STATUS)); assertTrue(outStr.contains(NamenodeFsck.CORRUPT_STATUS));
assertTrue(outStr.contains("Live_repl=" + (dataBlocks - 1))); assertTrue(outStr.contains("Live_repl=" + (dataBlocks - 1)));
assertTrue(outStr.contains("Under-erasure-coded block groups:\t0"));
outStr = runFsck(conf, -1, true, "/", "-list-corruptfileblocks");
assertTrue(outStr.contains("has 1 CORRUPT files"));
} }
private void waitForUnrecoverableBlockGroup(Configuration configuration) private void waitForUnrecoverableBlockGroup(Configuration configuration)