code: private void copyBlockLocalFinalize(int dstNamespaceId,
        Block dstBlock, File dstBlockFile)
      throws IOException {
      boolean inlineChecksum = Block.isInlineChecksumBlockFilename(dstBlockFile
          .getName());
      long blkSize = 0;
      long fileSize = dstBlockFile.length();
      lock.writeLock().lock();
      try {
        DatanodeBlockInfo info = volumeMap.get(dstNamespaceId, dstBlock);
        if (info == null) {
          throw new IOException("Could not find information for " + dstBlock);
        }
        if (inlineChecksum) {
          blkSize = BlockInlineChecksumReader.getBlockSizeFromFileLength(fileSize,
              info.getChecksumType(), info.getBytesPerChecksum());
        } else {
          blkSize = fileSize;
        }
  
        FSVolume dstVol = info.getBlockDataFile().getVolume();
        // Finalize block on disk.
        File dest = dstVol.addBlock(dstNamespaceId, dstBlock, dstBlockFile,
            info.isInlineChecksum(), info.getChecksumType(),
            info.getBytesPerChecksum());
        volumeMap.add(dstNamespaceId, dstBlock,
            new DatanodeBlockInfo(dstVol, dest, blkSize, true, inlineChecksum,
                info.getChecksumType(), info.getBytesPerChecksum(), false, 0));
        volumeMap.removeOngoingCreates(dstNamespaceId, dstBlock);
      } finally {
        lock.writeLock().unlock();
      }
    }
docs: Finalize the block in FSDataset.
  
  @param dstNamespaceId
  the namespace id for dstBlock
  @param dstBlock
  the block that needs to be finalized
  @param dstBlockFile
  the block file for the block that has to be finalized
  @throws IOException