Ext4 block allocator

Some ext4 block allocator internals

Ext4 makes some tries to get best blocks set to allocate data:

  • cr=0, try to allocate ^2 bytes

if (grp->bb_largest_free_order < ac->ac_2order)
                        return 0;

  • cr=1 average free range has required size

   if ((free / fragments) >= ac->ac_g_ex.fe_len)
                        return 1;
                break;

  • cr=2 Group has enough data

if (free >= ac->ac_g_ex.fe_len)
                        return 1;


  • cr=3 use any free data

return 1;

Allocator can start searching from start cr=0 if try to allocate ^2 blocks or cr=1

Leave a Reply

Your email address will not be published. Required fields are marked *