xfs_db: show the metadata root directory when dumping superblocks
authorDarrick J. Wong <djwong@kernel.org>
Wed, 3 Jul 2024 21:21:51 +0000 (14:21 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Tue, 30 Jul 2024 00:13:17 +0000 (17:13 -0700)
Show the metadirino field when appropriate.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
db/sb.c

diff --git a/db/sb.c b/db/sb.c
index 4f115650e1283f07c9395d2a566fa32132b4cb9b..01d5caeb60c432cbba90b4698a350d030c03e983 100644 (file)
--- a/db/sb.c
+++ b/db/sb.c
@@ -50,6 +50,18 @@ sb_init(void)
        add_command(&version_cmd);
 }
 
+/*
+ * Counts superblock fields that only exist when the metadata directory feature
+ * is enabled.
+ */
+static int
+metadirino_count(
+       void            *obj,
+       int             startoff)
+{
+       return xfs_has_metadir(mp) ? 1 : 0;
+}
+
 #define        OFF(f)  bitize(offsetof(struct xfs_dsb, sb_ ## f))
 #define        SZC(f)  szcount(struct xfs_dsb, sb_ ## f)
 const field_t  sb_flds[] = {
@@ -113,6 +125,8 @@ const field_t       sb_flds[] = {
        { "pquotino", FLDT_INO, OI(OFF(pquotino)), C1, 0, TYP_INODE },
        { "lsn", FLDT_UINT64X, OI(OFF(lsn)), C1, 0, TYP_NONE },
        { "meta_uuid", FLDT_UUID, OI(OFF(meta_uuid)), C1, 0, TYP_NONE },
+       { "metadirino", FLDT_INO, OI(OFF(metadirino)), metadirino_count,
+         FLD_COUNT, TYP_INODE },
        { NULL }
 };