• Dave Chinner's avatar
    xfs: collapse AG selection for inode allocation · 89b1f55a
    Dave Chinner authored
    xfs_dialloc_select_ag() does a lot of repetitive work. It first
    calls xfs_ialloc_ag_select() to select the AG to start allocation
    attempts in, which can do up to two entire loops across the perags
    that inodes can be allocated in. This is simply checking if there is
    spce available to allocate inodes in an AG, and it returns when it
    finds the first candidate AG.
    
    xfs_dialloc_select_ag() then does it's own iterative walk across
    all the perags locking the AGIs and trying to allocate inodes from
    the locked AG. It also doesn't limit the search to mp->m_maxagi,
    so it will walk all AGs whether they can allocate inodes or not.
    
    Hence if we are really low on inodes, we could do almost 3 entire
    walks across the whole perag range before we find an allocation
    group we can allocate inodes in or report ENOSPC.
    
    Because xfs_ialloc_ag_select() returns on the first candidate AG it
    finds, we can simply do these checks directly in
    xfs_dialloc_select_ag() before we lock and try to allocate inodes.
    This reduces the inode allocation pass down to 2 perag sweeps at
    most - one for aligned inode cluster allocation and if we can't
    allocate full, aligned inode clusters anywhere we'll do another pass
    trying to do sparse inode cluster allocation.
    
    This also removes a big chunk of duplicate code.
    Signed-off-by: default avatarDave Chinner <dchinner@redhat.com>
    Reviewed-by: default avatarDarrick J. Wong <djwong@kernel.org>
    89b1f55a
xfs_ialloc.c 77.6 KB