]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: Fix fragmentation calculation
authorAdam Kupczyk <akupczyk@ibm.com>
Thu, 26 Jan 2023 09:58:42 +0000 (09:58 +0000)
committerAdam Kupczyk <akupczyk@ibm.com>
Thu, 26 Jan 2023 10:13:37 +0000 (10:13 +0000)
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 <akupczyk@ibm.com>
src/os/bluestore/Allocator.cc

index 3acdeacdfe76a8f605fa6f1827b4ed8cf3002cfa..3008f9ce8fdb4b509edcca8db9eda05fb3082241 100644 (file)
@@ -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);
 }