]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
xfs: report realtime refcount btree corruption errors to the health system
authorDarrick J. Wong <djwong@kernel.org>
Thu, 21 Nov 2024 00:21:05 +0000 (16:21 -0800)
committerDarrick J. Wong <djwong@kernel.org>
Mon, 23 Dec 2024 21:06:14 +0000 (13:06 -0800)
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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
fs/xfs/libxfs/xfs_fs.h
fs/xfs/libxfs/xfs_health.h
fs/xfs/libxfs/xfs_rtgroup.c
fs/xfs/libxfs/xfs_rtrefcount_btree.c
fs/xfs/xfs_health.c

index d42d3a5617e314ccd7eb1d172045a3e26eb31890..ea9e58a89d92d3260fb0e10bedcc4cdd8603d487 100644 (file)
@@ -996,6 +996,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 5c8a0aff6ba6e9d0eca20ed0ea7be2c8e8cadedf..b31000f7190ce5ccda6d082b07575af536ec3cb7 100644 (file)
@@ -71,6 +71,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 */
@@ -117,7 +118,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 eab655a4a9ef5c03f6d9ae47725b35a33d16d6ea..a6468e591232c3350871fe47fff22928d1d4766a 100644 (file)
@@ -380,6 +380,7 @@ static const struct xfs_rtginode_ops xfs_rtginode_ops[XFS_RTGI_MAX] = {
        [XFS_RTGI_REFCOUNT] = {
                .name           = "refcount",
                .metafile_type  = XFS_METAFILE_RTREFCOUNT,
+               .sick           = XFS_SICK_RG_REFCNTBT,
                .fmt_mask       = 1U << XFS_DINODE_FMT_META_BTREE,
                /* same comment about growfs and rmap inodes applies here */
                .enabled        = xfs_has_reflink,
index 151fb1ef7db1263a5fcd06044a4876fc7dd9320a..3db5e7a4a9456764c9c72ad9f0807893d79f7915 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;
 
@@ -374,6 +375,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,
@@ -640,16 +642,20 @@ xfs_iformat_rtrefcount(
         * volume to the filesystem, so we cannot use the rtrefcount predicate
         * here.
         */
-       if (!xfs_has_reflink(ip->i_mount))
+       if (!xfs_has_reflink(ip->i_mount)) {
+               xfs_inode_mark_sick(ip, XFS_SICK_INO_CORE);
                return -EFSCORRUPTED;
+       }
 
        dsize = XFS_DFORK_SIZE(dip, mp, XFS_DATA_FORK);
        numrecs = be16_to_cpu(dfp->bb_numrecs);
        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;
+       }
 
        broot = xfs_broot_alloc(xfs_ifork_ptr(ip, XFS_DATA_FORK),
                        xfs_rtrefcount_broot_space_calc(mp, level, numrecs));
index d438c3c001c829b44547fe3302a0de11c0014c33..7c541fb373d5b20264cfc61e7f53cd5403b34676 100644 (file)
@@ -448,6 +448,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 },
 };
 
 /* Fill out rtgroup geometry health info. */