diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSImageFormatProtobuf.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSImageFormatProtobuf.java index a00cde59140..c99add3ec0e 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSImageFormatProtobuf.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSImageFormatProtobuf.java @@ -568,6 +568,8 @@ public final class FSImageFormatProtobuf { FSImageCompression compression, String filePath) throws IOException { StartupProgress prog = NameNode.getStartupProgress(); MessageDigest digester = MD5Hash.getDigester(); + int layoutVersion = + context.getSourceNamesystem().getEffectiveLayoutVersion(); underlyingOutputStream = new DigestOutputStream(new BufferedOutputStream( fout), digester); @@ -594,11 +596,16 @@ public final class FSImageFormatProtobuf { // depends on this behavior. context.checkCancelled(); + Step step; + // Erasure coding policies should be saved before inodes - Step step = new Step(StepType.ERASURE_CODING_POLICIES, filePath); - prog.beginStep(Phase.SAVING_CHECKPOINT, step); - saveErasureCodingSection(b); - prog.endStep(Phase.SAVING_CHECKPOINT, step); + if (NameNodeLayoutVersion.supports( + NameNodeLayoutVersion.Feature.ERASURE_CODING, layoutVersion)) { + step = new Step(StepType.ERASURE_CODING_POLICIES, filePath); + prog.beginStep(Phase.SAVING_CHECKPOINT, step); + saveErasureCodingSection(b); + prog.endStep(Phase.SAVING_CHECKPOINT, step); + } step = new Step(StepType.INODES, filePath); prog.beginStep(Phase.SAVING_CHECKPOINT, step);