]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: pretty print metadata file types in error messages
authorDarrick J. Wong <djwong@kernel.org>
Mon, 24 Feb 2025 18:21:48 +0000 (10:21 -0800)
committerDarrick J. Wong <djwong@kernel.org>
Tue, 25 Feb 2025 17:15:58 +0000 (09:15 -0800)
Source kernel commit: 219ee99d3673ded7abbc13ddd4d7847e92661e2c

Create a helper function to turn a metadata file type code into a
printable string, and use this to complain about lockdep problems with
rtgroup inodes.  We'll use this more in the next patch.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
libxfs/xfs_metafile.c
libxfs/xfs_metafile.h
libxfs/xfs_rtgroup.c

index 7f673d706aada88bc672da3b43e74c3716135ce1..4488e38a87345a23806247718bf6726fb9e452f7 100644 (file)
 #include "xfs_errortag.h"
 #include "xfs_alloc.h"
 
+static const struct {
+       enum xfs_metafile_type  mtype;
+       const char              *name;
+} xfs_metafile_type_strs[] = { XFS_METAFILE_TYPE_STR };
+
+const char *
+xfs_metafile_type_str(enum xfs_metafile_type metatype)
+{
+       unsigned int    i;
+
+       for (i = 0; i < ARRAY_SIZE(xfs_metafile_type_strs); i++) {
+               if (xfs_metafile_type_strs[i].mtype == metatype)
+                       return xfs_metafile_type_strs[i].name;
+       }
+
+       return NULL;
+}
+
 /* Set up an inode to be recognized as a metadata directory inode. */
 void
 xfs_metafile_set_iflag(
index 8d8f08a6071c2333176efa853734263bbabbbab9..95af4b52e5a75f8f2b6c228141e53f21f91cf4e2 100644 (file)
@@ -6,6 +6,8 @@
 #ifndef __XFS_METAFILE_H__
 #define __XFS_METAFILE_H__
 
+const char *xfs_metafile_type_str(enum xfs_metafile_type metatype);
+
 /* All metadata files must have these flags set. */
 #define XFS_METAFILE_DIFLAGS   (XFS_DIFLAG_IMMUTABLE | \
                                 XFS_DIFLAG_SYNC | \
index e422a7bc41a55e3c1c513647c31b147d5ea2ddbd..b9da90c5062dc107838e058c2335e19b242dce27 100644 (file)
@@ -279,7 +279,8 @@ xfs_rtginode_ilock_print_fn(
        const struct xfs_inode *ip =
                container_of(m, struct xfs_inode, i_lock.dep_map);
 
-       printk(KERN_CONT " rgno=%u", ip->i_projid);
+       printk(KERN_CONT " rgno=%u metatype=%s", ip->i_projid,
+                       xfs_metafile_type_str(ip->i_metatype));
 }
 
 /*