Repository: hadoop Updated Branches: refs/heads/branch-2 6b9ef2d5b -> 87e805ba4
HDFS-13602. Add checkOperation(WRITE) checks in FSNamesystem. Contributed by Chao Sun. (cherry picked from commit ff013d2c952272f3176dcf624251b05d610503b5) Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/87e805ba Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/87e805ba Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/87e805ba Branch: refs/heads/branch-2 Commit: 87e805ba4dd037e79223a839633747f8859a7267 Parents: 6b9ef2d Author: Chao Sun <[email protected]> Authored: Thu May 31 15:24:16 2018 -0700 Committer: Konstantin V Shvachko <[email protected]> Committed: Thu May 31 17:44:39 2018 -0700 ---------------------------------------------------------------------- .../apache/hadoop/hdfs/server/namenode/FSNamesystem.java | 11 +++++++++++ 1 file changed, 11 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/87e805ba/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java ---------------------------------------------------------------------- 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 144601e..11da1f6 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 @@ -1850,6 +1850,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean, if (!isInSafeMode() && res.updateAccessTime()) { String src = srcArg; + checkOperation(OperationCategory.WRITE); writeLock(); final long now = now(); try { @@ -1922,6 +1923,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean, final String operationName = "concat"; FileStatus stat = null; boolean success = false; + checkOperation(OperationCategory.WRITE); writeLock(); try { checkOperation(OperationCategory.WRITE); @@ -4951,6 +4953,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean, String clientName, ExtendedBlock oldBlock, ExtendedBlock newBlock, DatanodeID[] newNodes, String[] newStorageIDs, boolean logRetryCache) throws IOException { + checkOperation(OperationCategory.WRITE); LOG.info("updatePipeline(" + oldBlock.getLocalBlock() + ", newGS=" + newBlock.getGenerationStamp() + ", newLength=" + newBlock.getNumBytes() @@ -6134,6 +6137,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean, boolean logRetryCache) throws IOException { final String operationName = "deleteSnapshot"; boolean success = false; + checkOperation(OperationCategory.WRITE); writeLock(); BlocksMapUpdateInfo blocksToBeDeleted = null; try { @@ -6173,6 +6177,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean, checkOperation(OperationCategory.READ); readLock(); try { + checkOperation(OperationCategory.READ); if (!isRollingUpgrade()) { return null; } @@ -6427,6 +6432,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean, if (!flags.contains(CacheFlag.FORCE)) { cacheManager.waitForRescanIfNeeded(); } + checkOperation(OperationCategory.WRITE); writeLock(); try { checkOperation(OperationCategory.WRITE); @@ -6455,6 +6461,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean, if (!flags.contains(CacheFlag.FORCE)) { cacheManager.waitForRescanIfNeeded(); } + checkOperation(OperationCategory.WRITE); writeLock(); try { checkOperation(OperationCategory.WRITE); @@ -6476,6 +6483,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean, void removeCacheDirective(long id, boolean logRetryCache) throws IOException { final String operationName = "removeCacheDirective"; boolean success = false; + checkOperation(OperationCategory.WRITE); writeLock(); try { checkOperation(OperationCategory.WRITE); @@ -6515,6 +6523,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean, void addCachePool(CachePoolInfo req, boolean logRetryCache) throws IOException { final String operationName = "addCachePool"; + checkOperation(OperationCategory.WRITE); writeLock(); boolean success = false; String poolInfoStr = null; @@ -6537,6 +6546,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean, void modifyCachePool(CachePoolInfo req, boolean logRetryCache) throws IOException { final String operationName = "modifyCachePool"; + checkOperation(OperationCategory.WRITE); writeLock(); boolean success = false; try { @@ -6559,6 +6569,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean, void removeCachePool(String cachePoolName, boolean logRetryCache) throws IOException { final String operationName = "removeCachePool"; + checkOperation(OperationCategory.WRITE); writeLock(); boolean success = false; try { --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
