HDFS-16085. Move the getPermissionChecker out of the read lock (#3134). Contributed by tomscut.

Signed-off-by: Takanobu Asanuma <tasanuma@apache.org>
Signed-off-by: Ayush Saxena <ayushsaxena@apache.org>
This commit is contained in:
litao 2021-06-24 18:29:42 +08:00 committed by Ayush Saxena
parent 5fc61d2e56
commit 4ca49fcd44

View File

@ -573,10 +573,11 @@ private LocatedBlocks getBlockLocations(String path, HdfsFileStatus file)
final FSNamesystem fsn = namenode.getNamesystem(); final FSNamesystem fsn = namenode.getNamesystem();
final String operationName = "fsckGetBlockLocations"; final String operationName = "fsckGetBlockLocations";
FSPermissionChecker.setOperationType(operationName); FSPermissionChecker.setOperationType(operationName);
FSPermissionChecker pc = fsn.getPermissionChecker();
fsn.readLock(); fsn.readLock();
try { try {
blocks = FSDirStatAndListingOp.getBlockLocations( blocks = FSDirStatAndListingOp.getBlockLocations(
fsn.getFSDirectory(), fsn.getPermissionChecker(), fsn.getFSDirectory(), pc,
path, 0, fileLen, false) path, 0, fileLen, false)
.blocks; .blocks;
} catch (FileNotFoundException fnfe) { } catch (FileNotFoundException fnfe) {