public synchronized File increaseFileReference(final File file) throws IOException {
    // if the file is already a hardlink, just increase reference count and return it
    if (increaseReferenceIfExists(file.getPath())) {
      return file;
    }

    // if the file is not a hardlink, check if there is a related hardlink in pipe dir. if so,
    // increase reference count and return it.
    final File hardlink = getHardlinkInPipeWALDir(file);
    if (increaseReferenceIfExists(hardlink.getPath())) {
      return hardlink;
    }

    // if the file is a wal, and there is no related hardlink in pipe dir, create a hardlink to pipe
    // dir, maintain a reference count for the hardlink, and return the hardlink.
    hardlinkToReferenceMap.put(hardlink.getPath(), 1);
    return FileUtils.createHardLink(file, hardlink);
  }
given a file, create a hardlink, maintain a reference count for the hardlink, and return the
hardlink.

<p>if the given file is already a hardlink, increase its reference count and return it.

<p>if the given file is a wal, create a hardlink in pipe dir, increase the reference count of
the hardlink and return it.

@param file wal file. can be original file or the hardlink of original file
@return the hardlink
@throws IOException when create hardlink failed
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/resource/wal/hardlink/PipeWALHardlinkResourceManager.java