private static File prepareDirectory(File dir) throws IOException {
    if (!dir.exists()) {
      dir.mkdir();
    }
    if (!dir.isDirectory()) {
      throw new IOException(dir.getAbsolutePath() + " is not a directory or could not be created");
    }
    return dir;
  }
Create a directory if it does not yet exist and check that it is accessible.
@param dir The directory to possibly create.
@return the passed-in directory
@throws IOException if the specified directory could not be created/read, or if a non-directory file with the same
                    name already exists.
ambry-store/src/main/java/com/github/ambry/store/DiskSpaceAllocator.java