目录

Oversubscription in thin provisioning

  • Cinder spec: Over Subscription in Thin Provisioning https://review.openstack.org/#/c/129342/12/specs/kilo/over-subscription-in-thin-provisioning.rst
  • cinder bp: Over subscription in thin provisioning https://blueprints.launchpad.net/cinder/+spec/over-subscription-in-thin-provisioning

所谓 Oversubscription in thin provisioning,就相当于是 Thin Provisioning Storage Pool 的超分比限制,防止 Thin Provisioning Storage Pool 被无限放大。对应的配置项是 max_over_subscription_ratio,默认值为 20.0。e.g.

[lvm-1]
volume_group = centos
volume_driver = cinder.volume.drivers.lvm.LVMVolumeDriver
volume_backend_name = lvm-1
iscsi_helper = tgtadm
iscsi_protocol = iscsi
lvm_max_over_subscription_ratio = 25.0

功能生效的地方是 Cinder Scheduler Filter capacity_filter,代码如下:

# cinder/scheduler/filters/capacity_filter.py

        # Only evaluate using max_over_subscription_ratio if
# thin_provisioning_support is True. Check if the ratio of
# provisioned capacity over total capacity has exceeded over
# subscription ratio.
if (thin and backend_state.thin_provisioning_support and
backend_state.max_over_subscription_ratio >= 1):
provisioned_ratio = ((backend_state.provisioned_capacity_gb +
requested_size) / total)
LOG.debug("Checking provisioning for request of %s GB. "
"Backend: %s", requested_size, backend_state)
if provisioned_ratio > backend_state.max_over_subscription_ratio:
msg_args = {
"provisioned_ratio": provisioned_ratio,
"oversub_ratio": backend_state.max_over_subscription_ratio,
"grouping": grouping,
"grouping_name": backend_state.backend_id,
}
LOG.warning(
"Insufficient free space for thin provisioning. "
"The ratio of provisioned capacity over total capacity "
"%(provisioned_ratio).2f has exceeded the maximum over "
"subscription ratio %(oversub_ratio).2f on %(grouping)s "
"%(grouping_name)s.", msg_args)
return False

如果 provisioned_ratio > backend_state.max_over_subscription_ratio 为 True 则表示当前 provisioned 的比率已经大于 Oversubscription in thin provisioning 设定的比率了,所以当前 Cinder Backend 无法继续创建新的 Volume。

那么,provisioned_ratio 是怎么得到的呢?代码如下:

provisioned_ratio = ((backend_state.provisioned_capacity_gb + requested_size) / total)

首先弄清楚这几个变量的含义及取值:

# cinder/utils.py

    # provisioned_capacity_gb is the apparent total capacity of
# all the volumes created on a backend, which is greater than
# or equal to allocated_capacity_gb, which is the apparent
# total capacity of all the volumes created on a backend
# in Cinder. Using allocated_capacity_gb as the default of
# provisioned_capacity_gb if it is not set.
allocated_capacity_gb = capability.get('allocated_capacity_gb', 0)
provisioned_capacity_gb = capability.get('provisioned_capacity_gb',
allocated_capacity_gb)
thin_provisioning_support = capability.get('thin_provisioning_support',
False)
total_capacity_gb = capability.get('total_capacity_gb', 0)
free_capacity_gb = capability.get('free_capacity_gb', 0)

官方说明

  • total_capacity: This is an existing parameter already reported by the driver. It is the total physical capacity. Example: Assume backend A has a total physical capacity of 100G.

  • available_capacity: This is an existing parameter already reported by the driver. It is the real physical capacity available to be used. Example: Assume backend A has a total physical capacity of 100G. There are 10G thick luns and 20G thin luns (10G out of the 20G thin luns are written). In this case, available_capacity = 100 - 10 -10 = 80G.

  • used_capacity: This parameter is calculated by the difference between total_capacity and available_capacity. It is used below for calculating used ratio.

  • volume_size: This is an existing parameter. It is the size of the volume to be provisioned.

  • provisioned_capacity: This is a new parameter. It is the apparent allocated space indicating how much capacity has been provisioned. Example: User A created 2x10G volumes in Cinder from backend A, and user B created 3x10G volumes from backend A directly, without using Cinder. Assume those are all the volumes provisioned on backend A. The total provisioned_capacity will be 50G and that is what the driver should be reporting.

  • allocated_capacity: This is an existing parameter. Cinder uses this to keep track of how much capacity has been allocated through Cinder. Example: Using the same example above for provisioned_capacity, the allocated_capacity will be 20G because that is what has been provisioned through Cinder. allocated_capacity is documented here to differentiate from the new parameter provisioned_capacity.

简要说明

  • allocated_capacity_gb:实际已分配的容量。
  • provisioned_capacity_gb:已置备的容量,大于或等于 allocated_capacity_gb。

    注:所谓已置备是存储领域的专业术语,表示逻辑上的已经分配出去的虚拟容量,可能是精简置备的也可能是厚置备的。需要与实际已分配的容量作一个区分。
  • total_capacity_gb:实际的总容量。
  • free_capacity_gb:实际剩余的容量。

在 LVM Driver 中的含义

  • allocated_capacity_gb: 在 cinder 中分配的 cinder volume 总大小
  • free_capacity_gb: vg 中空闲的容量
  • provisioned_capacity_gb: vg 上面分配的总大小,因为文件稀疏(Thin)的问题,这个值可能很大
  • total_capacity_gb: vg 容量的总大小
  • max_over_subscription_ratio: 最大超配比

回过头来在看看这条计算公式:

provisioned_ratio = ((backend_state.provisioned_capacity_gb + requested_size) / total)

provisioned_ratio 就是当前已经被置备的容量的比率,包括精简置备或厚置备的情况,也就是我们不希望它太过于大的比率。理应小于 max_over_subscription_ratio。

但有一个问题需要注意,在 LVMDriver 中使用 Thin provisioning 时,provisioned_capacity_gb 马上就等于 VG 的总容量。你会发现虽然你还没有创建任何 Volume,但 provisioned_capacity_gb 就已经等于 VG 的 Size 了。代码如下:

# cinder/volume/drivers/lvm.py
if self.configuration.lvm_mirrors > 0:
total_capacity =\
self.vg.vg_mirror_size(self.configuration.lvm_mirrors)
free_capacity =\
self.vg.vg_mirror_free_space(self.configuration.lvm_mirrors)
provisioned_capacity = round(
float(total_capacity) - float(free_capacity), 2)
elif self.configuration.lvm_type == 'thin':
total_capacity = self.vg.vg_thin_pool_size
free_capacity = self.vg.vg_thin_pool_free_space
provisioned_capacity = self.vg.vg_provisioned_capacity
else:
total_capacity = self.vg.vg_size
free_capacity = self.vg.vg_free_space
provisioned_capacity = round(
float(total_capacity) - float(free_capacity), 2)

这是因为 Cinder 假设,当你使用 LVM Thin provisioning 的时候,那么整个 VG 都应该是 Thin provisioning 的,不存在 Thin 和 Thick 混合的情况,否则无法正确进行容量的计算。因此,当我们使用 LVM Thin provisioning 时,切记要划分一个干净的 VG 给 LVM Backend,否则就会出现资源计算错误的问题。

Cinder LVM Oversubscription in thin provisioning的更多相关文章

  1. 学习OpenStack之 (2):Cinder LVM 配置

    0.背景 OpenStack 中的实例是不能持久化的,cinder服务重启,实例消失.如果需要挂载 volume,需要在 volume 中实现持久化.Cinder提供持久的块存储,目前仅供给虚拟机挂载 ...

  2. Cinder LVM backend cinder-volume service down

    目录 文章目录 目录 问题 调查 解决 问题 [stack@manager ~]$ cinder service-list +------------------+------------------ ...

  3. volume image

    http://docs.openstack.org/user-guide/cli_nova_launch_instance_from_volume.html http://docs.openstack ...

  4. cinder介绍及使用lvm本地存储

    1.cinder简介 Cinder提供持久的块存储,目前仅供给虚拟机挂载使用.它并没有实现对块设备的管理和实际服务,而是为后端不同的存储结构提供了统一的接口,不同的块设备服务厂商在 Cinder 中实 ...

  5. Cinder 架构分析、高可用部署与核心功能解析

    目录 文章目录 目录 Cinder Cinder 的软件架构 cinder-api cinder-scheduler cinder-volume Driver 框架 Plugin 框架 cinder- ...

  6. Docker实践(3)—浅析device mapper的thin provision

    thin provision是在 kernel3.2 中引入的.它主要有以下一些特点: (1)允许多个虚拟设备存储在相同的数据卷中,从而达到共享数据,节省空间的目的: (2)支持任意深度的快照.之前的 ...

  7. LVM学习

    LVM Logical Volume Manager Volume management creates a layer of abstraction over physical storage, a ...

  8. LVM学习笔记

    LVM Logical Volume Manager Volume management creates a layer of abstraction over physical storage, a ...

  9. LVM实践

    [root@ftp:/root] > fdisk -l Disk /dev/sda: 53.7 GB, 53687091200 bytes, 104857600 sectors Units = ...

随机推荐

  1. 《数据结构与算法之美》 <04>链表(上):如何实现LRU缓存淘汰算法?

    今天我们来聊聊“链表(Linked list)”这个数据结构.学习链表有什么用呢?为了回答这个问题,我们先来讨论一个经典的链表应用场景,那就是 LRU 缓存淘汰算法. 缓存是一种提高数据读取性能的技术 ...

  2. 目标检测 — one-stage检测(一)

    总结的很好:https://www.cnblogs.com/guoyaohua/p/8994246.html 目前主流的目标检测算法主要是基于深度学习模型,其可以分成两大类:two-stage检测算法 ...

  3. 目标检测 — two-stage检测

    目前主流的目标检测算法主要是基于深度学习模型,其可以分成两大类:two-stage检测算法:one-stage检测算法.本文主要介绍第一类检测算法,第二类在下一篇博文中介绍. 目标检测模型的主要性能指 ...

  4. CrawlSpider ---> 通用爬虫 项目流程

    通用爬虫 通用网络爬虫 从互联网中搜集网页,采集信息,这些网页信息用于为搜索引擎建立索引从而提供支持,它决定着整个引擎系统的内容是否丰富,信息是否即时,因此其性能的优劣直接影响着搜索引擎的效果. 不扯 ...

  5. python调用cv2.findContours时报错:ValueError: not enough values to unpack (expected 3, got 2)

    OpenCV旧版,返回三个参数: im2, contours, hierarchy = cv2.findContours(mask, cv2.RETR_TREE, cv2.CHAIN_APPROX_S ...

  6. Hibernate初探之单表映射——创建对象-关系映射文件

    编写一个Hibernate例子 第三步:创建对象-关系映射文件 以下是具体实现步骤: 找到我们要持久化的学生类Sudents 生成对象-关系映射文档Students.hbm.xml: <?xml ...

  7. Java集合--Iterator和Enumeration比较

    转载请注明出处:http://www.cnblogs.com/skywang12345/admin/EditPosts.aspx?postid=3311275 第1部分 Iterator和Enumer ...

  8. 存储过程:SET Transaction Isolation Level Read语法的四种情况

    这几天一直在弄存储过程,现在在这里跟大伙共享下资料: SET Transaction Isolation Level Read UNCOMMITTED 使用这句东东呢可以分为四种情况,现在就在这里逐一 ...

  9. [Google Guava] 8-区间

    原文链接 译文链接 译文:沈义扬 范例 1 List scores; 2 Iterable belowMedian =Iterables.filter(scores,Range.lessThan(me ...

  10. 23333 又是一篇水文章(以下是各种复制来的关于maven转成eclipse项目)

    (转载) 当我们通过模版(比如最简单的maven-archetype-quikstart插件)生成了一个maven的项目结构时,如何将它转换成eclipse支持的java project呢? 1. 定 ...