|
@@ -941,8 +941,11 @@ class FsDatasetImpl implements FsDatasetSpi<FsVolumeImpl> {
|
|
+ replicaInfo.getVolume().getStorageType());
|
|
+ replicaInfo.getVolume().getStorageType());
|
|
}
|
|
}
|
|
|
|
|
|
- try (FsVolumeReference volumeRef = volumes.getNextVolume(
|
|
|
|
- targetStorageType, block.getNumBytes())) {
|
|
|
|
|
|
+ FsVolumeReference volumeRef = null;
|
|
|
|
+ synchronized (this) {
|
|
|
|
+ volumeRef = volumes.getNextVolume(targetStorageType, block.getNumBytes());
|
|
|
|
+ }
|
|
|
|
+ try {
|
|
File oldBlockFile = replicaInfo.getBlockFile();
|
|
File oldBlockFile = replicaInfo.getBlockFile();
|
|
File oldMetaFile = replicaInfo.getMetaFile();
|
|
File oldMetaFile = replicaInfo.getMetaFile();
|
|
FsVolumeImpl targetVolume = (FsVolumeImpl) volumeRef.getVolume();
|
|
FsVolumeImpl targetVolume = (FsVolumeImpl) volumeRef.getVolume();
|
|
@@ -961,6 +964,10 @@ class FsDatasetImpl implements FsDatasetSpi<FsVolumeImpl> {
|
|
|
|
|
|
removeOldReplica(replicaInfo, newReplicaInfo, oldBlockFile, oldMetaFile,
|
|
removeOldReplica(replicaInfo, newReplicaInfo, oldBlockFile, oldMetaFile,
|
|
oldBlockFile.length(), oldMetaFile.length(), block.getBlockPoolId());
|
|
oldBlockFile.length(), oldMetaFile.length(), block.getBlockPoolId());
|
|
|
|
+ } finally {
|
|
|
|
+ if (volumeRef != null) {
|
|
|
|
+ volumeRef.close();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
// Replace the old block if any to reschedule the scanning.
|
|
// Replace the old block if any to reschedule the scanning.
|