]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: standardize the btree maxrecs function parameters
authorDarrick J. Wong <djwong@kernel.org>
Mon, 21 Oct 2024 00:10:44 +0000 (17:10 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Thu, 31 Oct 2024 22:45:03 +0000 (15:45 -0700)
Source kernel commit: 411a71256de6f5a0015a28929cfbe6bc36c503dc

Standardize the parameters in xfs_{alloc,bm,ino,rmap,refcount}bt_maxrecs
so that we have consistent calling conventions.  This doesn't affect the
kernel that much, but enables us to clean up userspace a bit.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
16 files changed:
db/btheight.c
libxfs/xfs_alloc_btree.c
libxfs/xfs_alloc_btree.h
libxfs/xfs_bmap.c
libxfs/xfs_bmap_btree.c
libxfs/xfs_bmap_btree.h
libxfs/xfs_ialloc.c
libxfs/xfs_ialloc_btree.c
libxfs/xfs_ialloc_btree.h
libxfs/xfs_inode_fork.c
libxfs/xfs_refcount_btree.c
libxfs/xfs_refcount_btree.h
libxfs/xfs_rmap_btree.c
libxfs/xfs_rmap_btree.h
libxfs/xfs_sb.c
repair/phase5.c

index 0b421ab50a3a7610c34d996c43afc2ae5e284be9..6643489c82c4c9e264e94f6ccfbe8ab7a4ae61a0 100644 (file)
 #include "input.h"
 #include "libfrog/convert.h"
 
-static int refc_maxrecs(struct xfs_mount *mp, int blocklen, int leaf)
-{
-       return libxfs_refcountbt_maxrecs(blocklen, leaf != 0);
-}
-
-static int rmap_maxrecs(struct xfs_mount *mp, int blocklen, int leaf)
-{
-       return libxfs_rmapbt_maxrecs(blocklen, leaf);
-}
-
 struct btmap {
        const char      *tag;
        unsigned int    (*maxlevels)(void);
-       int             (*maxrecs)(struct xfs_mount *mp, int blocklen,
-                                  int leaf);
+       unsigned int    (*maxrecs)(struct xfs_mount *mp, unsigned int blocklen,
+                                  bool leaf);
 } maps[] = {
        {
                .tag            = "bnobt",
@@ -56,12 +46,12 @@ struct btmap {
        {
                .tag            = "refcountbt",
                .maxlevels      = libxfs_refcountbt_maxlevels_ondisk,
-               .maxrecs        = refc_maxrecs,
+               .maxrecs        = libxfs_refcountbt_maxrecs,
        },
        {
                .tag            = "rmapbt",
                .maxlevels      = libxfs_rmapbt_maxlevels_ondisk,
-               .maxrecs        = rmap_maxrecs,
+               .maxrecs        = libxfs_rmapbt_maxrecs,
        },
 };
 
index 9140dec00645f085e2982cbcb12a25622b8c45de..4a711f2463cd30a1c70029661dd7f0adb657bfff 100644 (file)
@@ -567,11 +567,11 @@ xfs_allocbt_block_maxrecs(
 /*
  * Calculate number of records in an alloc btree block.
  */
-int
+unsigned int
 xfs_allocbt_maxrecs(
        struct xfs_mount        *mp,
-       int                     blocklen,
-       int                     leaf)
+       unsigned int            blocklen,
+       bool                    leaf)
 {
        blocklen -= XFS_ALLOC_BLOCK_LEN(mp);
        return xfs_allocbt_block_maxrecs(blocklen, leaf);
index 155b47f231ab2f8de16f5e0cbf3919b0d4709791..12647f9aaa6d7937dfa0e0f4299e502c112a782c 100644 (file)
@@ -53,7 +53,8 @@ struct xfs_btree_cur *xfs_bnobt_init_cursor(struct xfs_mount *mp,
 struct xfs_btree_cur *xfs_cntbt_init_cursor(struct xfs_mount *mp,
                struct xfs_trans *tp, struct xfs_buf *bp,
                struct xfs_perag *pag);
-extern int xfs_allocbt_maxrecs(struct xfs_mount *, int, int);
+unsigned int xfs_allocbt_maxrecs(struct xfs_mount *mp, unsigned int blocklen,
+               bool leaf);
 extern xfs_extlen_t xfs_allocbt_calc_size(struct xfs_mount *mp,
                unsigned long long len);
 
index a85a75da954c4e58ff3b33950a488716b53221c7..4ee8d9b07a0ca7ab906e3decf9e06dfc3558ea94 100644 (file)
@@ -578,7 +578,7 @@ xfs_bmap_btree_to_extents(
        ASSERT(ifp->if_format == XFS_DINODE_FMT_BTREE);
        ASSERT(be16_to_cpu(rblock->bb_level) == 1);
        ASSERT(be16_to_cpu(rblock->bb_numrecs) == 1);
-       ASSERT(xfs_bmbt_maxrecs(mp, ifp->if_broot_bytes, 0) == 1);
+       ASSERT(xfs_bmbt_maxrecs(mp, ifp->if_broot_bytes, false) == 1);
 
        pp = xfs_bmap_broot_ptr_addr(mp, rblock, 1, ifp->if_broot_bytes);
        cbno = be64_to_cpu(*pp);
index cac644c8ce35a5d63379ce2e923a59a84b3a93f5..62e79d8fc49784e44f0eec27ef8a74f16470e1b3 100644 (file)
@@ -644,11 +644,11 @@ xfs_bmbt_commit_staged_btree(
 /*
  * Calculate number of records in a bmap btree block.
  */
-int
+unsigned int
 xfs_bmbt_maxrecs(
        struct xfs_mount        *mp,
-       int                     blocklen,
-       int                     leaf)
+       unsigned int            blocklen,
+       bool                    leaf)
 {
        blocklen -= xfs_bmbt_block_len(mp);
        return xfs_bmbt_block_maxrecs(blocklen, leaf);
index d006798d591bc21814b35dc080b5b8fe9c7479f4..49a3bae3f6ecec331b8f5936dad3b922ba2805d6 100644 (file)
@@ -35,7 +35,8 @@ extern void xfs_bmbt_to_bmdr(struct xfs_mount *, struct xfs_btree_block *, int,
 
 extern int xfs_bmbt_get_maxrecs(struct xfs_btree_cur *, int level);
 extern int xfs_bmdr_maxrecs(int blocklen, int leaf);
-extern int xfs_bmbt_maxrecs(struct xfs_mount *, int blocklen, int leaf);
+unsigned int xfs_bmbt_maxrecs(struct xfs_mount *mp, unsigned int blocklen,
+               bool leaf);
 
 extern int xfs_bmbt_change_owner(struct xfs_trans *tp, struct xfs_inode *ip,
                                 int whichfork, xfs_ino_t new_owner,
@@ -151,7 +152,7 @@ xfs_bmap_broot_ptr_addr(
        unsigned int            i,
        unsigned int            sz)
 {
-       return xfs_bmbt_ptr_addr(mp, bb, i, xfs_bmbt_maxrecs(mp, sz, 0));
+       return xfs_bmbt_ptr_addr(mp, bb, i, xfs_bmbt_maxrecs(mp, sz, false));
 }
 
 /*
index 83e3d7d7c5a1b3e9d1ed1511c0d76e1bfcb09dd5..141b2d397b1fe718375d88a4f46dbc6a508fabef 100644 (file)
@@ -2943,8 +2943,8 @@ xfs_ialloc_setup_geometry(
 
        /* Compute inode btree geometry. */
        igeo->agino_log = sbp->sb_inopblog + sbp->sb_agblklog;
-       igeo->inobt_mxr[0] = xfs_inobt_maxrecs(mp, sbp->sb_blocksize, 1);
-       igeo->inobt_mxr[1] = xfs_inobt_maxrecs(mp, sbp->sb_blocksize, 0);
+       igeo->inobt_mxr[0] = xfs_inobt_maxrecs(mp, sbp->sb_blocksize, true);
+       igeo->inobt_mxr[1] = xfs_inobt_maxrecs(mp, sbp->sb_blocksize, false);
        igeo->inobt_mnr[0] = igeo->inobt_mxr[0] / 2;
        igeo->inobt_mnr[1] = igeo->inobt_mxr[1] / 2;
 
index 489c080fb22d05c7acc40c377cd5405e8f51b5b7..ffca4a80219d6ddf50de488006574fde38de306a 100644 (file)
@@ -571,11 +571,11 @@ xfs_inobt_block_maxrecs(
 /*
  * Calculate number of records in an inobt btree block.
  */
-int
+unsigned int
 xfs_inobt_maxrecs(
        struct xfs_mount        *mp,
-       int                     blocklen,
-       int                     leaf)
+       unsigned int            blocklen,
+       bool                    leaf)
 {
        blocklen -= XFS_INOBT_BLOCK_LEN(mp);
        return xfs_inobt_block_maxrecs(blocklen, leaf);
index 6472ec1ecbb45839d23993ca9d13c9089e33e541..300edf5bc00949fe3d2e6ace63958c3ea88767fd 100644 (file)
@@ -50,7 +50,8 @@ struct xfs_btree_cur *xfs_inobt_init_cursor(struct xfs_perag *pag,
                struct xfs_trans *tp, struct xfs_buf *agbp);
 struct xfs_btree_cur *xfs_finobt_init_cursor(struct xfs_perag *pag,
                struct xfs_trans *tp, struct xfs_buf *agbp);
-extern int xfs_inobt_maxrecs(struct xfs_mount *, int, int);
+unsigned int xfs_inobt_maxrecs(struct xfs_mount *mp, unsigned int blocklen,
+               bool leaf);
 
 /* ir_holemask to inode allocation bitmap conversion */
 uint64_t xfs_inobt_irec_to_allocmask(const struct xfs_inobt_rec_incore *irec);
index fd79da64e43a8d91abd24b28a3790426edbcde6d..a71a5e98bf408bc6330793a8e6c74c33dc9769a4 100644 (file)
@@ -420,7 +420,7 @@ xfs_iroot_realloc(
                 * location.  The records don't change location because
                 * they are kept butted up against the btree block header.
                 */
-               cur_max = xfs_bmbt_maxrecs(mp, ifp->if_broot_bytes, 0);
+               cur_max = xfs_bmbt_maxrecs(mp, ifp->if_broot_bytes, false);
                new_max = cur_max + rec_diff;
                new_size = xfs_bmap_broot_space_calc(mp, new_max);
                ifp->if_broot = krealloc(ifp->if_broot, new_size,
@@ -442,7 +442,7 @@ xfs_iroot_realloc(
         * records, just get rid of the root and clear the status bit.
         */
        ASSERT((ifp->if_broot != NULL) && (ifp->if_broot_bytes > 0));
-       cur_max = xfs_bmbt_maxrecs(mp, ifp->if_broot_bytes, 0);
+       cur_max = xfs_bmbt_maxrecs(mp, ifp->if_broot_bytes, false);
        new_max = cur_max + rec_diff;
        ASSERT(new_max >= 0);
        if (new_max > 0)
index 162f9e6896a59035ddf3e827aa53b41e1a705c8c..9028dea06b0c071f7159f797f51e5c160b423152 100644 (file)
@@ -416,9 +416,10 @@ xfs_refcountbt_block_maxrecs(
 /*
  * Calculate the number of records in a refcount btree block.
  */
-int
+unsigned int
 xfs_refcountbt_maxrecs(
-       int                     blocklen,
+       struct xfs_mount        *mp,
+       unsigned int            blocklen,
        bool                    leaf)
 {
        blocklen -= XFS_REFCOUNT_BLOCK_LEN;
index 1e0ab25f6c68087882a7448959f9cb3f3bd8288e..beb93bef6a8141d3b842580fddf72f1f82046e83 100644 (file)
@@ -48,7 +48,8 @@ struct xbtree_afakeroot;
 extern struct xfs_btree_cur *xfs_refcountbt_init_cursor(struct xfs_mount *mp,
                struct xfs_trans *tp, struct xfs_buf *agbp,
                struct xfs_perag *pag);
-extern int xfs_refcountbt_maxrecs(int blocklen, bool leaf);
+unsigned int xfs_refcountbt_maxrecs(struct xfs_mount *mp, unsigned int blocklen,
+               bool leaf);
 extern void xfs_refcountbt_compute_maxlevels(struct xfs_mount *mp);
 
 extern xfs_extlen_t xfs_refcountbt_calc_size(struct xfs_mount *mp,
index f1732b72d13db1e11bce55ef23698464f0481c6d..ada58e92645020c1e11a9f6429214ce85f816772 100644 (file)
@@ -730,10 +730,11 @@ xfs_rmapbt_block_maxrecs(
 /*
  * Calculate number of records in an rmap btree block.
  */
-int
+unsigned int
 xfs_rmapbt_maxrecs(
-       int                     blocklen,
-       int                     leaf)
+       struct xfs_mount        *mp,
+       unsigned int            blocklen,
+       bool                    leaf)
 {
        blocklen -= XFS_RMAP_BLOCK_LEN;
        return xfs_rmapbt_block_maxrecs(blocklen, leaf);
index eb90d89e8086668047656d3009ea6bda74581437..119b1567cd0ee824e4b02403138868cfbe2fed5d 100644 (file)
@@ -47,7 +47,8 @@ struct xfs_btree_cur *xfs_rmapbt_init_cursor(struct xfs_mount *mp,
                                struct xfs_perag *pag);
 void xfs_rmapbt_commit_staged_btree(struct xfs_btree_cur *cur,
                struct xfs_trans *tp, struct xfs_buf *agbp);
-int xfs_rmapbt_maxrecs(int blocklen, int leaf);
+unsigned int xfs_rmapbt_maxrecs(struct xfs_mount *mp, unsigned int blocklen,
+               bool leaf);
 extern void xfs_rmapbt_compute_maxlevels(struct xfs_mount *mp);
 
 extern xfs_extlen_t xfs_rmapbt_calc_size(struct xfs_mount *mp,
index 5f7ff4fa4e49b10aa52cd2ba9410f8f5ff6f329b..0603e5087f2e46639972f96697d39fab03daca89 100644 (file)
@@ -997,23 +997,23 @@ xfs_sb_mount_common(
        mp->m_blockwmask = mp->m_blockwsize - 1;
        xfs_mount_sb_set_rextsize(mp, sbp);
 
-       mp->m_alloc_mxr[0] = xfs_allocbt_maxrecs(mp, sbp->sb_blocksize, 1);
-       mp->m_alloc_mxr[1] = xfs_allocbt_maxrecs(mp, sbp->sb_blocksize, 0);
+       mp->m_alloc_mxr[0] = xfs_allocbt_maxrecs(mp, sbp->sb_blocksize, true);
+       mp->m_alloc_mxr[1] = xfs_allocbt_maxrecs(mp, sbp->sb_blocksize, false);
        mp->m_alloc_mnr[0] = mp->m_alloc_mxr[0] / 2;
        mp->m_alloc_mnr[1] = mp->m_alloc_mxr[1] / 2;
 
-       mp->m_bmap_dmxr[0] = xfs_bmbt_maxrecs(mp, sbp->sb_blocksize, 1);
-       mp->m_bmap_dmxr[1] = xfs_bmbt_maxrecs(mp, sbp->sb_blocksize, 0);
+       mp->m_bmap_dmxr[0] = xfs_bmbt_maxrecs(mp, sbp->sb_blocksize, true);
+       mp->m_bmap_dmxr[1] = xfs_bmbt_maxrecs(mp, sbp->sb_blocksize, false);
        mp->m_bmap_dmnr[0] = mp->m_bmap_dmxr[0] / 2;
        mp->m_bmap_dmnr[1] = mp->m_bmap_dmxr[1] / 2;
 
-       mp->m_rmap_mxr[0] = xfs_rmapbt_maxrecs(sbp->sb_blocksize, 1);
-       mp->m_rmap_mxr[1] = xfs_rmapbt_maxrecs(sbp->sb_blocksize, 0);
+       mp->m_rmap_mxr[0] = xfs_rmapbt_maxrecs(mp, sbp->sb_blocksize, true);
+       mp->m_rmap_mxr[1] = xfs_rmapbt_maxrecs(mp, sbp->sb_blocksize, false);
        mp->m_rmap_mnr[0] = mp->m_rmap_mxr[0] / 2;
        mp->m_rmap_mnr[1] = mp->m_rmap_mxr[1] / 2;
 
-       mp->m_refc_mxr[0] = xfs_refcountbt_maxrecs(sbp->sb_blocksize, true);
-       mp->m_refc_mxr[1] = xfs_refcountbt_maxrecs(sbp->sb_blocksize, false);
+       mp->m_refc_mxr[0] = xfs_refcountbt_maxrecs(mp, sbp->sb_blocksize, true);
+       mp->m_refc_mxr[1] = xfs_refcountbt_maxrecs(mp, sbp->sb_blocksize, false);
        mp->m_refc_mnr[0] = mp->m_refc_mxr[0] / 2;
        mp->m_refc_mnr[1] = mp->m_refc_mxr[1] / 2;
 
index 52666ad882331237a64c5f148711e2c576614474..d18ec095b0524ba24467656e0176e87630b74772 100644 (file)
@@ -641,21 +641,21 @@ phase5(xfs_mount_t *mp)
 
 #ifdef XR_BLD_FREE_TRACE
        fprintf(stderr, "inobt level 1, maxrec = %d, minrec = %d\n",
-               libxfs_inobt_maxrecs(mp, mp->m_sb.sb_blocksize, 0),
-               libxfs_inobt_maxrecs(mp, mp->m_sb.sb_blocksize, 0) / 2);
+               libxfs_inobt_maxrecs(mp, mp->m_sb.sb_blocksize, false),
+               libxfs_inobt_maxrecs(mp, mp->m_sb.sb_blocksize, false) / 2);
        fprintf(stderr, "inobt level 0 (leaf), maxrec = %d, minrec = %d\n",
-               libxfs_inobt_maxrecs(mp, mp->m_sb.sb_blocksize, 1),
-               libxfs_inobt_maxrecs(mp, mp->m_sb.sb_blocksize, 1) / 2);
+               libxfs_inobt_maxrecs(mp, mp->m_sb.sb_blocksize, true),
+               libxfs_inobt_maxrecs(mp, mp->m_sb.sb_blocksize, true) / 2);
        fprintf(stderr, "xr inobt level 0 (leaf), maxrec = %d\n",
                XR_INOBT_BLOCK_MAXRECS(mp, 0));
        fprintf(stderr, "xr inobt level 1 (int), maxrec = %d\n",
                XR_INOBT_BLOCK_MAXRECS(mp, 1));
        fprintf(stderr, "bnobt level 1, maxrec = %d, minrec = %d\n",
-               libxfs_allocbt_maxrecs(mp, mp->m_sb.sb_blocksize, 0),
-               libxfs_allocbt_maxrecs(mp, mp->m_sb.sb_blocksize, 0) / 2);
+               libxfs_allocbt_maxrecs(mp, mp->m_sb.sb_blocksize, false),
+               libxfs_allocbt_maxrecs(mp, mp->m_sb.sb_blocksize, false) / 2);
        fprintf(stderr, "bnobt level 0 (leaf), maxrec = %d, minrec = %d\n",
-               libxfs_allocbt_maxrecs(mp, mp->m_sb.sb_blocksize, 1),
-               libxfs_allocbt_maxrecs(mp, mp->m_sb.sb_blocksize, 1) / 2);
+               libxfs_allocbt_maxrecs(mp, mp->m_sb.sb_blocksize, true),
+               libxfs_allocbt_maxrecs(mp, mp->m_sb.sb_blocksize, true) / 2);
 #endif
        /*
         * make sure the root and realtime inodes show up allocated