HDFS-7634. Disallow truncation of Lazy persist files. (Contributed by Yi Liu)

This commit is contained in:
Arpit Agarwal 2015-01-20 12:11:36 -08:00
parent c94c0d2c56
commit c09c65b212
2 changed files with 11 additions and 0 deletions

View File

@ -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

View File

@ -1952,6 +1952,14 @@ boolean truncateInternal(String src, long newLength,
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.