diff options
Diffstat (limited to 'nova/utils.py')
-rw-r--r-- | nova/utils.py | 49 |
1 files changed, 0 insertions, 49 deletions
diff --git a/nova/utils.py b/nova/utils.py index bd93aea3aa..c2e304fc99 100644 --- a/nova/utils.py +++ b/nova/utils.py @@ -20,11 +20,9 @@ import contextlib import copy import datetime -import errno import functools import hashlib import inspect -import mmap import os import pyclbr import random @@ -1341,53 +1339,6 @@ def get_endpoint(ksa_adapter): "interfaces: %s" % interfaces) -def supports_direct_io(dirpath): - - if not hasattr(os, 'O_DIRECT'): - LOG.debug("This python runtime does not support direct I/O") - return False - - testfile = os.path.join(dirpath, ".directio.test") - - hasDirectIO = True - fd = None - try: - fd = os.open(testfile, os.O_CREAT | os.O_WRONLY | os.O_DIRECT) - # Check is the write allowed with 512 byte alignment - align_size = 512 - m = mmap.mmap(-1, align_size) - m.write(b"x" * align_size) - os.write(fd, m) - LOG.debug("Path '%(path)s' supports direct I/O", - {'path': dirpath}) - except OSError as e: - if e.errno == errno.EINVAL: - LOG.debug("Path '%(path)s' does not support direct I/O: " - "'%(ex)s'", {'path': dirpath, 'ex': e}) - hasDirectIO = False - else: - with excutils.save_and_reraise_exception(): - LOG.error("Error on '%(path)s' while checking " - "direct I/O: '%(ex)s'", - {'path': dirpath, 'ex': e}) - except Exception as e: - with excutils.save_and_reraise_exception(): - LOG.error("Error on '%(path)s' while checking direct I/O: " - "'%(ex)s'", {'path': dirpath, 'ex': e}) - finally: - # ensure unlink(filepath) will actually remove the file by deleting - # the remaining link to it in close(fd) - if fd is not None: - os.close(fd) - - try: - os.unlink(testfile) - except Exception: - pass - - return hasDirectIO - - def generate_hostid(host, project_id): """Generate an obfuscated host id representing the host. |