HDFS-16855. Remove the redundant write lock in addBlockPool. Contributed by DingShun.

This commit is contained in:
shun01.ding 2022-11-28 21:19:10 +08:00
parent 1a7acc403b
commit 54a0786d10
1 changed files with 9 additions and 11 deletions

View File

@ -3187,17 +3187,15 @@ class FsDatasetImpl implements FsDatasetSpi<FsVolumeImpl> {
throws IOException { throws IOException {
LOG.info("Adding block pool " + bpid); LOG.info("Adding block pool " + bpid);
AddBlockPoolException volumeExceptions = new AddBlockPoolException(); AddBlockPoolException volumeExceptions = new AddBlockPoolException();
try (AutoCloseableLock lock = lockManager.writeLock(LockLevel.BLOCK_POOl, bpid)) { try {
try { volumes.addBlockPool(bpid, conf);
volumes.addBlockPool(bpid, conf); } catch (AddBlockPoolException e) {
} catch (AddBlockPoolException e) { volumeExceptions.mergeException(e);
volumeExceptions.mergeException(e); }
} volumeMap.initBlockPool(bpid);
volumeMap.initBlockPool(bpid); Set<String> vols = storageMap.keySet();
Set<String> vols = storageMap.keySet(); for (String v : vols) {
for (String v : vols) { lockManager.addLock(LockLevel.VOLUME, bpid, v);
lockManager.addLock(LockLevel.VOLUME, bpid, v);
}
} }
try { try {
volumes.getAllVolumesMap(bpid, volumeMap, ramDiskReplicaTracker); volumes.getAllVolumesMap(bpid, volumeMap, ramDiskReplicaTracker);