HDFS-13602. Add checkOperation(WRITE) checks in FSNamesystem. Contributed by Chao Sun.

This commit is contained in:
Chao Sun 2018-05-31 15:24:16 -07:00 committed by Konstantin V Shvachko
parent 6b74f5d7fc
commit ff013d2c95

View File

@ -1952,6 +1952,7 @@ LocatedBlocks getBlockLocations(String clientMachine, String srcArg,
if (!isInSafeMode() && res.updateAccessTime()) {
String src = srcArg;
checkOperation(OperationCategory.WRITE);
writeLock();
final long now = now();
try {
@ -2034,6 +2035,7 @@ void concat(String target, String [] srcs, boolean logRetryCache)
FileStatus stat = null;
boolean success = false;
final FSPermissionChecker pc = getPermissionChecker();
checkOperation(OperationCategory.WRITE);
writeLock();
try {
checkOperation(OperationCategory.WRITE);
@ -2137,6 +2139,7 @@ void createSymlink(String target, String link,
throw new UnsupportedOperationException("Symlinks not supported");
}
FileStatus auditStat = null;
checkOperation(OperationCategory.WRITE);
writeLock();
try {
checkOperation(OperationCategory.WRITE);
@ -5306,6 +5309,7 @@ void updatePipeline(
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()
@ -6605,6 +6609,7 @@ void deleteSnapshot(String snapshotRoot, String snapshotName,
String rootPath = null;
BlocksMapUpdateInfo blocksToBeDeleted = null;
final FSPermissionChecker pc = getPermissionChecker();
checkOperation(OperationCategory.WRITE);
writeLock();
try {
checkOperation(OperationCategory.WRITE);
@ -6645,6 +6650,7 @@ RollingUpgradeInfo queryRollingUpgrade() throws IOException {
checkOperation(OperationCategory.READ);
readLock();
try {
checkOperation(OperationCategory.READ);
if (!isRollingUpgrade()) {
return null;
}
@ -6897,6 +6903,7 @@ long addCacheDirective(CacheDirectiveInfo directive,
if (!flags.contains(CacheFlag.FORCE)) {
cacheManager.waitForRescanIfNeeded();
}
checkOperation(OperationCategory.WRITE);
writeLock();
try {
checkOperation(OperationCategory.WRITE);
@ -6928,6 +6935,7 @@ void modifyCacheDirective(CacheDirectiveInfo directive,
if (!flags.contains(CacheFlag.FORCE)) {
cacheManager.waitForRescanIfNeeded();
}
checkOperation(OperationCategory.WRITE);
writeLock();
try {
checkOperation(OperationCategory.WRITE);
@ -6953,6 +6961,7 @@ void removeCacheDirective(long id, boolean logRetryCache) throws IOException {
final String operationName = "removeCacheDirective";
boolean success = false;
String idStr = "{id: " + Long.toString(id) + "}";
checkOperation(OperationCategory.WRITE);
writeLock();
try {
checkOperation(OperationCategory.WRITE);
@ -6997,6 +7006,7 @@ BatchedListEntries<CacheDirectiveEntry> listCacheDirectives(
void addCachePool(CachePoolInfo req, boolean logRetryCache)
throws IOException {
final String operationName = "addCachePool";
checkOperation(OperationCategory.WRITE);
writeLock();
boolean success = false;
String poolInfoStr = null;
@ -7021,6 +7031,7 @@ void addCachePool(CachePoolInfo req, boolean logRetryCache)
void modifyCachePool(CachePoolInfo req, boolean logRetryCache)
throws IOException {
final String operationName = "modifyCachePool";
checkOperation(OperationCategory.WRITE);
writeLock();
boolean success = false;
String poolNameStr = "{poolName: " +
@ -7047,6 +7058,7 @@ void modifyCachePool(CachePoolInfo req, boolean logRetryCache)
void removeCachePool(String cachePoolName, boolean logRetryCache)
throws IOException {
final String operationName = "removeCachePool";
checkOperation(OperationCategory.WRITE);
writeLock();
boolean success = false;
String poolNameStr = "{poolName: " + cachePoolName + "}";