From f0e13c5499e8dc06b36f19f31bbff90daba0dc93 Mon Sep 17 00:00:00 2001 From: Jing Zhao Date: Tue, 11 Aug 2015 10:28:18 -0700 Subject: [PATCH] HDFS-8805. Archival Storage: getStoragePolicy should not need superuser privilege. Contributed by Brahma Reddy Battula. (cherry picked from commit 1fc3c779a422bafdb86ad1a5b2349802dda1cb62) --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 +++ .../hadoop/hdfs/server/namenode/FSDirAppendOp.java | 2 +- .../hdfs/server/namenode/FSDirStatAndListingOp.java | 9 +++------ .../hadoop/hdfs/server/namenode/FSDirWriteFileOp.java | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index dbba75da469..4d101270c27 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -432,6 +432,9 @@ Release 2.8.0 - UNRELEASED HDFS-8818. Changes the global moveExecutor to per datanode executors and changes MAX_SIZE_TO_MOVE to be configurable. (szetszwo) + HDFS-8805. Archival Storage: getStoragePolicy should not need superuser privilege. + (Brahma Reddy Battula via jing9) + OPTIMIZATIONS HDFS-8026. Trace FSOutputSummer#writeChecksumChunks rather than diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirAppendOp.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirAppendOp.java index abb2dc86fe8..3d79d0962db 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirAppendOp.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirAppendOp.java @@ -135,7 +135,7 @@ final class FSDirAppendOp { } HdfsFileStatus stat = FSDirStatAndListingOp.getFileInfo(fsd, src, false, - FSDirectory.isReservedRawName(srcArg), true); + FSDirectory.isReservedRawName(srcArg)); if (lb != null) { NameNode.stateChangeLog.debug( "DIR* NameSystem.appendFile: file {} for {} at {} block {} block" diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirStatAndListingOp.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirStatAndListingOp.java index 14f4d66e885..4a45074d42b 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirStatAndListingOp.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirStatAndListingOp.java @@ -105,13 +105,11 @@ class FSDirStatAndListingOp { byte[][] pathComponents = FSDirectory.getPathComponentsForReservedPath(src); src = fsd.resolvePath(pc, src, pathComponents); final INodesInPath iip = fsd.getINodesInPath(src, resolveLink); - boolean isSuperUser = true; if (fsd.isPermissionEnabled()) { fsd.checkPermission(pc, iip, false, null, null, null, null, false); - isSuperUser = pc.isSuperUser(); } return getFileInfo(fsd, src, resolveLink, - FSDirectory.isReservedRawName(srcArg), isSuperUser); + FSDirectory.isReservedRawName(srcArg)); } /** @@ -369,8 +367,7 @@ class FSDirStatAndListingOp { } static HdfsFileStatus getFileInfo( - FSDirectory fsd, String src, boolean resolveLink, boolean isRawPath, - boolean includeStoragePolicy) + FSDirectory fsd, String src, boolean resolveLink, boolean isRawPath) throws IOException { String srcs = FSDirectory.normalizePath(src); if (srcs.endsWith(HdfsConstants.SEPARATOR_DOT_SNAPSHOT_DIR)) { @@ -385,7 +382,7 @@ class FSDirStatAndListingOp { fsd.readLock(); try { final INodesInPath iip = fsd.getINodesInPath(srcs, resolveLink); - return getFileInfo(fsd, src, iip, isRawPath, includeStoragePolicy); + return getFileInfo(fsd, src, iip, isRawPath, true); } finally { fsd.readUnlock(); } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirWriteFileOp.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirWriteFileOp.java index 732e9cf4cae..3d30a199ff1 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirWriteFileOp.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirWriteFileOp.java @@ -432,7 +432,7 @@ class FSDirWriteFileOp { NameNode.stateChangeLog.debug("DIR* NameSystem.startFile: added " + src + " inode " + newNode.getId() + " " + holder); } - return FSDirStatAndListingOp.getFileInfo(fsd, src, false, isRawPath, true); + return FSDirStatAndListingOp.getFileInfo(fsd, src, false, isRawPath); } static EncryptionKeyInfo getEncryptionKeyInfo(FSNamesystem fsn,