Created
February 22, 2022 19:09
-
-
Save hemna/b65b2617db7c1a0e94c8d66c1fb50e74 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Cinder has calculations in the capacity filter and the Capacity weigher for determining how much free space there is. | |
https://github.com/openstack/cinder/blob/master/cinder/scheduler/filters/capacity_filter.py#L108-L159 | |
and | |
https://github.com/openstack/cinder/blob/master/cinder/scheduler/weights/capacity.py#L118-L125 | |
These 2 mechanisms turn up to having different values. | |
Take my pool stats of | |
Total Capacity 156871 | |
Allocated Capacity 144553 | |
Free Capacity 104897 | |
Provisioning Type thin | |
Max Overcommit 1 | |
Reserved 20 % | |
Using the math in the capacity filter. Notice we are applying the reserved to the free space. | |
free = free_space - math.floor(total * reserved) | |
free = 104897 - (156871 * .2) | |
free = 104897 - 31374 | |
free = 73523 | |
Then apply the final calculation here: | |
https://github.com/openstack/cinder/blob/master/cinder/scheduler/filters/capacity_filter.py#L156-L157 | |
adjusted_free_virtual = (free * backend_state.max_over_subscription_ratio) | |
adjusted_free_virtual = (73523 * 1) | |
adjusted_free_virtual = 73523 | |
Now using the CapacityWeigher algorightm here: | |
https://github.com/openstack/cinder/blob/master/cinder/utils.py#L739-L742 | |
free = (total * max_over_subscription_ratio - provisioned_capacity - math.floor(total * reserved)) | |
free = (156871 * 1 - 144553 - (156871 * .2) | |
free = 156871 - 144553 - 31374 | |
free = -19056 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Using a max overcommit of 2 the numbers look different
Take my pool stats of
Total Capacity 156871
Allocated Capacity 144553
Free Capacity 104897
Provisioning Type thin
Max Overcommit 2
Reserved 20 %
Using the math in the capacity filter.
free = free_space - math.floor(total * reserved)
free = 104897 - (156871 * .2)
free = 104897 - 31374
free = 73523
adjusted_free_virtual = (free * backend_state.max_over_subscription_ratio)
adjusted_free_virtual = (73523 * 2)
adjusted_free_virtual = 147046
Reserve from raw total
OR
Reserve from max oversub total
max oversub total = 156871 * 2 = 313742
available total B = 250994
available free B = (available total B - free) = 177471
virtual free in cinder utils
free = (total * max_oversub_ratio - provisioned - (total * reserved)
free = 156871 * 2 - 144553 - (156781 * .2)
free = 313742 - 144553 - 31374
free = 137815