Quota: Fix precision mistakes for storage pressure.
There have been a number of reports about the storage pressure notification being shown, even when there is an absence of storage pressure. This is due to a numerical precision issue, where division of two ints would almost always return 0. This 0 meant that a condition that checked for storage pressure would always pass, and QuotaManger would fire storage pressure notifications for all write errors, regardless of disk availability. This change removes the division operation entirely with a little trick: - Given percent_available = 100 * available_space / total, - percent_available < kStoragePressureThresholdRatio is equivalent to (substitution): - 100 * available_space / total < kStoragePressureThresholdRatio is equivalent to (multiply both sides by total): - 100 * available_space < kStoragePressureThresholdRatio * total TBR=pwnall@chromium.org Bug: 1127237 Change-Id: I79c5ff47f27824d25ff8e47dc4aed859c8d3cd7d Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2412758Reviewed-by:Jarryd Goodman <jarrydg@chromium.org> Commit-Queue: Jarryd Goodman <jarrydg@chromium.org> Cr-Commit-Position: refs/heads/master@{#807356}
Showing
Please register or sign in to comment