]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
xfs: fold xfs_bmap_alloc_userdata into xfs_bmapi_allocate
authorChristoph Hellwig <hch@lst.de>
Wed, 18 Sep 2024 05:30:07 +0000 (07:30 +0200)
committerCarlos Maiolino <cem@kernel.org>
Mon, 7 Oct 2024 06:00:11 +0000 (08:00 +0200)
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>
fs/xfs/libxfs/xfs_bmap.c

index 8090e8249116d0b24d506b495455b996be555eac..d5a8403b469b9deef140e555b8043d3593719090 100644 (file)
@@ -4176,43 +4176,6 @@ out:
        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
 xfs_bmapi_allocate(
        struct xfs_bmalloca     *bma)
@@ -4230,15 +4193,35 @@ xfs_bmapi_allocate(
        else
                bma->minlen = 1;
 
-       if (bma->flags & XFS_BMAPI_METADATA) {
-               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 (!(bma->flags & XFS_BMAPI_METADATA)) {
+               /*
+                * 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) {
+                       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)
                return error;
        if (bma->blkno == NULLFSBLOCK)