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

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
Loading
Loading
Loading
Loading
+28 −45
Original line number Diff line number Diff line
@@ -4177,18 +4177,28 @@ xfs_bmapi_reserve_delalloc(
}

static int
xfs_bmap_alloc_userdata(
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)) {
		/*
	 * 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.
		 * For the data and COW 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) {
@@ -4201,44 +4211,17 @@ xfs_bmap_alloc_userdata(
				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
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,
	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);
	} else {
		error = xfs_bmap_alloc_userdata(bma);
	}
	if (error)
		return error;
	if (bma->blkno == NULLFSBLOCK)