OpenStack中计算disk资源的方式(by quqi99)

版权声明:本文为博主原创文章,如需转载,请注明出处! https://blog.csdn.net/quqi99/article/details/80769725

版权声明:可以任意转载,转载时请务必以超链接形式标明文章原始出处和作者信息及本版权声明 (作者:张华 发表于:2018-06-22)

问题

https://review.openstack.org/#/c/536351/

不超载时

不使用disk_over_commit时将采用available_least, 它有可能为负数.
1, available_least is used for the case without disk_over_commit
get_available_resource in nova/virt/libvirt/driver.py will get ‘total’ and ‘used’ disk for local disk by statvfs
hddinfo = os.statvfs(path)
total = hddinfo.f_frsize * hddinfo.f_blocks
free = hddinfo.f_frsize * hddinfo.f_bavail
used = hddinfo.f_frsize * (hddinfo.f_blocks - hddinfo.f_bfree)
but nova doesn’t use above ‘free’ directly, it uses available_least instead
available_least = disk_free_gb * units.Gi - disk_over_committed
where disk_over_committed can be gotten by the following formula according to the output of ‘qemu-img info /var/lib/nova/instances/xxx/disk’
disk_over_committed = virtual_size - disk_size

2, When the case having disk_over_commit with disk_allocation_ratio (./nova/scheduler/filters/disk_filter.py):
disk_mb_limit = total_usable_disk_mb * disk_allocation_ratio
used_disk_mb = total_usable_disk_mb - free_disk_mb
disk_mb_limit - used_disk_mb < requested_disk
disk_available_mb = (disk_available_gb * units.Ki) - CONF.reserved_host_disk_mb)

超载时

超载时应该使用free_disk_gb - https://review.openstack.org/#/c/536351/
./nova/compute/resource_tracker.py
free_disk_gb = resources[‘local_gb’] - resources[‘local_gb_used’]
= disk_info[‘total’] - disk_info[‘used’] (libvirt/driver)
= statvfs: frsize*blocks - frsize*(blocks-bfree) (libvirt/utils)

阅读更多
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页