]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: simplify usage of the rcur local variable in xfs_rmap_finish_one
authorChristoph Hellwig <hch@lst.de>
Wed, 2 Oct 2024 01:20:04 +0000 (18:20 -0700)
committerAndrey Albershteyn <aalbersh@redhat.com>
Fri, 4 Oct 2024 10:42:07 +0000 (12:42 +0200)
Source kernel commit: 905af72610d90f58f994feff4ead1fc258f5d2b1

Only update rcur when we know the final *pcur value.

Signed-off-by: Christoph Hellwig <hch@lst.de>
[djwong: don't leave the caller with a dangling ref]
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
libxfs/xfs_rmap.c

index 1b5004b9c88ece72c58a1bbb3ffb6fb410c1f2fc..d60edaa23638dd94814f513609937f685419e8d1 100644 (file)
@@ -2569,7 +2569,7 @@ xfs_rmap_finish_one(
 {
        struct xfs_owner_info           oinfo;
        struct xfs_mount                *mp = tp->t_mountp;
-       struct xfs_btree_cur            *rcur;
+       struct xfs_btree_cur            *rcur = *pcur;
        struct xfs_buf                  *agbp = NULL;
        xfs_agblock_t                   bno;
        bool                            unwritten;
@@ -2584,7 +2584,6 @@ xfs_rmap_finish_one(
         * If we haven't gotten a cursor or the cursor AG doesn't match
         * the startblock, get one now.
         */
-       rcur = *pcur;
        if (rcur != NULL && rcur->bc_ag.pag != ri->ri_pag) {
                xfs_btree_del_cursor(rcur, 0);
                rcur = NULL;
@@ -2606,9 +2605,8 @@ xfs_rmap_finish_one(
                        return -EFSCORRUPTED;
                }
 
-               rcur = xfs_rmapbt_init_cursor(mp, tp, agbp, ri->ri_pag);
+               *pcur = rcur = xfs_rmapbt_init_cursor(mp, tp, agbp, ri->ri_pag);
        }
-       *pcur = rcur;
 
        xfs_rmap_ino_owner(&oinfo, ri->ri_owner, ri->ri_whichfork,
                        ri->ri_bmap.br_startoff);