|
@@ -7196,13 +7196,13 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
final String operationName = "allowSnapshot";
|
|
|
checkSuperuserPrivilege(operationName, path);
|
|
|
- writeLock();
|
|
|
+ writeLock(FSNamesystemLockMode.FS);
|
|
|
try {
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
checkNameNodeSafeMode("Cannot allow snapshot for " + path);
|
|
|
FSDirSnapshotOp.allowSnapshot(dir, snapshotManager, path);
|
|
|
} finally {
|
|
|
- writeUnlock(operationName, getLockReportInfoSupplier(path));
|
|
|
+ writeUnlock(FSNamesystemLockMode.FS, operationName, getLockReportInfoSupplier(path));
|
|
|
}
|
|
|
getEditLog().logSync();
|
|
|
logAuditEvent(true, operationName, path, null, null);
|
|
@@ -7213,13 +7213,13 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
final String operationName = "disallowSnapshot";
|
|
|
checkSuperuserPrivilege(operationName, path);
|
|
|
- writeLock();
|
|
|
+ writeLock(FSNamesystemLockMode.FS);
|
|
|
try {
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
checkNameNodeSafeMode("Cannot disallow snapshot for " + path);
|
|
|
FSDirSnapshotOp.disallowSnapshot(dir, snapshotManager, path);
|
|
|
} finally {
|
|
|
- writeUnlock(operationName, getLockReportInfoSupplier(path));
|
|
|
+ writeUnlock(FSNamesystemLockMode.FS, operationName, getLockReportInfoSupplier(path));
|
|
|
}
|
|
|
getEditLog().logSync();
|
|
|
logAuditEvent(true, operationName, path, null, null);
|
|
@@ -7238,14 +7238,15 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
final FSPermissionChecker pc = getPermissionChecker();
|
|
|
FSPermissionChecker.setOperationType(operationName);
|
|
|
try {
|
|
|
- writeLock();
|
|
|
+ writeLock(FSNamesystemLockMode.FS);
|
|
|
try {
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
checkNameNodeSafeMode("Cannot create snapshot for " + snapshotRoot);
|
|
|
snapshotPath = FSDirSnapshotOp.createSnapshot(dir, pc,
|
|
|
snapshotManager, snapshotRoot, snapshotName, logRetryCache);
|
|
|
} finally {
|
|
|
- writeUnlock(operationName, getLockReportInfoSupplier(snapshotRoot));
|
|
|
+ writeUnlock(FSNamesystemLockMode.FS, operationName,
|
|
|
+ getLockReportInfoSupplier(snapshotRoot));
|
|
|
}
|
|
|
} catch (AccessControlException ace) {
|
|
|
logAuditEvent(false, operationName, snapshotRoot);
|
|
@@ -7275,15 +7276,15 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
final FSPermissionChecker pc = getPermissionChecker();
|
|
|
FSPermissionChecker.setOperationType(operationName);
|
|
|
try {
|
|
|
- writeLock();
|
|
|
+ writeLock(FSNamesystemLockMode.FS);
|
|
|
try {
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
checkNameNodeSafeMode("Cannot rename snapshot for " + path);
|
|
|
FSDirSnapshotOp.renameSnapshot(dir, pc, snapshotManager, path,
|
|
|
snapshotOldName, snapshotNewName, logRetryCache);
|
|
|
} finally {
|
|
|
- writeUnlock(operationName, getLockReportInfoSupplier(oldSnapshotRoot,
|
|
|
- newSnapshotRoot));
|
|
|
+ writeUnlock(FSNamesystemLockMode.FS, operationName,
|
|
|
+ getLockReportInfoSupplier(oldSnapshotRoot, newSnapshotRoot));
|
|
|
}
|
|
|
} catch (AccessControlException ace) {
|
|
|
logAuditEvent(false, operationName, oldSnapshotRoot,
|
|
@@ -7310,13 +7311,13 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
final FSPermissionChecker pc = getPermissionChecker();
|
|
|
FSPermissionChecker.setOperationType(operationName);
|
|
|
try {
|
|
|
- readLock();
|
|
|
+ readLock(FSNamesystemLockMode.FS);
|
|
|
try {
|
|
|
checkOperation(OperationCategory.READ);
|
|
|
status = FSDirSnapshotOp.getSnapshottableDirListing(dir, pc,
|
|
|
snapshotManager);
|
|
|
} finally {
|
|
|
- readUnlock(operationName, getLockReportInfoSupplier(null));
|
|
|
+ readUnlock(FSNamesystemLockMode.FS, operationName, getLockReportInfoSupplier(null));
|
|
|
}
|
|
|
} catch (AccessControlException ace) {
|
|
|
logAuditEvent(false, operationName, null, null, null);
|
|
@@ -7341,14 +7342,14 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
final FSPermissionChecker pc = getPermissionChecker();
|
|
|
FSPermissionChecker.setOperationType(operationName);
|
|
|
try {
|
|
|
- readLock();
|
|
|
+ readLock(FSNamesystemLockMode.FS);
|
|
|
try {
|
|
|
checkOperation(OperationCategory.READ);
|
|
|
status = FSDirSnapshotOp.getSnapshotListing(dir, pc, snapshotManager,
|
|
|
snapshotRoot);
|
|
|
success = true;
|
|
|
} finally {
|
|
|
- readUnlock(operationName, getLockReportInfoSupplier(null));
|
|
|
+ readUnlock(FSNamesystemLockMode.FS, operationName, getLockReportInfoSupplier(null));
|
|
|
}
|
|
|
} catch (AccessControlException ace) {
|
|
|
logAuditEvent(success, operationName, snapshotRoot);
|
|
@@ -7386,14 +7387,14 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
FSPermissionChecker.setOperationType(operationName);
|
|
|
long actualTime = Time.monotonicNow();
|
|
|
try {
|
|
|
- readLock();
|
|
|
+ readLock(FSNamesystemLockMode.FS);
|
|
|
try {
|
|
|
checkOperation(OperationCategory.READ);
|
|
|
diffs = FSDirSnapshotOp.getSnapshotDiffReport(dir, pc, snapshotManager,
|
|
|
path, fromSnapshot, toSnapshot);
|
|
|
} finally {
|
|
|
- readUnlock(operationName, getLockReportInfoSupplier(fromSnapshotRoot,
|
|
|
- toSnapshotRoot));
|
|
|
+ readUnlock(FSNamesystemLockMode.FS, operationName,
|
|
|
+ getLockReportInfoSupplier(fromSnapshotRoot, toSnapshotRoot));
|
|
|
}
|
|
|
} catch (AccessControlException ace) {
|
|
|
logAuditEvent(false, operationName, fromSnapshotRoot,
|
|
@@ -7460,7 +7461,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
final FSPermissionChecker pc = getPermissionChecker();
|
|
|
FSPermissionChecker.setOperationType(operationName);
|
|
|
try {
|
|
|
- readLock();
|
|
|
+ readLock(FSNamesystemLockMode.FS);
|
|
|
try {
|
|
|
checkOperation(OperationCategory.READ);
|
|
|
diffs = FSDirSnapshotOp
|
|
@@ -7468,8 +7469,8 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
fromSnapshot, toSnapshot, startPath, index,
|
|
|
snapshotDiffReportLimit);
|
|
|
} finally {
|
|
|
- readUnlock(operationName, getLockReportInfoSupplier(fromSnapshotRoot,
|
|
|
- toSnapshotRoot));
|
|
|
+ readUnlock(FSNamesystemLockMode.FS, operationName,
|
|
|
+ getLockReportInfoSupplier(fromSnapshotRoot, toSnapshotRoot));
|
|
|
}
|
|
|
} catch (AccessControlException ace) {
|
|
|
logAuditEvent(false, operationName, fromSnapshotRoot, toSnapshotRoot,
|
|
@@ -7497,7 +7498,8 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
FSPermissionChecker.setOperationType(operationName);
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
try {
|
|
|
- writeLock();
|
|
|
+ // It involves Block while collecting blocks to be deleted.
|
|
|
+ writeLock(FSNamesystemLockMode.GLOBAL);
|
|
|
try {
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
checkNameNodeSafeMode("Cannot delete snapshot for " + snapshotRoot);
|
|
@@ -7505,7 +7507,8 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
blocksToBeDeleted = FSDirSnapshotOp.deleteSnapshot(dir, pc,
|
|
|
snapshotManager, snapshotRoot, snapshotName, logRetryCache);
|
|
|
} finally {
|
|
|
- writeUnlock(operationName, getLockReportInfoSupplier(rootPath));
|
|
|
+ writeUnlock(FSNamesystemLockMode.GLOBAL, operationName,
|
|
|
+ getLockReportInfoSupplier(rootPath));
|
|
|
}
|
|
|
} catch (AccessControlException ace) {
|
|
|
logAuditEvent(false, operationName, rootPath, null, null);
|