]> 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>
Wed, 3 Jul 2024 21:22:31 +0000 (14:22 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Tue, 16 Jul 2024 22:49:23 +0000 (15:49 -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_rtrefcount_btree.c
man/man2/ioctl_xfs_rtgroup_geometry.2

index 51a4bff117ececa5e3f79d6593da1be4ba718e04..5351a253c956d25a381888b70e77f64ef5a52c40 100644 (file)
@@ -990,6 +990,7 @@ struct xfs_rtgroup_geometry {
 #define XFS_RTGROUP_GEOM_SICK_SUPER    (1U << 0)  /* superblock */
 #define XFS_RTGROUP_GEOM_SICK_BITMAP   (1U << 1)  /* rtbitmap for this group */
 #define XFS_RTGROUP_GEOM_SICK_RMAPBT   (1U << 2)  /* reverse mappings */
+#define XFS_RTGROUP_GEOM_SICK_REFCNTBT (1U << 3)  /* reference counts */
 
 /*
  * ioctl commands that are used by Linux filesystems
index c03a42032d7fad63ba8a3de6fbff7102cb7c6f29..89b80e957917e8df7d322c3f1832f48556eb8e84 100644 (file)
@@ -72,6 +72,7 @@ struct xfs_rtgroup;
 #define XFS_SICK_RG_SUPER      (1 << 0)  /* rt group superblock */
 #define XFS_SICK_RG_BITMAP     (1 << 1)  /* rt group part of rtbitmap */
 #define XFS_SICK_RG_RMAPBT     (1 << 2)  /* reverse mappings */
+#define XFS_SICK_RG_REFCNTBT   (1 << 3)  /* reference counts */
 
 /* Observable health issues for AG metadata. */
 #define XFS_SICK_AG_SB         (1 << 0)  /* superblock */
@@ -120,7 +121,8 @@ struct xfs_rtgroup;
 
 #define XFS_SICK_RG_PRIMARY    (XFS_SICK_RG_SUPER | \
                                 XFS_SICK_RG_BITMAP | \
-                                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 88d36cd07175403a84b30854a59056b6d616072d..eb58647f169609c1cfa240dad17d28dfffb08411 100644 (file)
@@ -275,8 +275,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 4dcfd20c44ca16e0bddfdde54e980687f22ff7b5..76fcd6ede778b3319c1e5467ed5759adc22eab5e 100644 (file)
@@ -25,6 +25,7 @@
 #include "xfs_rtgroup.h"
 #include "xfs_rtbitmap.h"
 #include "xfs_imeta.h"
+#include "xfs_health.h"
 
 static struct kmem_cache       *xfs_rtrefcountbt_cur_cache;
 
@@ -358,6 +359,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_imeta_block,
@@ -625,8 +627,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 26cfb5a3881e7869f3ed89c9d1a1147050c7623b..4edaa15dbbdb8cae5003243870718c5461ad04b2 100644 (file)
@@ -74,6 +74,9 @@ Realtime bitmap for this group.
 .TP
 .B XFS_RTGROUP_GEOM_SICK_RTRMAPBT
 Reverse mapping btree for this group.
+.TP
+.B XFS_RTGROUP_GEOM_SICK_REFCNTBT
+Reference count btree for this group.
 .RE
 .SH RETURN VALUE
 On error, \-1 is returned, and