private static void runWithStorageReadLocksTemporaryReleased(@NotNull StorageLockContext lockContext,
                                                               @NotNull ThrowableRunnable<IOException> task) throws IOException {
    int readLocksActuallyReleased = 0;
    Lock readLock = lockContext.readLock();
    try {
      int readLocksToRelease = lockContext.readLockHolds();
      //readLocksActuallyReleased counts locks _actually released_ -- i.e. if the loop terminates earlier than readLocksToRelease,
      // we'll acquire back only the number of locks we've actually released, not more.
      while (readLocksActuallyReleased < readLocksToRelease) {
        readLock.unlock();
        readLocksActuallyReleased++;
      }

      task.run();
    }
    finally {
      for (int i = 0; i < readLocksActuallyReleased; i++) {
        readLock.lock();
      }
    }
  }
private static void runWithStorageReadLocksTemporaryReleased(@NotNull StorageLockContext lockContext,
                                                               @NotNull ThrowableRunnable<IOException> task)