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 |
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
- reserved A (156781 * .2) = 31374
- available total A = 125407 * 2 = 250814
- available free A = (available total A - free) = 177291
OR
Reserve from max oversub total
max oversub total = 156871 * 2 = 313742
- reserved B (313742 * .2) = 62748
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
thick vs. thin calculations
thin