• C
    xfs: stop searching for free slots in an inode chunk when there are none · 2d32311c
    Carlos Maiolino 提交于
    In a filesystem without finobt, the Space manager selects an AG to alloc a new
    inode, where xfs_dialloc_ag_inobt() will search the AG for the free slot chunk.
    
    When the new inode is in the same AG as its parent, the btree will be searched
    starting on the parent's record, and then retried from the top if no slot is
    available beyond the parent's record.
    
    To exit this loop though, xfs_dialloc_ag_inobt() relies on the fact that the
    btree must have a free slot available, once its callers relied on the
    agi->freecount when deciding how/where to allocate this new inode.
    
    In the case when the agi->freecount is corrupted, showing available inodes in an
    AG, when in fact there is none, this becomes an infinite loop.
    
    Add a way to stop the loop when a free slot is not found in the btree, making
    the function to fall into the whole AG scan which will then, be able to detect
    the corruption and shut the filesystem down.
    
    As pointed by Brian, this might impact performance, giving the fact we
    don't reset the search distance anymore when we reach the end of the
    tree, giving it fewer tries before falling back to the whole AG search, but
    it will only affect searches that start within 10 records to the end of the tree.
    Signed-off-by: NCarlos Maiolino <cmaiolino@redhat.com>
    Reviewed-by: NDarrick J. Wong <darrick.wong@oracle.com>
    Signed-off-by: NDarrick J. Wong <darrick.wong@oracle.com>
    2d32311c
xfs_ialloc.c 72.2 KB