]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: record health problems with the metadata directory
authorDarrick J. Wong <djwong@kernel.org>
Mon, 25 Nov 2024 21:14:18 +0000 (13:14 -0800)
committerDarrick J. Wong <djwong@kernel.org>
Tue, 24 Dec 2024 02:01:25 +0000 (18:01 -0800)
Source kernel commit: be42fc1393d66024eb6415c92f45fab5d1878c3e

Make a report to the health monitoring subsystem any time we encounter
something in the metadata directory tree that looks like corruption.

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

index 499bea4ea8067fe3127378feb728bc60ced027be..b05e6fb1470351727934c9a506765f860d708ead 100644 (file)
@@ -198,6 +198,7 @@ struct xfs_fsop_geom {
 #define XFS_FSOP_GEOM_SICK_RT_SUMMARY  (1 << 5)  /* realtime summary */
 #define XFS_FSOP_GEOM_SICK_QUOTACHECK  (1 << 6)  /* quota counts */
 #define XFS_FSOP_GEOM_SICK_NLINKS      (1 << 7)  /* inode link counts */
+#define XFS_FSOP_GEOM_SICK_METADIR     (1 << 8)  /* metadata directory */
 
 /* Output for XFS_FS_COUNTS */
 typedef struct xfs_fsop_counts {
index 13301420a2f670fc0de657a1ef1d33a17bd00467..f90e8dfc0500002b3c5a6ed61962ff42630bb73d 100644 (file)
@@ -62,6 +62,7 @@ struct xfs_da_args;
 #define XFS_SICK_FS_PQUOTA     (1 << 3)  /* project quota */
 #define XFS_SICK_FS_QUOTACHECK (1 << 4)  /* quota counts */
 #define XFS_SICK_FS_NLINKS     (1 << 5)  /* inode link counts */
+#define XFS_SICK_FS_METADIR    (1 << 6)  /* metadata directory tree */
 
 /* Observable health issues for realtime volume metadata. */
 #define XFS_SICK_RT_BITMAP     (1 << 0)  /* realtime bitmap */
@@ -105,7 +106,8 @@ struct xfs_da_args;
                                 XFS_SICK_FS_GQUOTA | \
                                 XFS_SICK_FS_PQUOTA | \
                                 XFS_SICK_FS_QUOTACHECK | \
-                                XFS_SICK_FS_NLINKS)
+                                XFS_SICK_FS_NLINKS | \
+                                XFS_SICK_FS_METADIR)
 
 #define XFS_SICK_RT_PRIMARY    (XFS_SICK_RT_BITMAP | \
                                 XFS_SICK_RT_SUMMARY)
index b52abf12d20511b5af22274052b707aec6b36175..b5f05925e73a4e69536beb0ace12984fdbd1ed6e 100644 (file)
@@ -27,6 +27,7 @@
 #include "xfs_dir2.h"
 #include "xfs_dir2_priv.h"
 #include "xfs_parent.h"
+#include "xfs_health.h"
 
 /*
  * Metadata Directory Tree
@@ -93,8 +94,10 @@ xfs_metadir_lookup(
        };
        int                     error;
 
-       if (!S_ISDIR(VFS_I(dp)->i_mode))
+       if (!S_ISDIR(VFS_I(dp)->i_mode)) {
+               xfs_fs_mark_sick(mp, XFS_SICK_FS_METADIR);
                return -EFSCORRUPTED;
+       }
        if (xfs_is_shutdown(mp))
                return -EIO;
 
@@ -102,10 +105,14 @@ xfs_metadir_lookup(
        if (error)
                return error;
 
-       if (!xfs_verify_ino(mp, args.inumber))
+       if (!xfs_verify_ino(mp, args.inumber)) {
+               xfs_fs_mark_sick(mp, XFS_SICK_FS_METADIR);
                return -EFSCORRUPTED;
-       if (xname->type != XFS_DIR3_FT_UNKNOWN && xname->type != args.filetype)
+       }
+       if (xname->type != XFS_DIR3_FT_UNKNOWN && xname->type != args.filetype) {
+               xfs_fs_mark_sick(mp, XFS_SICK_FS_METADIR);
                return -EFSCORRUPTED;
+       }
 
        trace_xfs_metadir_lookup(dp, xname, args.inumber);
        *ino = args.inumber;