diff options
author | Jack Ding <jack.ding@windriver.com> | 2018-10-02 11:59:37 -0400 |
---|---|---|
committer | Jack Ding <jack.ding@windriver.com> | 2018-11-21 15:57:11 -0500 |
commit | 728f20e8f4ac2e3d4b893b7169b81d20471d0be9 (patch) | |
tree | 09241bf0a5ab0ec6d3224da26314897f1a75ce9a /nova/virt/images.py | |
parent | 7217e38bafb75e8a613763835b64e48e6b2c8ece (diff) | |
download | nova-728f20e8f4ac2e3d4b893b7169b81d20471d0be9.tar.gz |
Add I/O Semaphore to limit concurrent disk ops
Introduce an I/O semaphore to limit the number of concurrent
disk-IO-intensive operations. This could reduce disk contention from
image operations like image download, image format conversion, snapshot
extraction, etc.
The new config option max_concurrent_disk_ops can be set in nova.conf
per compute host and would be virt-driver-agnostic. It is default to 0
which means no limit.
blueprint: io-semaphore-for-concurrent-disk-ops
Change-Id: I897999e8a4601694213f068367eae9608cdc7bbb
Signed-off-by: Jack Ding <jack.ding@windriver.com>
Diffstat (limited to 'nova/virt/images.py')
-rw-r--r-- | nova/virt/images.py | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/nova/virt/images.py b/nova/virt/images.py index dbaa4e7b30..2f04f86eef 100644 --- a/nova/virt/images.py +++ b/nova/virt/images.py @@ -28,6 +28,7 @@ from oslo_utils import fileutils from oslo_utils import imageutils from oslo_utils import units +from nova.compute import utils as compute_utils import nova.conf from nova import exception from nova.i18n import _ @@ -118,12 +119,13 @@ def convert_image_unsafe(source, dest, out_format, run_as_root=False): def _convert_image(source, dest, in_format, out_format, run_as_root): try: - if not run_as_root: - nova.privsep.qemu.unprivileged_convert_image( - source, dest, in_format, out_format, CONF.instances_path) - else: - nova.privsep.qemu.convert_image( - source, dest, in_format, out_format, CONF.instances_path) + with compute_utils.disk_ops_semaphore: + if not run_as_root: + nova.privsep.qemu.unprivileged_convert_image( + source, dest, in_format, out_format, CONF.instances_path) + else: + nova.privsep.qemu.convert_image( + source, dest, in_format, out_format, CONF.instances_path) except processutils.ProcessExecutionError as exp: msg = (_("Unable to convert image to %(format)s: %(exp)s") % @@ -133,8 +135,9 @@ def _convert_image(source, dest, in_format, out_format, run_as_root): def fetch(context, image_href, path, trusted_certs=None): with fileutils.remove_path_on_error(path): - IMAGE_API.download(context, image_href, dest_path=path, - trusted_certs=trusted_certs) + with compute_utils.disk_ops_semaphore: + IMAGE_API.download(context, image_href, dest_path=path, + trusted_certs=trusted_certs) def get_info(context, image_href): |