xfs: fold xfs_bmap_alloc_userdata into xfs_bmapi_allocate

Userdata and metadata allocations end up in the same allocation helpers.
Remove the separate xfs_bmap_alloc_userdata function to make this more
clear.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
This commit is contained in:
Christoph Hellwig 2024-09-18 07:30:07 +02:00 committed by Carlos Maiolino
parent b3f4e84e2f
commit 865469cd41

View File

@ -4176,43 +4176,6 @@ out:
return error; return error;
} }
static int
xfs_bmap_alloc_userdata(
struct xfs_bmalloca *bma)
{
struct xfs_mount *mp = bma->ip->i_mount;
int whichfork = xfs_bmapi_whichfork(bma->flags);
int error;
/*
* Set the data type being allocated. For the data fork, the first data
* in the file is treated differently to all other allocations. For the
* attribute fork, we only need to ensure the allocated range is not on
* the busy list.
*/
bma->datatype = XFS_ALLOC_NOBUSY;
if (whichfork == XFS_DATA_FORK || whichfork == XFS_COW_FORK) {
bma->datatype |= XFS_ALLOC_USERDATA;
if (bma->offset == 0)
bma->datatype |= XFS_ALLOC_INITIAL_USER_DATA;
if (mp->m_dalign && bma->length >= mp->m_dalign) {
error = xfs_bmap_isaeof(bma, whichfork);
if (error)
return error;
}
if (XFS_IS_REALTIME_INODE(bma->ip))
return xfs_bmap_rtalloc(bma);
}
if (unlikely(XFS_TEST_ERROR(false, mp,
XFS_ERRTAG_BMAP_ALLOC_MINLEN_EXTENT)))
return xfs_bmap_exact_minlen_extent_alloc(bma);
return xfs_bmap_btalloc(bma);
}
static int static int
xfs_bmapi_allocate( xfs_bmapi_allocate(
struct xfs_bmalloca *bma) struct xfs_bmalloca *bma)
@ -4230,15 +4193,35 @@ xfs_bmapi_allocate(
else else
bma->minlen = 1; bma->minlen = 1;
if (bma->flags & XFS_BMAPI_METADATA) { if (!(bma->flags & XFS_BMAPI_METADATA)) {
if (unlikely(XFS_TEST_ERROR(false, mp, /*
XFS_ERRTAG_BMAP_ALLOC_MINLEN_EXTENT))) * For the data and COW fork, the first data in the file is
error = xfs_bmap_exact_minlen_extent_alloc(bma); * treated differently to all other allocations. For the
else * attribute fork, we only need to ensure the allocated range
error = xfs_bmap_btalloc(bma); * is not on the busy list.
} else { */
error = xfs_bmap_alloc_userdata(bma); bma->datatype = XFS_ALLOC_NOBUSY;
if (whichfork == XFS_DATA_FORK || whichfork == XFS_COW_FORK) {
bma->datatype |= XFS_ALLOC_USERDATA;
if (bma->offset == 0)
bma->datatype |= XFS_ALLOC_INITIAL_USER_DATA;
if (mp->m_dalign && bma->length >= mp->m_dalign) {
error = xfs_bmap_isaeof(bma, whichfork);
if (error)
return error;
}
}
} }
if ((bma->datatype & XFS_ALLOC_USERDATA) &&
XFS_IS_REALTIME_INODE(bma->ip))
error = xfs_bmap_rtalloc(bma);
else if (unlikely(XFS_TEST_ERROR(false, mp,
XFS_ERRTAG_BMAP_ALLOC_MINLEN_EXTENT)))
error = xfs_bmap_exact_minlen_extent_alloc(bma);
else
error = xfs_bmap_btalloc(bma);
if (error) if (error)
return error; return error;
if (bma->blkno == NULLFSBLOCK) if (bma->blkno == NULLFSBLOCK)