private void free(LogSegment logSegment, boolean isSwapSegment) throws StoreException {
    File segmentFile = logSegment.getView().getFirst();
    try {
      logSegment.close(false);
      diskSpaceAllocator.free(segmentFile, logSegment.getCapacityInBytes(), storeId, isSwapSegment);
    } catch (IOException e) {
      StoreErrorCodes errorCode = StoreException.resolveErrorCode(e);
      throw new StoreException(errorCode.toString() + " while freeing log segment", e, errorCode);
    }
  }
Frees the given {@link LogSegment} and its backing segment file.
@param logSegment the {@link LogSegment} instance whose backing file needs to be freed.
@param isSwapSegment whether the segment to free is a swap segment.
@throws StoreException if there is any store exception when freeing the log segment.
ambry-store/src/main/java/com/github/ambry/store/Log.java