0

图像卷缓存仅适用于 QCOW2 图像,不适用于 RAW 图像。Cinder 的这一功能有望显着提高卷创建性能。 https://docs.openstack.org/cinder/latest/admin/blockstorage-image-volume-cache.html

4

1 回答 1

1

从镜像创建卷,首先尝试调用clone_image接口,然后尝试调用clone_image_volume接口,然后尝试使用镜像缓存。如果所有其他方法都失败,则返回到创建卷的默认行为下载图像数据并将其复制到卷中。

如果卷后端是 ceph 和 ceph 中的 RAW 图像,则从 RAW 图像创建卷,将直接在 ceph 中克隆图像,而不使用图像缓存。

 @utils.retry(exception.SnapshotLimitReached, retries=1)
def _create_from_image(self, context, volume,
                       image_location, image_id, image_meta,
                       image_service, **kwargs):
    LOG.debug("Cloning %(volume_id)s from image %(image_id)s "
              " at location %(image_location)s.",
              {'volume_id': volume.id,
               'image_location': image_location, 'image_id': image_id})

    virtual_size = image_meta.get('virtual_size')
    if virtual_size:
        virtual_size = image_utils.check_virtual_size(virtual_size,
                                                      volume.size,
                                                      image_id)

    # Create the volume from an image.
    #
    # First see if the driver can clone the image directly.
    #
    # NOTE (singn): two params need to be returned
    # dict containing provider_location for cloned volume
    # and clone status.
    # NOTE (lixiaoy1): Currently all images are raw data, we can't
    # use clone_image to copy data if new volume is encrypted.
    volume_is_encrypted = volume.encryption_key_id is not None
    cloned = False
    model_update = None
    if not volume_is_encrypted:
        model_update, cloned = self.driver.clone_image(context,
                                                       volume,
                                                       image_location,
                                                       image_meta,
                                                       image_service)

    # Try and clone the image if we have it set as a glance location.
    if not cloned and 'cinder' in CONF.allowed_direct_url_schemes:
        model_update, cloned = self._clone_image_volume(context,
                                                        volume,
                                                        image_location,
                                                        image_meta)

    # If we're going to try using the image cache then prepare the cache
    # entry. Note: encrypted volume images are not cached.
    if not cloned and self.image_volume_cache and not volume_is_encrypted:
        # If _prepare_image_cache_entry() has to create the cache entry
        # then it will also create the volume. But if the volume image
        # is already in the cache then it returns (None, False), and
        # _create_from_image_cache_or_download() will use the cache.
        model_update, cloned = self._prepare_image_cache_entry(
            context,
            volume,
            image_location,
            image_id,
            image_meta,
            image_service)

    # Try and use the image cache, and download if not cached.
    if not cloned:
        model_update = self._create_from_image_cache_or_download(
            context,
            volume,
            image_location,
            image_id,
            image_meta,
            image_service)

    self._handle_bootable_volume_glance_meta(context, volume,
                                             image_id=image_id,
                                             image_meta=image_meta)
    return model_update

https://github.com/openstack/cinder/blob/master/cinder/volume/flows/manager/create_volume.py

于 2020-09-20T07:23:49.873 回答