]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: move the XFS_IFEXTENTS check into xfs_iread_extents
authorChristoph Hellwig <hch@lst.de>
Wed, 30 Jun 2021 22:38:57 +0000 (18:38 -0400)
committerEric Sandeen <sandeen@sandeen.net>
Wed, 30 Jun 2021 22:38:57 +0000 (18:38 -0400)
Source kernel commit: 862a804aae3031e91bd0ae0b13c90a1b13d77af3

Move the XFS_IFEXTENTS check from the callers into xfs_iread_extents to
simplify the code.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
libxfs/xfs_bmap.c

index f6b4ab3798afe55a199bc79c08a226ed55da982b..c7452d356ae6026927547edb4e316c0163ee1f4d 100644 (file)
@@ -1220,6 +1220,9 @@ xfs_iread_extents(
        struct xfs_btree_cur    *cur;
        int                     error;
 
+       if (ifp->if_flags & XFS_IFEXTENTS)
+               return 0;
+
        ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));
 
        if (XFS_IS_CORRUPT(mp, ifp->if_format != XFS_DINODE_FMT_BTREE)) {
@@ -1277,11 +1280,9 @@ xfs_bmap_first_unused(
 
        ASSERT(xfs_ifork_has_extents(ifp));
 
-       if (!(ifp->if_flags & XFS_IFEXTENTS)) {
-               error = xfs_iread_extents(tp, ip, whichfork);
-               if (error)
-                       return error;
-       }
+       error = xfs_iread_extents(tp, ip, whichfork);
+       if (error)
+               return error;
 
        lowest = max = *first_unused;
        for_each_xfs_iext(ifp, &icur, &got) {
@@ -1329,11 +1330,9 @@ xfs_bmap_last_before(
                return -EFSCORRUPTED;
        }
 
-       if (!(ifp->if_flags & XFS_IFEXTENTS)) {
-               error = xfs_iread_extents(tp, ip, whichfork);
-               if (error)
-                       return error;
-       }
+       error = xfs_iread_extents(tp, ip, whichfork);
+       if (error)
+               return error;
 
        if (!xfs_iext_lookup_extent_before(ip, ifp, last_block, &icur, &got))
                *last_block = 0;
@@ -1352,11 +1351,9 @@ xfs_bmap_last_extent(
        struct xfs_iext_cursor  icur;
        int                     error;
 
-       if (!(ifp->if_flags & XFS_IFEXTENTS)) {
-               error = xfs_iread_extents(tp, ip, whichfork);
-               if (error)
-                       return error;
-       }
+       error = xfs_iread_extents(tp, ip, whichfork);
+       if (error)
+               return error;
 
        xfs_iext_last(ifp, &icur);
        if (!xfs_iext_get_extent(ifp, &icur, rec))
@@ -3984,11 +3981,9 @@ xfs_bmapi_read(
 
        XFS_STATS_INC(mp, xs_blk_mapr);
 
-       if (!(ifp->if_flags & XFS_IFEXTENTS)) {
-               error = xfs_iread_extents(NULL, ip, whichfork);
-               if (error)
-                       return error;
-       }
+       error = xfs_iread_extents(NULL, ip, whichfork);
+       if (error)
+               return error;
 
        if (!xfs_iext_lookup_extent(ip, ifp, bno, &icur, &got))
                eof = true;
@@ -4468,11 +4463,9 @@ xfs_bmapi_write(
 
        XFS_STATS_INC(mp, xs_blk_mapw);
 
-       if (!(ifp->if_flags & XFS_IFEXTENTS)) {
-               error = xfs_iread_extents(tp, ip, whichfork);
-               if (error)
-                       goto error0;
-       }
+       error = xfs_iread_extents(tp, ip, whichfork);
+       if (error)
+               goto error0;
 
        if (!xfs_iext_lookup_extent(ip, ifp, bno, &bma.icur, &bma.got))
                eof = true;
@@ -4751,11 +4744,9 @@ xfs_bmapi_remap(
        if (XFS_FORCED_SHUTDOWN(mp))
                return -EIO;
 
-       if (!(ifp->if_flags & XFS_IFEXTENTS)) {
-               error = xfs_iread_extents(tp, ip, whichfork);
-               if (error)
-                       return error;
-       }
+       error = xfs_iread_extents(tp, ip, whichfork);
+       if (error)
+               return error;
 
        if (xfs_iext_lookup_extent(ip, ifp, bno, &icur, &got)) {
                /* make sure we only reflink into a hole. */
@@ -5426,9 +5417,10 @@ __xfs_bunmapi(
        else
                max_len = len;
 
-       if (!(ifp->if_flags & XFS_IFEXTENTS) &&
-           (error = xfs_iread_extents(tp, ip, whichfork)))
+       error = xfs_iread_extents(tp, ip, whichfork);
+       if (error)
                return error;
+
        if (xfs_iext_count(ifp) == 0) {
                *rlen = 0;
                return 0;
@@ -5914,11 +5906,9 @@ xfs_bmap_collapse_extents(
 
        ASSERT(xfs_isilocked(ip, XFS_IOLOCK_EXCL | XFS_ILOCK_EXCL));
 
-       if (!(ifp->if_flags & XFS_IFEXTENTS)) {
-               error = xfs_iread_extents(tp, ip, whichfork);
-               if (error)
-                       return error;
-       }
+       error = xfs_iread_extents(tp, ip, whichfork);
+       if (error)
+               return error;
 
        if (ifp->if_flags & XFS_IFBROOT) {
                cur = xfs_bmbt_init_cursor(mp, tp, ip, whichfork);
@@ -6031,11 +6021,9 @@ xfs_bmap_insert_extents(
 
        ASSERT(xfs_isilocked(ip, XFS_IOLOCK_EXCL | XFS_ILOCK_EXCL));
 
-       if (!(ifp->if_flags & XFS_IFEXTENTS)) {
-               error = xfs_iread_extents(tp, ip, whichfork);
-               if (error)
-                       return error;
-       }
+       error = xfs_iread_extents(tp, ip, whichfork);
+       if (error)
+               return error;
 
        if (ifp->if_flags & XFS_IFBROOT) {
                cur = xfs_bmbt_init_cursor(mp, tp, ip, whichfork);
@@ -6134,12 +6122,10 @@ xfs_bmap_split_extent(
        if (XFS_FORCED_SHUTDOWN(mp))
                return -EIO;
 
-       if (!(ifp->if_flags & XFS_IFEXTENTS)) {
-               /* Read in all the extents */
-               error = xfs_iread_extents(tp, ip, whichfork);
-               if (error)
-                       return error;
-       }
+       /* Read in all the extents */
+       error = xfs_iread_extents(tp, ip, whichfork);
+       if (error)
+               return error;
 
        /*
         * If there are not extents, or split_fsb lies in a hole we are done.