]> www.infradead.org Git - users/hch/xfsprogs.git/commitdiff
xfs: report realtime refcount btree corruption errors to the health system
authorDarrick J. Wong <djwong@kernel.org>
Thu, 15 Aug 2024 18:49:36 +0000 (11:49 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Wed, 9 Oct 2024 23:29:20 +0000 (16:29 -0700)
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>
libxfs/xfs_fs.h
libxfs/xfs_health.h
libxfs/xfs_inode_fork.c
libxfs/xfs_rtgroup.c
libxfs/xfs_rtrefcount_btree.c

index f43eefd1133077ad7e05637af5c3afea0154300f..d535eaf6877102d1a7f7728e3c3729b1cbec90f4 100644 (file)
@@ -997,6 +997,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 74b3737ca3f2d112fdbf2c0d25ffb26883947ea6..567fb8312cf65136a49852a483147516e69e92f1 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 e3a75f90b4761927aa74ad9b923ca564c6ca775e..6fa49ab145a93c079fc69419ab6a48522c634810 100644 (file)
@@ -281,8 +281,10 @@ xfs_iformat_data_fork(
                        return xfs_iformat_rtrmap(ip, dip);
                case XFS_DINODE_FMT_REFCOUNT:
                        /* same comment about growfs and rmap inodes applies */
-                       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;
+                       }
                        return xfs_iformat_rtrefcount(ip, dip);
                default:
                        xfs_inode_verifier_error(ip, -EFSCORRUPTED, __func__,
index 46b440ab287fadf7e83bdde7fb1327fa8e093508..766776c8d0b801e1968cfdb22f2b686bf31ebacc 100644 (file)
@@ -373,6 +373,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_REFCOUNT,
                /* same comment about growfs and rmap inodes applies here */
                .enabled        = xfs_has_reflink,
index 1e385c67bd66c38816031d8aef6eb7476de3aa52..1a3f82911b5f0fa8123f74f15b8778fa430737dc 100644 (file)
@@ -26,6 +26,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;
 
@@ -375,6 +376,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,
@@ -641,8 +643,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;
+       }
 
        broot = xfs_broot_realloc(xfs_ifork_ptr(ip, XFS_DATA_FORK),
                        xfs_rtrefcount_broot_space_calc(mp, level, numrecs));