Skip to content

Commit 4988364

Browse files
committed
adjust hardLinkOneBlock() write lock
1 parent de73618 commit 4988364

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsDatasetImpl.java

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3868,20 +3868,15 @@ public long getPendingAsyncDeletions() {
38683868
@Override
38693869
public void hardLinkOneBlock(ExtendedBlock srcBlock, ExtendedBlock dstBlock) throws IOException {
38703870
BlockLocalPathInfo blpi = getBlockLocalPathInfo(srcBlock);
3871-
File src = new File(blpi.getBlockPath());
3872-
File srcMeta = new File(blpi.getMetaPath());
3873-
38743871
FsVolumeImpl v = getVolume(srcBlock);
38753872

3876-
if (v.getAvailable() < dstBlock.getNumBytes()) {
3877-
throw new DiskOutOfSpaceException("Insufficient space for hardlink block " + srcBlock);
3878-
}
3879-
3880-
BlockPoolSlice dstBPS = v.getBlockPoolSlice(dstBlock.getBlockPoolId());
3881-
File dstBlockFile = dstBPS.hardLinkOneBlock(src, srcMeta, dstBlock.getLocalBlock());
3882-
38833873
try (AutoCloseableLock lock = lockManager.writeLock(LockLevel.VOLUME, dstBlock.getBlockPoolId(),
38843874
v.getStorageID())) {
3875+
File src = new File(blpi.getBlockPath());
3876+
File srcMeta = new File(blpi.getMetaPath());
3877+
BlockPoolSlice dstBPS = v.getBlockPoolSlice(dstBlock.getBlockPoolId());
3878+
File dstBlockFile = dstBPS.hardLinkOneBlock(src, srcMeta, dstBlock.getLocalBlock());
3879+
38853880
ReplicaInfo replicaInfo =
38863881
new LocalReplicaInPipeline(dstBlock.getBlockId(), dstBlock.getGenerationStamp(), v,
38873882
dstBlockFile.getParentFile(), dstBlock.getLocalBlock().getNumBytes());

hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/extdataset/ExternalDatasetImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ public long getPendingAsyncDeletions() {
497497
@Override
498498
public void hardLinkOneBlock(ExtendedBlock srcBlock, ExtendedBlock dstBlock)
499499
throws IOException {
500-
500+
throw new UnsupportedOperationException();
501501
}
502502

503503
}

0 commit comments

Comments
 (0)