]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: set the btree cursor bc_ops in xfs_btree_alloc_cursor
authorDarrick J. Wong <djwong@kernel.org>
Mon, 22 Apr 2024 17:00:57 +0000 (10:00 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Mon, 3 Jun 2024 18:37:37 +0000 (11:37 -0700)
Source kernel commit: 056d22c87132cf4968f5e702116439bea9795930

This is a precursor to putting more static data in the btree ops structure.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
libxfs/xfs_alloc_btree.c
libxfs/xfs_bmap_btree.c
libxfs/xfs_btree.h
libxfs/xfs_ialloc_btree.c
libxfs/xfs_refcount_btree.c
libxfs/xfs_rmap_btree.c

index a472ec6d21a20748ec3f000a47ce96c394e70688..16f683e1dc84fd4079bfcdcf1eea4a862d124bde 100644 (file)
@@ -510,18 +510,17 @@ xfs_allocbt_init_common(
 
        ASSERT(btnum == XFS_BTNUM_BNO || btnum == XFS_BTNUM_CNT);
 
-       cur = xfs_btree_alloc_cursor(mp, tp, btnum, mp->m_alloc_maxlevels,
-                       xfs_allocbt_cur_cache);
-       cur->bc_ag.abt.active = false;
-
        if (btnum == XFS_BTNUM_CNT) {
-               cur->bc_ops = &xfs_cntbt_ops;
+               cur = xfs_btree_alloc_cursor(mp, tp, btnum, &xfs_cntbt_ops,
+                               mp->m_alloc_maxlevels, xfs_allocbt_cur_cache);
                cur->bc_statoff = XFS_STATS_CALC_INDEX(xs_abtc_2);
                cur->bc_flags = XFS_BTREE_LASTREC_UPDATE;
        } else {
-               cur->bc_ops = &xfs_bnobt_ops;
+               cur = xfs_btree_alloc_cursor(mp, tp, btnum, &xfs_bnobt_ops,
+                               mp->m_alloc_maxlevels, xfs_allocbt_cur_cache);
                cur->bc_statoff = XFS_STATS_CALC_INDEX(xs_abtb_2);
        }
+       cur->bc_ag.abt.active = false;
 
        cur->bc_ag.pag = xfs_perag_hold(pag);
 
index 887ba56f3b7b4b6aac7a4c68ddab1f9819da4ccd..751ae73c55cc5b1d79ab3a93a6bcfd872475386d 100644 (file)
@@ -548,11 +548,10 @@ xfs_bmbt_init_common(
 
        ASSERT(whichfork != XFS_COW_FORK);
 
-       cur = xfs_btree_alloc_cursor(mp, tp, XFS_BTNUM_BMAP,
+       cur = xfs_btree_alloc_cursor(mp, tp, XFS_BTNUM_BMAP, &xfs_bmbt_ops,
                        mp->m_bm_maxlevels[whichfork], xfs_bmbt_cur_cache);
        cur->bc_statoff = XFS_STATS_CALC_INDEX(xs_bmbt_2);
 
-       cur->bc_ops = &xfs_bmbt_ops;
        cur->bc_flags = XFS_BTREE_LONG_PTRS | XFS_BTREE_ROOT_IN_INODE;
        if (xfs_has_crc(mp))
                cur->bc_flags |= XFS_BTREE_CRC_BLOCKS;
index 75a0e2c8e115b32dba15465b1ec47fa052686d71..c053fb934dc70f87ab368011b570b8da7e28ca59 100644 (file)
@@ -720,6 +720,7 @@ xfs_btree_alloc_cursor(
        struct xfs_mount        *mp,
        struct xfs_trans        *tp,
        xfs_btnum_t             btnum,
+       const struct xfs_btree_ops *ops,
        uint8_t                 maxlevels,
        struct kmem_cache       *cache)
 {
@@ -728,6 +729,7 @@ xfs_btree_alloc_cursor(
        /* BMBT allocations can come through from non-transactional context. */
        cur = kmem_cache_zalloc(cache,
                        GFP_KERNEL | __GFP_NOLOCKDEP | __GFP_NOFAIL);
+       cur->bc_ops = ops;
        cur->bc_tp = tp;
        cur->bc_mp = mp;
        cur->bc_btnum = btnum;
index 593cb1fcc1d93a2a8f854b4190e2a6842b2d9ff4..5ea08cca25b433c78967070ca081b7fe1e5acf25 100644 (file)
@@ -453,14 +453,16 @@ xfs_inobt_init_common(
        struct xfs_mount        *mp = pag->pag_mount;
        struct xfs_btree_cur    *cur;
 
-       cur = xfs_btree_alloc_cursor(mp, tp, btnum,
-                       M_IGEO(mp)->inobt_maxlevels, xfs_inobt_cur_cache);
        if (btnum == XFS_BTNUM_INO) {
+               cur = xfs_btree_alloc_cursor(mp, tp, btnum, &xfs_inobt_ops,
+                               M_IGEO(mp)->inobt_maxlevels,
+                               xfs_inobt_cur_cache);
                cur->bc_statoff = XFS_STATS_CALC_INDEX(xs_ibt_2);
-               cur->bc_ops = &xfs_inobt_ops;
        } else {
+               cur = xfs_btree_alloc_cursor(mp, tp, btnum, &xfs_finobt_ops,
+                               M_IGEO(mp)->inobt_maxlevels,
+                               xfs_inobt_cur_cache);
                cur->bc_statoff = XFS_STATS_CALC_INDEX(xs_fibt_2);
-               cur->bc_ops = &xfs_finobt_ops;
        }
 
        if (xfs_has_crc(mp))
index 9a3c2270c254624c6b1915524996628bedcccab3..561b732b474603151b1e3be4bd43329075eaff4d 100644 (file)
@@ -352,7 +352,8 @@ xfs_refcountbt_init_common(
        ASSERT(pag->pag_agno < mp->m_sb.sb_agcount);
 
        cur = xfs_btree_alloc_cursor(mp, tp, XFS_BTNUM_REFC,
-                       mp->m_refc_maxlevels, xfs_refcountbt_cur_cache);
+                       &xfs_refcountbt_ops, mp->m_refc_maxlevels,
+                       xfs_refcountbt_cur_cache);
        cur->bc_statoff = XFS_STATS_CALC_INDEX(xs_refcbt_2);
 
        cur->bc_flags |= XFS_BTREE_CRC_BLOCKS;
@@ -360,7 +361,6 @@ xfs_refcountbt_init_common(
        cur->bc_ag.pag = xfs_perag_hold(pag);
        cur->bc_ag.refc.nr_ops = 0;
        cur->bc_ag.refc.shape_changes = 0;
-       cur->bc_ops = &xfs_refcountbt_ops;
        return cur;
 }
 
index e894a22e087c2bae33581e41a3d23561a47d4ab8..36231272964ba5e65f21d268646b2cd24cdfd43e 100644 (file)
@@ -501,11 +501,10 @@ xfs_rmapbt_init_common(
        struct xfs_btree_cur    *cur;
 
        /* Overlapping btree; 2 keys per pointer. */
-       cur = xfs_btree_alloc_cursor(mp, tp, XFS_BTNUM_RMAP,
+       cur = xfs_btree_alloc_cursor(mp, tp, XFS_BTNUM_RMAP, &xfs_rmapbt_ops,
                        mp->m_rmap_maxlevels, xfs_rmapbt_cur_cache);
        cur->bc_flags = XFS_BTREE_CRC_BLOCKS | XFS_BTREE_OVERLAPPING;
        cur->bc_statoff = XFS_STATS_CALC_INDEX(xs_rmap_2);
-       cur->bc_ops = &xfs_rmapbt_ops;
 
        cur->bc_ag.pag = xfs_perag_hold(pag);
        return cur;