long registerPagedFileStorage(@NotNull PagedFileStorage storage) {
    synchronized (storageById) {
      Path storageFile = storage.getFile();
      Path storageAbsolutePath = storageFile.toAbsolutePath();
      PagedFileStorage alreadyRegisteredStorage = storageByAbsolutePath.get(storageAbsolutePath);
      if (alreadyRegisteredStorage != null) {
        IllegalStateException ex = new IllegalStateException(
          "Storage for [" + storageAbsolutePath + "] is already registered"
        );
        if (KEEP_STACK_TRACE_AT_STORAGE_REGISTRATION) {
          Exception stackTraceHolder = stackTracesOfStorageRegistration.get(storageAbsolutePath);
          if (stackTraceHolder != null) {
            ex.addSuppressed(stackTraceHolder);
          }
        }
        if (THROW_ERROR_ON_DUPLICATE_STORAGE_REGISTRATION) {
          throw ex;
        }
        else {
          LOG.warn(ex.getMessage(), ex);
        }
      }

      //Generate unique 'id' (index) for a new storage: just find the number not occupied yet. Assume
      // storages are rarely closed, so start with currently registered storages count, and count up
      // until 'index' is not in use yet:
      int storageIndex = storageById.size();
      while (storageById.get(storageIndex) != null) {
        storageIndex++;
      }
      storageById.put(storageIndex, storage);
      storageByAbsolutePath.put(storageAbsolutePath, storage);
      if (KEEP_STACK_TRACE_AT_STORAGE_REGISTRATION) {
        stackTracesOfStorageRegistration.put(storageAbsolutePath,
                                             new Exception("Storage[" + storageAbsolutePath + "] registration stack trace"));
      }
      myMaxRegisteredFiles = Math.max(myMaxRegisteredFiles, storageById.size());
      return (long)storageIndex << 32;
    }
  }
long registerPagedFileStorage(@NotNull PagedFileStorage storage)