On Thu, Jul 24, 2014 at 10:23:01AM -0400, Brian Foster wrote:
> xfs_ialloc_ag_select() iterates through the allocation groups looking
> for free inodes or free space to determine whether to allow an inode
> allocation to proceed. If no free inodes are available, it assumes that
> an AG must have an extent longer than mp->m_ialloc_blks.
> Sparse inode chunk support currently allows for allocations as small as
> the cluster size. If sparse inodes are supported, use the cluster
> alignment as a minimum extent size limit to determine whether an inode
> chunk allocation attempt can proceed.
> Signed-off-by: Brian Foster <bfoster@xxxxxxxxxx>
> fs/xfs/libxfs/xfs_ialloc.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
> diff --git a/fs/xfs/libxfs/xfs_ialloc.c b/fs/xfs/libxfs/xfs_ialloc.c
> index 4dd45c2..4e98a21 100644
> --- a/fs/xfs/libxfs/xfs_ialloc.c
> +++ b/fs/xfs/libxfs/xfs_ialloc.c
> @@ -770,9 +770,15 @@ xfs_ialloc_ag_select(
> * Is there enough free space for the file plus a block of
> - * inodes? (if we need to allocate some)?
> + * inodes? (if we need to allocate some)? If sparse inode chunks
> + * are supported, we only require an extent of length equal to
> + * the cluster size.
> - ineed = mp->m_ialloc_blks;
> + if (xfs_sb_version_hassparseinodes(&mp->m_sb))
> + ineed = xfs_ialloc_cluster_alignment(mp);
> + else
> + ineed = mp->m_ialloc_blks;
Why wouldn't we calculate this once at mount time and dump it in
mp->m_ialloc_min_blks? And if we don't have sparse inodes enabled,
when would be ever select an AG that would trigger a sparse
allocation and then turn the feature bit on?