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

This commit is contained in:
yliu 2015-01-24 16:34:08 -08:00 committed by Konstantin V Shvachko
parent 0fdd09a895
commit 8adffbb2c8
2 changed files with 11 additions and 0 deletions

View File

@ -491,6 +491,9 @@ Release 2.7.0 - UNRELEASED
HDFS-7638: Small fix and few refinements for FSN#truncate. (yliu)
HDFS-7634. Disallow truncation of Lazy persist files. (Yi Liu via
Arpit Agarwal)
Release 2.6.1 - UNRELEASED
INCOMPATIBLE CHANGES

View File

@ -2006,6 +2006,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.