diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 47228a47799..9e1dc17287e 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -735,6 +735,9 @@ Release 2.7.0 - UNRELEASED HDFS-7637. Fix the check condition for reserved path. (Yi Liu via jing9) + HDFS-7634. Disallow truncation of Lazy persist files. (Yi Liu via + Arpit Agarwal) + Release 2.6.1 - UNRELEASED INCOMPATIBLE CHANGES diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java index ff53fb5ddc5..6a8f57452de 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java @@ -1952,6 +1952,14 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean, dir.checkPathAccess(pc, iip, FsAction.WRITE); } INodeFile file = INodeFile.valueOf(iip.getLastINode(), src); + final BlockStoragePolicy lpPolicy = + blockManager.getStoragePolicy("LAZY_PERSIST"); + + if (lpPolicy != null && + lpPolicy.getId() == file.getStoragePolicyID()) { + throw new UnsupportedOperationException( + "Cannot truncate lazy persist file " + src); + } // Opening an existing file for write. May need lease recovery. recoverLeaseInternal(iip, src, clientName, clientMachine, false); // Truncate length check.