How Buddy Allocator Search in Filled Groups with Small Free Blocks Ranges

Let’s fill all disk, make gaps with free blocks and try to allocate large blocks ranges.

Create 4G filesystem same way as before:

For 4k block group size is 128mb. 31 group for 4G. Let’s create 240 files in every group. Then delete half of them. And try to allocate large file.

#!/bin/bash
OSTCOUNT=1 OSTSIZE=4194304 lustre/tests/llmount.sh


echo “1” > /sys/fs/ldiskfs/loop1/mb_stats


ls -l /mnt/lustre
#128mb group
#create 128 1M files in eatch of group
echo “Creating 110*31 files …”
for group in $(seq 31)
do
        _group=$(printf “%02d” $group);
        for nfile in $(seq 240)
        do
                _nfile=$(printf “%03d” $nfile)
                dd if=/dev/zero of=/mnt/lustre/foofile-$_group-$_nfile bs=524288 count=1 &> /dev/null
        done
done
echo “done”


echo “created files”
ls -l /mnt/lustre | wc -l


echo “Deleting half of files …”
for group in $(seq 31)
do
        _group=$(printf “%02d” $group);


        for nfile in $(seq 240)
        do
                _nfile=$(printf “%03d” $nfile)
                if [ “$(($nfile % 2))” -eq 0 ]
                then
                        #echo “Deleting $_group  $_nfile”
                        rm -f /mnt/lustre/foofile-$_group-$_nfile
                fi
        done
done


echo “files after deleting”
ls -l /mnt/lustre | wc -l
df | grep “/mnt/lustre”


dd if=/dev/zero of=/mnt/lustre/foofile bs=1048576 count=2000


lustre/tests/llmountcleanup.sh

Now we get expected result.

[ 5148.016557] LDISKFS-fs (loop1): mballoc: 1376278 blocks 9524 reqs (9007 success)
[ 5148.016560] LDISKFS-fs (loop1): mballoc: 282165 extents scanned, 745 goal hits, 1988 2^N hits, 1389 breaks, 0 lost
[ 5148.016562] LDISKFS-fs (loop1): mballoc: (511, 1405, 0) useless c(0,1,2) loops
[ 5148.016563] LDISKFS-fs (loop1): mballoc: 31 generated and it took 63044
[ 5148.016564] LDISKFS-fs (loop1): mballoc: 1066390 preallocated, 125 discarded

mballoc: (511, 1405, 0) useless c(0,1,2) loops – allocator iterates other block groups and can’t find requested large range.