]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: add a name field to struct xfs_btree_ops
authorChristoph Hellwig <hch@lst.de>
Mon, 22 Apr 2024 17:01:05 +0000 (10:01 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Mon, 3 Jun 2024 18:37:39 +0000 (11:37 -0700)
Source kernel commit: 77953b97bb19dc031673d055c811a5ba7df92307

The btnum in struct xfs_btree_ops is often used for printing a symbolic
name for the btree.  Add a name field to the ops structure and use that
directly.

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

index e7cbd0d9d41625795eb25d3055f62abdab962d4d..df25dc2a9d621e0a33d31ee56f16bef90d8502d8 100644 (file)
@@ -8,7 +8,7 @@
 
 #define trace_xfs_agfl_reset(a,b,c,d)          ((void) 0)
 #define trace_xfs_agfl_free_defer(a,b,c,d,e)   ((void) 0)
-#define trace_xfs_alloc_cur_check(a,b,c,d,e,f) ((void) 0)
+#define trace_xfs_alloc_cur_check(...)         ((void) 0)
 #define trace_xfs_alloc_cur(a)                 ((void) 0)
 #define trace_xfs_alloc_cur_left(a)            ((void) 0)
 #define trace_xfs_alloc_cur_lookup(a)          ((void) 0)
index 1fdd7d44cb1a117b611c394724e10adbe090333c..b7690dfde8cc78dafc7419a7d178f98adafcc19f 100644 (file)
@@ -269,9 +269,8 @@ xfs_alloc_complain_bad_rec(
        struct xfs_mount                *mp = cur->bc_mp;
 
        xfs_warn(mp,
-               "%s Freespace BTree record corruption in AG %d detected at %pS!",
-               cur->bc_btnum == XFS_BTNUM_BNO ? "Block" : "Size",
-               cur->bc_ag.pag->pag_agno, fa);
+               "%sbt record corruption in AG %d detected at %pS!",
+               cur->bc_ops->name, cur->bc_ag.pag->pag_agno, fa);
        xfs_warn(mp,
                "start block 0x%x block count 0x%x", irec->ar_startblock,
                irec->ar_blockcount);
@@ -992,8 +991,7 @@ xfs_alloc_cur_check(
 out:
        if (deactivate)
                cur->bc_flags &= ~XFS_BTREE_ALLOCBT_ACTIVE;
-       trace_xfs_alloc_cur_check(args->mp, cur->bc_btnum, bno, len, diff,
-                                 *new);
+       trace_xfs_alloc_cur_check(cur, bno, len, diff, *new);
        return 0;
 }
 
index dd9584269fc0e23fff002e03c81f09400ef8bc73..d9e9ba53a7c488355fdc2b4ce1b9ad3ce3c8055d 100644 (file)
@@ -466,6 +466,7 @@ xfs_allocbt_keys_contiguous(
 }
 
 const struct xfs_btree_ops xfs_bnobt_ops = {
+       .name                   = "bno",
        .type                   = XFS_BTREE_TYPE_AG,
 
        .rec_len                = sizeof(xfs_alloc_rec_t),
@@ -495,6 +496,7 @@ const struct xfs_btree_ops xfs_bnobt_ops = {
 };
 
 const struct xfs_btree_ops xfs_cntbt_ops = {
+       .name                   = "cnt",
        .type                   = XFS_BTREE_TYPE_AG,
        .geom_flags             = XFS_BTGEO_LASTREC_UPDATE,
 
index 828dfb7d4247e1f4f520d5363f377bb91b358daf..12b94c74ecb10120e85b4b2b1438c35f3a237882 100644 (file)
@@ -516,6 +516,7 @@ xfs_bmbt_keys_contiguous(
 }
 
 const struct xfs_btree_ops xfs_bmbt_ops = {
+       .name                   = "bmap",
        .type                   = XFS_BTREE_TYPE_INODE,
 
        .rec_len                = sizeof(xfs_bmbt_rec_t),
index 42a1ed78628488e6752c85a648f4738fa7650eb1..95f77fbe7111ef134df3e46224caf61e442c530d 100644 (file)
@@ -295,17 +295,17 @@ xfs_btree_check_ptr(
                                level))
                        return 0;
                xfs_err(cur->bc_mp,
-"Inode %llu fork %d: Corrupt btree %d pointer at level %d index %d.",
+"Inode %llu fork %d: Corrupt %sbt pointer at level %d index %d.",
                                cur->bc_ino.ip->i_ino,
-                               cur->bc_ino.whichfork, cur->bc_btnum,
+                               cur->bc_ino.whichfork, cur->bc_ops->name,
                                level, index);
        } else {
                if (xfs_btree_check_sptr(cur, be32_to_cpu((&ptr->s)[index]),
                                level))
                        return 0;
                xfs_err(cur->bc_mp,
-"AG %u: Corrupt btree %d pointer at level %d index %d.",
-                               cur->bc_ag.pag->pag_agno, cur->bc_btnum,
+"AG %u: Corrupt %sbt pointer at level %d index %d.",
+                               cur->bc_ag.pag->pag_agno, cur->bc_ops->name,
                                level, index);
        }
 
index 99194ae946948b26e6149e686741b2bba9aa7b3d..6bc6096205b3c8cc8bf892e0159315e1531a9323 100644 (file)
@@ -123,6 +123,8 @@ enum xfs_btree_type {
 };
 
 struct xfs_btree_ops {
+       const char              *name;
+
        /* Type of btree - AG-rooted or inode-rooted */
        enum xfs_btree_type     type;
 
index 21577a50f65588c785fb645058cc634392047d71..94f4f86902b58db80cd7692562b1ecf561f59ab5 100644 (file)
@@ -136,9 +136,8 @@ xfs_inobt_complain_bad_rec(
        struct xfs_mount                *mp = cur->bc_mp;
 
        xfs_warn(mp,
-               "%s Inode BTree record corruption in AG %d detected at %pS!",
-               cur->bc_btnum == XFS_BTNUM_INO ? "Used" : "Free",
-               cur->bc_ag.pag->pag_agno, fa);
+               "%sbt record corruption in AG %d detected at %pS!",
+               cur->bc_ops->name, cur->bc_ag.pag->pag_agno, fa);
        xfs_warn(mp,
 "start inode 0x%x, count 0x%x, free 0x%x freemask 0x%llx, holemask 0x%x",
                irec->ir_startino, irec->ir_count, irec->ir_freecount,
index 6a34de28293b463c5ea47757a5289c683cf4d271..5e8a475631839d3c7282d3b268f2dbc004c5f21d 100644 (file)
@@ -398,6 +398,7 @@ xfs_inobt_keys_contiguous(
 }
 
 const struct xfs_btree_ops xfs_inobt_ops = {
+       .name                   = "ino",
        .type                   = XFS_BTREE_TYPE_AG,
 
        .rec_len                = sizeof(xfs_inobt_rec_t),
@@ -426,6 +427,7 @@ const struct xfs_btree_ops xfs_inobt_ops = {
 };
 
 const struct xfs_btree_ops xfs_finobt_ops = {
+       .name                   = "fino",
        .type                   = XFS_BTREE_TYPE_AG,
 
        .rec_len                = sizeof(xfs_inobt_rec_t),
index 760163ca414e2e668dcab6f8d4ed52b603adff55..397ce2131933ba8ac02e06157b425dfff330f298 100644 (file)
@@ -317,6 +317,7 @@ xfs_refcountbt_keys_contiguous(
 }
 
 const struct xfs_btree_ops xfs_refcountbt_ops = {
+       .name                   = "refcount",
        .type                   = XFS_BTREE_TYPE_AG,
 
        .rec_len                = sizeof(struct xfs_refcount_rec),
index 82052ce78554e5bf8b03b5c195655b7cc8fb4b8f..5bf5340c89835f01619d95975a5c992d0a759caf 100644 (file)
@@ -470,6 +470,7 @@ xfs_rmapbt_keys_contiguous(
 }
 
 const struct xfs_btree_ops xfs_rmapbt_ops = {
+       .name                   = "rmap",
        .type                   = XFS_BTREE_TYPE_AG,
        .geom_flags             = XFS_BTGEO_OVERLAPPING,
 
index a1004fb3c8fb4878f0c592a6a8858b0e8dd82735..f577247b748d342070777c8c47c46861046a76fb 100644 (file)
@@ -125,15 +125,6 @@ typedef enum {
        XFS_BTNUM_INOi, XFS_BTNUM_FINOi, XFS_BTNUM_REFCi, XFS_BTNUM_MAX
 } xfs_btnum_t;
 
-#define XFS_BTNUM_STRINGS \
-       { XFS_BTNUM_BNOi,       "bnobt" }, \
-       { XFS_BTNUM_CNTi,       "cntbt" }, \
-       { XFS_BTNUM_RMAPi,      "rmapbt" }, \
-       { XFS_BTNUM_BMAPi,      "bmbt" }, \
-       { XFS_BTNUM_INOi,       "inobt" }, \
-       { XFS_BTNUM_FINOi,      "finobt" }, \
-       { XFS_BTNUM_REFCi,      "refcbt" }
-
 struct xfs_name {
        const unsigned char     *name;
        int                     len;