]> www.infradead.org Git - users/hch/xfs.git/commitdiff
xfs: report realtime refcount btree corruption errors to the health system
authorDarrick J. Wong <djwong@kernel.org>
Fri, 9 Aug 2024 13:21:17 +0000 (15:21 +0200)
committerChristoph Hellwig <hch@lst.de>
Mon, 12 Aug 2024 11:53:09 +0000 (13:53 +0200)
Whenever we encounter corrupt realtime refcount 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_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_rtrefcount_btree.c
fs/xfs/xfs_health.c

index 036dc246b9ab9961b19d5cd401ad103209e54ce4..d460be71c31406d59d0de1de08fb54f53c8522fb 100644 (file)
@@ -993,6 +993,7 @@ struct xfs_rtgroup_geometry {
 #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 */
+#define XFS_RTGROUP_GEOM_SICK_REFCNTBT (1U << 4)  /* reference counts */
 
 /*
  * ioctl commands that are used by Linux filesystems
index 87b38d0bcb310cc47ebb8817d6477a124f1618da..65a4af590d05dc4e1c71ede04ce0ee4a992e6dda 100644 (file)
@@ -69,6 +69,7 @@ struct xfs_rtgroup;
 #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 */
+#define XFS_SICK_RG_REFCNTBT   (1 << 4)  /* reference counts */
 
 /* 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_RMAPBT)
+                                XFS_SICK_RG_RMAPBT | \
+                                XFS_SICK_RG_REFCNTBT)
 
 #define XFS_SICK_AG_PRIMARY    (XFS_SICK_AG_SB | \
                                 XFS_SICK_AG_AGF | \
index 7c1ab95788e07997e7ad949e6229cb3f37133585..b677c6a91563b3bb2549bcf8ec9f51023a8ff272 100644 (file)
@@ -277,8 +277,10 @@ xfs_iformat_data_fork(
                        }
                        return xfs_iformat_rtrmap(ip, dip);
                case XFS_DINODE_FMT_REFCOUNT:
-                       if (!xfs_has_rtreflink(ip->i_mount))
+                       if (!xfs_has_rtreflink(ip->i_mount)) {
+                               xfs_inode_mark_sick(ip, XFS_SICK_INO_CORE);
                                return -EFSCORRUPTED;
+                       }
                        return xfs_iformat_rtrefcount(ip, dip);
                default:
                        xfs_inode_verifier_error(ip, -EFSCORRUPTED, __func__,
index 51fd11e4a79e425eaa366a27f6d8d728362c3581..41214519b445ae867c57fb7c77d11e955f134e7e 100644 (file)
@@ -422,6 +422,7 @@ static const struct xfs_rtginode_ops xfs_rtginode_ops[XFS_RTG_MAX] = {
                .name           = "refcount",
                .metafile_type  = XFS_METAFILE_RTREFCOUNT,
                .format         = XFS_DINODE_FMT_REFCOUNT,
+               .sick           = XFS_SICK_RG_REFCNTBT,
                .enabled        = xfs_has_rtreflink,
                .create         = xfs_rtrefcountbt_create,
        },
index f753c6630d60aad5fe19d42df08ed876a8739681..db27b9baecc861623c801506b6a217ce92893693 100644 (file)
@@ -27,6 +27,7 @@
 #include "xfs_rtgroup.h"
 #include "xfs_rtbitmap.h"
 #include "xfs_metafile.h"
+#include "xfs_health.h"
 
 static struct kmem_cache       *xfs_rtrefcountbt_cur_cache;
 
@@ -360,6 +361,7 @@ const struct xfs_btree_ops xfs_rtrefcountbt_ops = {
 
        .lru_refs               = XFS_REFC_BTREE_REF,
        .statoff                = XFS_STATS_CALC_INDEX(xs_rtrefcbt_2),
+       .sick_mask              = XFS_SICK_RG_REFCNTBT,
 
        .dup_cursor             = xfs_rtrefcountbt_dup_cursor,
        .alloc_block            = xfs_btree_alloc_metafile_block,
@@ -627,8 +629,10 @@ xfs_iformat_rtrefcount(
        level = be16_to_cpu(dfp->bb_level);
 
        if (level > mp->m_rtrefc_maxlevels ||
-           xfs_rtrefcount_droot_space_calc(level, numrecs) > dsize)
+           xfs_rtrefcount_droot_space_calc(level, numrecs) > dsize) {
+               xfs_inode_mark_sick(ip, XFS_SICK_INO_CORE);
                return -EFSCORRUPTED;
+       }
 
        xfs_iroot_alloc(ip, XFS_DATA_FORK,
                        xfs_rtrefcount_broot_space_calc(mp, level, numrecs));
index d35678edf82ad7f343a879469114127bb84a9152..b466c20035021ec2de71a012bdefc759f1d57a8b 100644 (file)
@@ -490,6 +490,7 @@ static const struct ioctl_sick_map rtgroup_map[] = {
        { 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 },
+       { XFS_SICK_RG_REFCNTBT, XFS_RTGROUP_GEOM_SICK_REFCNTBT },
        { 0, 0 },
 };