Skip to content

Commit 865469c

Browse files
Christoph Hellwigcmaiolino
authored andcommitted
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 <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Signed-off-by: Carlos Maiolino <[email protected]>
1 parent b3f4e84 commit 865469c

File tree

1 file changed

+28
-45
lines changed

1 file changed

+28
-45
lines changed

fs/xfs/libxfs/xfs_bmap.c

Lines changed: 28 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -4176,43 +4176,6 @@ xfs_bmapi_reserve_delalloc(
41764176
return error;
41774177
}
41784178

4179-
static int
4180-
xfs_bmap_alloc_userdata(
4181-
struct xfs_bmalloca *bma)
4182-
{
4183-
struct xfs_mount *mp = bma->ip->i_mount;
4184-
int whichfork = xfs_bmapi_whichfork(bma->flags);
4185-
int error;
4186-
4187-
/*
4188-
* Set the data type being allocated. For the data fork, the first data
4189-
* in the file is treated differently to all other allocations. For the
4190-
* attribute fork, we only need to ensure the allocated range is not on
4191-
* the busy list.
4192-
*/
4193-
bma->datatype = XFS_ALLOC_NOBUSY;
4194-
if (whichfork == XFS_DATA_FORK || whichfork == XFS_COW_FORK) {
4195-
bma->datatype |= XFS_ALLOC_USERDATA;
4196-
if (bma->offset == 0)
4197-
bma->datatype |= XFS_ALLOC_INITIAL_USER_DATA;
4198-
4199-
if (mp->m_dalign && bma->length >= mp->m_dalign) {
4200-
error = xfs_bmap_isaeof(bma, whichfork);
4201-
if (error)
4202-
return error;
4203-
}
4204-
4205-
if (XFS_IS_REALTIME_INODE(bma->ip))
4206-
return xfs_bmap_rtalloc(bma);
4207-
}
4208-
4209-
if (unlikely(XFS_TEST_ERROR(false, mp,
4210-
XFS_ERRTAG_BMAP_ALLOC_MINLEN_EXTENT)))
4211-
return xfs_bmap_exact_minlen_extent_alloc(bma);
4212-
4213-
return xfs_bmap_btalloc(bma);
4214-
}
4215-
42164179
static int
42174180
xfs_bmapi_allocate(
42184181
struct xfs_bmalloca *bma)
@@ -4230,15 +4193,35 @@ xfs_bmapi_allocate(
42304193
else
42314194
bma->minlen = 1;
42324195

4233-
if (bma->flags & XFS_BMAPI_METADATA) {
4234-
if (unlikely(XFS_TEST_ERROR(false, mp,
4235-
XFS_ERRTAG_BMAP_ALLOC_MINLEN_EXTENT)))
4236-
error = xfs_bmap_exact_minlen_extent_alloc(bma);
4237-
else
4238-
error = xfs_bmap_btalloc(bma);
4239-
} else {
4240-
error = xfs_bmap_alloc_userdata(bma);
4196+
if (!(bma->flags & XFS_BMAPI_METADATA)) {
4197+
/*
4198+
* For the data and COW fork, the first data in the file is
4199+
* treated differently to all other allocations. For the
4200+
* attribute fork, we only need to ensure the allocated range
4201+
* is not on the busy list.
4202+
*/
4203+
bma->datatype = XFS_ALLOC_NOBUSY;
4204+
if (whichfork == XFS_DATA_FORK || whichfork == XFS_COW_FORK) {
4205+
bma->datatype |= XFS_ALLOC_USERDATA;
4206+
if (bma->offset == 0)
4207+
bma->datatype |= XFS_ALLOC_INITIAL_USER_DATA;
4208+
4209+
if (mp->m_dalign && bma->length >= mp->m_dalign) {
4210+
error = xfs_bmap_isaeof(bma, whichfork);
4211+
if (error)
4212+
return error;
4213+
}
4214+
}
42414215
}
4216+
4217+
if ((bma->datatype & XFS_ALLOC_USERDATA) &&
4218+
XFS_IS_REALTIME_INODE(bma->ip))
4219+
error = xfs_bmap_rtalloc(bma);
4220+
else if (unlikely(XFS_TEST_ERROR(false, mp,
4221+
XFS_ERRTAG_BMAP_ALLOC_MINLEN_EXTENT)))
4222+
error = xfs_bmap_exact_minlen_extent_alloc(bma);
4223+
else
4224+
error = xfs_bmap_btalloc(bma);
42424225
if (error)
42434226
return error;
42444227
if (bma->blkno == NULLFSBLOCK)

0 commit comments

Comments
 (0)