Commit 865469cd authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Carlos Maiolino

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: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDarrick J. Wong <djwong@kernel.org>
Signed-off-by: default avatarCarlos Maiolino <cem@kernel.org>
parent b3f4e84e
...@@ -4177,18 +4177,28 @@ xfs_bmapi_reserve_delalloc( ...@@ -4177,18 +4177,28 @@ xfs_bmapi_reserve_delalloc(
} }
static int static int
xfs_bmap_alloc_userdata( xfs_bmapi_allocate(
struct xfs_bmalloca *bma) struct xfs_bmalloca *bma)
{ {
struct xfs_mount *mp = bma->ip->i_mount; struct xfs_mount *mp = bma->ip->i_mount;
int whichfork = xfs_bmapi_whichfork(bma->flags); int whichfork = xfs_bmapi_whichfork(bma->flags);
struct xfs_ifork *ifp = xfs_ifork_ptr(bma->ip, whichfork);
int error; int error;
ASSERT(bma->length > 0);
ASSERT(bma->length <= XFS_MAX_BMBT_EXTLEN);
if (bma->flags & XFS_BMAPI_CONTIG)
bma->minlen = bma->length;
else
bma->minlen = 1;
if (!(bma->flags & XFS_BMAPI_METADATA)) {
/* /*
* Set the data type being allocated. For the data fork, the first data * For the data and COW fork, the first data in the file is
* in the file is treated differently to all other allocations. For the * treated differently to all other allocations. For the
* attribute fork, we only need to ensure the allocated range is not on * attribute fork, we only need to ensure the allocated range
* the busy list. * is not on the busy list.
*/ */
bma->datatype = XFS_ALLOC_NOBUSY; bma->datatype = XFS_ALLOC_NOBUSY;
if (whichfork == XFS_DATA_FORK || whichfork == XFS_COW_FORK) { if (whichfork == XFS_DATA_FORK || whichfork == XFS_COW_FORK) {
...@@ -4201,44 +4211,17 @@ xfs_bmap_alloc_userdata( ...@@ -4201,44 +4211,17 @@ xfs_bmap_alloc_userdata(
if (error) if (error)
return error; return error;
} }
}
if (XFS_IS_REALTIME_INODE(bma->ip))
return xfs_bmap_rtalloc(bma);
} }
if (unlikely(XFS_TEST_ERROR(false, mp, if ((bma->datatype & XFS_ALLOC_USERDATA) &&
XFS_ERRTAG_BMAP_ALLOC_MINLEN_EXTENT))) XFS_IS_REALTIME_INODE(bma->ip))
return xfs_bmap_exact_minlen_extent_alloc(bma); error = xfs_bmap_rtalloc(bma);
else if (unlikely(XFS_TEST_ERROR(false, mp,
return xfs_bmap_btalloc(bma);
}
static int
xfs_bmapi_allocate(
struct xfs_bmalloca *bma)
{
struct xfs_mount *mp = bma->ip->i_mount;
int whichfork = xfs_bmapi_whichfork(bma->flags);
struct xfs_ifork *ifp = xfs_ifork_ptr(bma->ip, whichfork);
int error;
ASSERT(bma->length > 0);
ASSERT(bma->length <= XFS_MAX_BMBT_EXTLEN);
if (bma->flags & XFS_BMAPI_CONTIG)
bma->minlen = bma->length;
else
bma->minlen = 1;
if (bma->flags & XFS_BMAPI_METADATA) {
if (unlikely(XFS_TEST_ERROR(false, mp,
XFS_ERRTAG_BMAP_ALLOC_MINLEN_EXTENT))) XFS_ERRTAG_BMAP_ALLOC_MINLEN_EXTENT)))
error = xfs_bmap_exact_minlen_extent_alloc(bma); error = xfs_bmap_exact_minlen_extent_alloc(bma);
else else
error = xfs_bmap_btalloc(bma); error = xfs_bmap_btalloc(bma);
} else {
error = xfs_bmap_alloc_userdata(bma);
}
if (error) if (error)
return error; return error;
if (bma->blkno == NULLFSBLOCK) if (bma->blkno == NULLFSBLOCK)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment