From 1854150fccc486f0bff5d384f8ccb0c161fb4d05 Mon Sep 17 00:00:00 2001 From: Igor Fedotov Date: Thu, 16 Aug 2018 14:51:06 +0300 Subject: [PATCH] os/bluestore: fix assertion in StupidAllocator::get_fragmentation One might face an assertion (assert(intervals <= max_intervals)) in StupidAllocator::get_fragmentation method for clusters created by early Luminous releases and before. The root cause is that block volume size wasn't aligned with min_alloc_size and hence we missed that last fraction interval during max_interval calculation. Fixes: https://tracker.ceph.com/issues/43297 Note: This was a clean cherry-pick from master, but p2roundup was introduced since mimic release, use P2ROUNDUP instead Signed-off-by: Igor Fedotov (cherry picked from commit a60b2316ce0bed28c468043cff4cab5e61b1a694) Signed-off-by: Lei Liu --- src/os/bluestore/StupidAllocator.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/os/bluestore/StupidAllocator.cc b/src/os/bluestore/StupidAllocator.cc index 4ea171e859817..d174de471adf8 100644 --- a/src/os/bluestore/StupidAllocator.cc +++ b/src/os/bluestore/StupidAllocator.cc @@ -258,7 +258,7 @@ double StupidAllocator::get_fragmentation(uint64_t alloc_unit) uint64_t intervals = 0; { std::lock_guard l(lock); - max_intervals = num_free / alloc_unit; + max_intervals = P2ROUNDUP(num_free, alloc_unit) / alloc_unit; for (unsigned bin = 0; bin < free.size(); ++bin) { intervals += free[bin].num_intervals(); } -- 2.39.5