HDFS-7252. small refinement to the use of isInAnEZ in FSNamesystem. (Yi Liu via vinayakumarb)

(cherry picked from commit 368743140d)
This commit is contained in:
Vinayakumar B 2014-10-17 18:03:44 +05:30
parent 7c87c2b42e
commit 6f19ba7688
2 changed files with 10 additions and 5 deletions

View File

@ -44,6 +44,9 @@ Release 2.7.0 - UNRELEASED
HDFS-7242. Code improvement for FSN#checkUnreadableBySuperuser. HDFS-7242. Code improvement for FSN#checkUnreadableBySuperuser.
(Yi Liu via vinayakumarb) (Yi Liu via vinayakumarb)
HDFS-7252. small refinement to the use of isInAnEZ in FSNamesystem.
(Yi Liu via vinayakumarb)
Release 2.6.0 - UNRELEASED Release 2.6.0 - UNRELEASED
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -2561,11 +2561,11 @@ private HdfsFileStatus startFileInt(final String srcArg,
src = resolvePath(src, pathComponents); src = resolvePath(src, pathComponents);
INodesInPath iip = dir.getINodesInPath4Write(src); INodesInPath iip = dir.getINodesInPath4Write(src);
// Nothing to do if the path is not within an EZ // Nothing to do if the path is not within an EZ
if (dir.isInAnEZ(iip)) { final EncryptionZone zone = dir.getEZForPath(iip);
EncryptionZone zone = dir.getEZForPath(iip); if (zone != null) {
protocolVersion = chooseProtocolVersion(zone, supportedVersions); protocolVersion = chooseProtocolVersion(zone, supportedVersions);
suite = zone.getSuite(); suite = zone.getSuite();
ezKeyName = dir.getKeyName(iip); ezKeyName = zone.getKeyName();
Preconditions.checkNotNull(protocolVersion); Preconditions.checkNotNull(protocolVersion);
Preconditions.checkNotNull(suite); Preconditions.checkNotNull(suite);
@ -2648,14 +2648,16 @@ private BlocksMapUpdateInfo startFileInternal(FSPermissionChecker pc,
} }
FileEncryptionInfo feInfo = null; FileEncryptionInfo feInfo = null;
if (dir.isInAnEZ(iip)) {
final EncryptionZone zone = dir.getEZForPath(iip);
if (zone != null) {
// The path is now within an EZ, but we're missing encryption parameters // The path is now within an EZ, but we're missing encryption parameters
if (suite == null || edek == null) { if (suite == null || edek == null) {
throw new RetryStartFileException(); throw new RetryStartFileException();
} }
// Path is within an EZ and we have provided encryption parameters. // Path is within an EZ and we have provided encryption parameters.
// Make sure that the generated EDEK matches the settings of the EZ. // Make sure that the generated EDEK matches the settings of the EZ.
String ezKeyName = dir.getKeyName(iip); final String ezKeyName = zone.getKeyName();
if (!ezKeyName.equals(edek.getEncryptionKeyName())) { if (!ezKeyName.equals(edek.getEncryptionKeyName())) {
throw new RetryStartFileException(); throw new RetryStartFileException();
} }