[PATCH 07/22] xfs_db: support the realtime refcountbt

Darrick J. Wong
2025-02-06T22:58:36Z

Wire up various parts of xfs_db for realtime refcount support so that we
can dump the rt refcount btree contents.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
---
db/btblock.c | 3 +++
db/btdump.c | 8 ++++++++
db/btheight.c | 5 +++++
libxfs/libxfs_api_defs.h | 1 +
man/man8/xfs_db.8 | 1 +
5 files changed, 18 insertions(+)

diff --git a/db/btblock.c b/db/btblock.c
index 40913a094375aa..e9e5d2f86b9f01 100644
--- a/db/btblock.c
+++ b/db/btblock.c
@@ -159,6 +159,9 @@ block_to_bt(
case TYP_REFCBT:
magic = crc ? XFS_REFC_CRC_MAGIC : 0;
break;
+ case TYP_RTREFCBT:
+ magic = crc ? XFS_RTREFC_CRC_MAGIC : 0;
+ break;
default:
ASSERT(0);
}
diff --git a/db/btdump.c b/db/btdump.c
index 55301d25de10cd..29ff28f1639977 100644
--- a/db/btdump.c
+++ b/db/btdump.c
@@ -456,6 +456,7 @@ dump_btree_inode(
char *prefix;
struct xfs_dinode *dip = iocur_top->data;
struct xfs_rtrmap_root *rtrmap;
+ struct xfs_rtrefcount_root *rtrefc;
int level;
int numrecs;
int ret;
@@ -467,6 +468,12 @@ dump_btree_inode(
level = be16_to_cpu(rtrmap->bb_level);
numrecs = be16_to_cpu(rtrmap->bb_numrecs);
break;
+ case XFS_METAFILE_RTREFCOUNT:
+ prefix = "u3.rtrefcbt";
+ rtrefc = (struct xfs_rtrefcount_root *)XFS_DFORK_DPTR(dip);
+ level = be16_to_cpu(rtrefc->bb_level);
+ numrecs = be16_to_cpu(rtrefc->bb_numrecs);
+ break;
default:
dbprintf("Unknown metadata inode btree type %u\n",
be16_to_cpu(dip->di_metatype));
@@ -549,6 +556,7 @@ btdump_f(
case TYP_BMAPBTA:
case TYP_BMAPBTD:
case TYP_RTRMAPBT:
+ case TYP_RTREFCBT:
return dump_btree_long(iflag);
case TYP_INODE:
if (is_btree_inode())
diff --git a/db/btheight.c b/db/btheight.c
index 31dff1c924a2e0..14081c969a922c 100644
--- a/db/btheight.c
+++ b/db/btheight.c
@@ -58,6 +58,11 @@ struct btmap {
.maxlevels = libxfs_rtrmapbt_maxlevels_ondisk,
.maxrecs = libxfs_rtrmapbt_maxrecs,
},
+ {
+ .tag = "rtrefcountbt",
+ .maxlevels = libxfs_rtrefcountbt_maxlevels_ondisk,
+ .maxrecs = libxfs_rtrefcountbt_maxrecs,
+ },
};

static void
diff --git a/libxfs/libxfs_api_defs.h b/libxfs/libxfs_api_defs.h
index 167df04df8fb1b..87a598f346f86a 100644
--- a/libxfs/libxfs_api_defs.h
+++ b/libxfs/libxfs_api_defs.h
@@ -321,6 +321,7 @@
#define xfs_rtgroup_put libxfs_rtgroup_put

#define xfs_rtrefcountbt_droot_maxrecs libxfs_rtrefcountbt_droot_maxrecs
+#define xfs_rtrefcountbt_maxlevels_ondisk libxfs_rtrefcountbt_maxlevels_ondisk
#define xfs_rtrefcountbt_maxrecs libxfs_rtrefcountbt_maxrecs

#define xfs_rtrmapbt_calc_reserves libxfs_rtrmapbt_calc_reserves
diff --git a/man/man8/xfs_db.8 b/man/man8/xfs_db.8
index 8326bddcef8378..08f38f37ca01cc 100644
--- a/man/man8/xfs_db.8
+++ b/man/man8/xfs_db.8
@@ -536,6 +536,7 @@ .SH COMMANDS
.IR bmapbt ,
.IR refcountbt ,
.IR rmapbt ,
+.IR rtrefcountbt ,
and
.IR rtrmapbt .
The magic value