]> git.ipfire.org Git - people/ms/linux.git/commit - fs/xfs/libxfs/xfs_ialloc.c
xfs: stop searching for free slots in an inode chunk when there are none
authorCarlos Maiolino <cmaiolino@redhat.com>
Sat, 19 Aug 2017 01:07:04 +0000 (18:07 -0700)
committerDarrick J. Wong <darrick.wong@oracle.com>
Tue, 22 Aug 2017 16:22:24 +0000 (09:22 -0700)
commit2d32311cf19bfb8c1d2b4601974ddd951f9cfd0b
tree359b7501bd1f404ecc20229272ecc5d20f88ad87
parente67d3d4246e5fbb0c7c700426d11241ca9c6f473
xfs: stop searching for free slots in an inode chunk when there are none

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: Carlos Maiolino <cmaiolino@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
fs/xfs/libxfs/xfs_ialloc.c