]> git.apps.os.sepia.ceph.com Git - xfsprogs-dev.git/commitdiff
xfs: move lru refs to the btree ops structure
authorDarrick J. Wong <djwong@kernel.org>
Mon, 22 Apr 2024 17:00:59 +0000 (10:00 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Mon, 3 Jun 2024 18:37:37 +0000 (11:37 -0700)
Source kernel commit: 90cfae818dac5227e94e21d0f5250e098432723e

Move the btree buffer LRU refcount to the btree ops structure so that we
can eliminate the last bc_btnum switch in the generic btree code.  We're
about to create repair-specific btree types, and we don't want that
stuff cluttering up libxfs.

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.c
libxfs/xfs_btree.h
libxfs/xfs_ialloc_btree.c
libxfs/xfs_refcount_btree.c
libxfs/xfs_rmap_btree.c

index 6c9781fcf0d20f84fbc325bf1bd3220eae7b4f95..51c6703db6b1404264d071c61ceaa31ab4fea61b 100644 (file)
@@ -456,6 +456,8 @@ const struct xfs_btree_ops xfs_bnobt_ops = {
        .rec_len                = sizeof(xfs_alloc_rec_t),
        .key_len                = sizeof(xfs_alloc_key_t),
 
+       .lru_refs               = XFS_ALLOC_BTREE_REF,
+
        .dup_cursor             = xfs_allocbt_dup_cursor,
        .set_root               = xfs_allocbt_set_root,
        .alloc_block            = xfs_allocbt_alloc_block,
@@ -481,6 +483,8 @@ const struct xfs_btree_ops xfs_cntbt_ops = {
        .rec_len                = sizeof(xfs_alloc_rec_t),
        .key_len                = sizeof(xfs_alloc_key_t),
 
+       .lru_refs               = XFS_ALLOC_BTREE_REF,
+
        .dup_cursor             = xfs_allocbt_dup_cursor,
        .set_root               = xfs_allocbt_set_root,
        .alloc_block            = xfs_allocbt_alloc_block,
index 2d84118099d8fc9a604e05c6e2327ba141378281..966e793b08d2ea2f28d7a7ce6b444afc793563d1 100644 (file)
@@ -529,6 +529,8 @@ const struct xfs_btree_ops xfs_bmbt_ops = {
        .rec_len                = sizeof(xfs_bmbt_rec_t),
        .key_len                = sizeof(xfs_bmbt_key_t),
 
+       .lru_refs               = XFS_BMAP_BTREE_REF,
+
        .dup_cursor             = xfs_bmbt_dup_cursor,
        .update_cursor          = xfs_bmbt_update_cursor,
        .alloc_block            = xfs_bmbt_alloc_block,
index 95041d626c4c92f0c1f96232c63fc78d1c68c20a..150f8ac23d9d30a3ba585e77378711edfadde932 100644 (file)
@@ -1281,32 +1281,12 @@ xfs_btree_buf_to_ptr(
        }
 }
 
-STATIC void
+static inline void
 xfs_btree_set_refs(
        struct xfs_btree_cur    *cur,
        struct xfs_buf          *bp)
 {
-       switch (cur->bc_btnum) {
-       case XFS_BTNUM_BNO:
-       case XFS_BTNUM_CNT:
-               xfs_buf_set_ref(bp, XFS_ALLOC_BTREE_REF);
-               break;
-       case XFS_BTNUM_INO:
-       case XFS_BTNUM_FINO:
-               xfs_buf_set_ref(bp, XFS_INO_BTREE_REF);
-               break;
-       case XFS_BTNUM_BMAP:
-               xfs_buf_set_ref(bp, XFS_BMAP_BTREE_REF);
-               break;
-       case XFS_BTNUM_RMAP:
-               xfs_buf_set_ref(bp, XFS_RMAP_BTREE_REF);
-               break;
-       case XFS_BTNUM_REFC:
-               xfs_buf_set_ref(bp, XFS_REFC_BTREE_REF);
-               break;
-       default:
-               ASSERT(0);
-       }
+       xfs_buf_set_ref(bp, cur->bc_ops->lru_refs);
 }
 
 int
index 80be40ca89547c363bc8362970dc0a155b956b55..39df108a32ef4d78137183735a5d84a296b7741f 100644 (file)
@@ -120,6 +120,9 @@ struct xfs_btree_ops {
        size_t  key_len;
        size_t  rec_len;
 
+       /* LRU refcount to set on each btree buffer created */
+       unsigned int            lru_refs;
+
        /* cursor operations */
        struct xfs_btree_cur *(*dup_cursor)(struct xfs_btree_cur *);
        void    (*update_cursor)(struct xfs_btree_cur *src,
index 52cc00e4ff1cee0713da94fe2a0085b636e1b2d6..332d497eaf713649cbeda067dda83f9ece9a4de2 100644 (file)
@@ -401,6 +401,8 @@ const struct xfs_btree_ops xfs_inobt_ops = {
        .rec_len                = sizeof(xfs_inobt_rec_t),
        .key_len                = sizeof(xfs_inobt_key_t),
 
+       .lru_refs               = XFS_INO_BTREE_REF,
+
        .dup_cursor             = xfs_inobt_dup_cursor,
        .set_root               = xfs_inobt_set_root,
        .alloc_block            = xfs_inobt_alloc_block,
@@ -423,6 +425,8 @@ const struct xfs_btree_ops xfs_finobt_ops = {
        .rec_len                = sizeof(xfs_inobt_rec_t),
        .key_len                = sizeof(xfs_inobt_key_t),
 
+       .lru_refs               = XFS_INO_BTREE_REF,
+
        .dup_cursor             = xfs_inobt_dup_cursor,
        .set_root               = xfs_finobt_set_root,
        .alloc_block            = xfs_finobt_alloc_block,
index 2f91c7b62ef1a05bc429b634178176882ff160d4..1774b047726fde26cba03640cdb634196c6014dc 100644 (file)
@@ -320,6 +320,8 @@ const struct xfs_btree_ops xfs_refcountbt_ops = {
        .rec_len                = sizeof(struct xfs_refcount_rec),
        .key_len                = sizeof(struct xfs_refcount_key),
 
+       .lru_refs               = XFS_REFC_BTREE_REF,
+
        .dup_cursor             = xfs_refcountbt_dup_cursor,
        .set_root               = xfs_refcountbt_set_root,
        .alloc_block            = xfs_refcountbt_alloc_block,
index c3a113c881d81e9caa4e7be8a32c780b1a1bf572..6a7a9a176c6296e6ce88a404fce1470c2a955886 100644 (file)
@@ -476,6 +476,8 @@ const struct xfs_btree_ops xfs_rmapbt_ops = {
        .rec_len                = sizeof(struct xfs_rmap_rec),
        .key_len                = 2 * sizeof(struct xfs_rmap_key),
 
+       .lru_refs               = XFS_RMAP_BTREE_REF,
+
        .dup_cursor             = xfs_rmapbt_dup_cursor,
        .set_root               = xfs_rmapbt_set_root,
        .alloc_block            = xfs_rmapbt_alloc_block,