From: Adam Kupczyk Date: Thu, 26 Jan 2023 09:58:42 +0000 (+0000) Subject: os/bluestore: Fix fragmentation calculation X-Git-Tag: v19.0.0~1295^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b62ad2d807bc443cc44e530eb78f2e7cd04ec961;p=ceph.git os/bluestore: Fix fragmentation calculation The fragmentation score is evaluated as a proportion between score of ideal (all free in one fragment) and terrible (as fragmented as possible). The mistake is to behave as if free blocks of size 1 are possible, while in reality smallest block possible is min_alloc_size. Analysis of maximum fragmentation bias: https://docs.google.com/spreadsheets/d/16pfs-xoV6rhR3nHXmja-5iQ3pZW6AlSz_aZqi7_ZOFI/edit#gid=0 Partially fixes: https://tracker.ceph.com/issues/58022 Signed-off-by: Adam Kupczyk --- diff --git a/src/os/bluestore/Allocator.cc b/src/os/bluestore/Allocator.cc index 3acdeacdfe7..3008f9ce8fd 100644 --- a/src/os/bluestore/Allocator.cc +++ b/src/os/bluestore/Allocator.cc @@ -217,8 +217,7 @@ double Allocator::get_fragmentation_score() }; foreach(iterated_allocation); - double ideal = get_score(sum); - double terrible = sum * get_score(1); + double terrible = (sum / block_size) * get_score(block_size); return (ideal - score_sum) / (ideal - terrible); }