code: @Nullable
    public static StorageDirView selectDirWithRequestedSpace(long bytesToBeAvailable,
        BlockStoreLocation location, BlockMetadataManagerView mManagerView) {
      if (location.equals(BlockStoreLocation.anyTier())) {
        for (StorageTierView tierView : mManagerView.getTierViews()) {
          for (StorageDirView dirView : tierView.getDirViews()) {
            if (dirView.getAvailableBytes() >= bytesToBeAvailable) {
              return dirView;
            }
          }
        }
        return null;
      }
  
      String tierAlias = location.tierAlias();
      StorageTierView tierView = mManagerView.getTierView(tierAlias);
      if (location.equals(BlockStoreLocation.anyDirInTier(tierAlias))) {
        for (StorageDirView dirView : tierView.getDirViews()) {
          if (dirView.getAvailableBytes() >= bytesToBeAvailable) {
            return dirView;
          }
        }
        return null;
      }
  
      StorageDirView dirView = tierView.getDirView(location.dir());
      return (dirView.getAvailableBytes() >= bytesToBeAvailable) ? dirView : null;
    }
docs: Finds a directory in the given location range with capacity upwards of the given bound.
  
  @param bytesToBeAvailable the capacity bound
  @param location the location range
  @param mManagerView the storage manager view
  @return a {@link StorageDirView} in the range of location that already has availableBytes
  larger than bytesToBeAvailable, otherwise null