]> www.infradead.org Git - users/hch/xfs.git/commitdiff
xfs: report realtime rmap btree corruption errors to the health system
authorDarrick J. Wong <djwong@kernel.org>
Mon, 23 Sep 2024 20:42:06 +0000 (13:42 -0700)
committerChristoph Hellwig <hch@lst.de>
Wed, 9 Oct 2024 13:55:46 +0000 (15:55 +0200)
Whenever we encounter corrupt realtime rmap btree blocks, we should
report that to the health monitoring system for later reporting.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
fs/xfs/libxfs/xfs_btree.h
fs/xfs/libxfs/xfs_fs.h
fs/xfs/libxfs/xfs_health.h
fs/xfs/libxfs/xfs_inode_fork.c
fs/xfs/libxfs/xfs_rtgroup.c
fs/xfs/libxfs/xfs_rtrmap_btree.c
fs/xfs/xfs_health.c

index 1454d8b41eaad0184db80f2628bbf14663269626..99624cd8bab933510c6b0ca5e1564c5131e028b6 100644 (file)
@@ -135,7 +135,7 @@ struct xfs_btree_ops {
        /* offset of btree stats array */
        unsigned int            statoff;
 
-       /* sick mask for health reporting (only for XFS_BTREE_TYPE_AG) */
+       /* sick mask for health reporting (not for bmap btrees) */
        unsigned int            sick_mask;
 
        /* cursor operations */
index 32f8af6d4b1fa45ef8bd853cc6c9f8751134077a..8a1ee2bfdbbf0a118fa9f05141afacd5b642b02f 100644 (file)
@@ -995,6 +995,7 @@ struct xfs_rtgroup_geometry {
 #define XFS_RTGROUP_GEOM_SICK_SUPER    (1U << 0)  /* superblock */
 #define XFS_RTGROUP_GEOM_SICK_BITMAP   (1U << 1)  /* rtbitmap */
 #define XFS_RTGROUP_GEOM_SICK_SUMMARY  (1U << 2)  /* rtsummary */
+#define XFS_RTGROUP_GEOM_SICK_RMAPBT   (1U << 3)  /* reverse mappings */
 
 /*
  * ioctl commands that are used by Linux filesystems
index 89b24df5ed806e6155703027e93a02cf73c41814..74b3737ca3f2d112fdbf2c0d25ffb26883947ea6 100644 (file)
@@ -70,6 +70,7 @@ struct xfs_rtgroup;
 #define XFS_SICK_RG_SUPER      (1 << 0)  /* rt group superblock */
 #define XFS_SICK_RG_BITMAP     (1 << 1)  /* rt group bitmap */
 #define XFS_SICK_RG_SUMMARY    (1 << 2)  /* rt groups summary */
+#define XFS_SICK_RG_RMAPBT     (1 << 3)  /* reverse mappings */
 
 /* Observable health issues for AG metadata. */
 #define XFS_SICK_AG_SB         (1 << 0)  /* superblock */
@@ -115,7 +116,8 @@ struct xfs_rtgroup;
 
 #define XFS_SICK_RG_PRIMARY    (XFS_SICK_RG_SUPER | \
                                 XFS_SICK_RG_BITMAP | \
-                                XFS_SICK_RG_SUMMARY)
+                                XFS_SICK_RG_SUMMARY | \
+                                XFS_SICK_RG_RMAPBT)
 
 #define XFS_SICK_AG_PRIMARY    (XFS_SICK_AG_SB | \
                                 XFS_SICK_AG_AGF | \
index 7b1ff7872b59745849a90d9500d1977f5b1dd88b..5f0166c2f69ed1511b9039f348c3604c6b8a21de 100644 (file)
@@ -275,8 +275,10 @@ xfs_iformat_data_fork(
                         * realtime volume to the filesystem, so we cannot use
                         * the rtrmapbt predicate here.
                         */
-                       if (!xfs_has_rmapbt(ip->i_mount))
+                       if (!xfs_has_rmapbt(ip->i_mount)) {
+                               xfs_inode_mark_sick(ip, XFS_SICK_INO_CORE);
                                return -EFSCORRUPTED;
+                       }
                        return xfs_iformat_rtrmap(ip, dip);
                default:
                        xfs_inode_verifier_error(ip, -EFSCORRUPTED, __func__,
index 8844685cc3196ace72a34f5f04732a2536c555a4..e88da842a1e9c241b2c1b126e3079563a57dce26 100644 (file)
@@ -333,6 +333,7 @@ static const struct xfs_rtginode_ops xfs_rtginode_ops[XFS_RTGI_MAX] = {
        [XFS_RTGI_RMAP] = {
                .name           = "rmap",
                .metafile_type  = XFS_METAFILE_RTRMAP,
+               .sick           = XFS_SICK_RG_RMAPBT,
                .fmt_mask       = 1U << XFS_DINODE_FMT_RMAP,
                /*
                 * growfs must create the rtrmap inodes before adding a
index 007d3ec9ecbddca962474608f58e33021e6802f7..bc1ea2346cdf3fb200ad915eb2489ff6226fe772 100644 (file)
@@ -27,6 +27,7 @@
 #include "xfs_extent_busy.h"
 #include "xfs_rtgroup.h"
 #include "xfs_bmap.h"
+#include "xfs_health.h"
 
 static struct kmem_cache       *xfs_rtrmapbt_cur_cache;
 
@@ -498,6 +499,7 @@ const struct xfs_btree_ops xfs_rtrmapbt_ops = {
 
        .lru_refs               = XFS_RMAP_BTREE_REF,
        .statoff                = XFS_STATS_CALC_INDEX(xs_rtrmap_2),
+       .sick_mask              = XFS_SICK_RG_RMAPBT,
 
        .dup_cursor             = xfs_rtrmapbt_dup_cursor,
        .alloc_block            = xfs_btree_alloc_metafile_block,
@@ -758,8 +760,10 @@ xfs_iformat_rtrmap(
        level = be16_to_cpu(dfp->bb_level);
 
        if (level > mp->m_rtrmap_maxlevels ||
-           xfs_rtrmap_droot_space_calc(level, numrecs) > dsize)
+           xfs_rtrmap_droot_space_calc(level, numrecs) > dsize) {
+               xfs_inode_mark_sick(ip, XFS_SICK_INO_CORE);
                return -EFSCORRUPTED;
+       }
 
        broot = xfs_broot_realloc(xfs_ifork_ptr(ip, XFS_DATA_FORK),
                        xfs_rtrmap_broot_space_calc(mp, level, numrecs));
index b1c709e405129f1c75a9775d49397782ec0f0c6f..5c282ca862bba6dd70f01f4ec96e933d5d7b507d 100644 (file)
@@ -447,6 +447,7 @@ static const struct ioctl_sick_map rtgroup_map[] = {
        { XFS_SICK_RG_SUPER,    XFS_RTGROUP_GEOM_SICK_SUPER },
        { XFS_SICK_RG_BITMAP,   XFS_RTGROUP_GEOM_SICK_BITMAP },
        { XFS_SICK_RG_SUMMARY,  XFS_RTGROUP_GEOM_SICK_SUMMARY },
+       { XFS_SICK_RG_RMAPBT,   XFS_RTGROUP_GEOM_SICK_RMAPBT },
 };
 
 /* Fill out rtgroup geometry health info. */