From: Darrick J. Wong Date: Tue, 7 Mar 2023 03:55:58 +0000 (-0800) Subject: xfs: report realtime rmap btree corruption errors to the health system X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=143f4c83739485ffd87be7a99d5c060bf6dda768;p=users%2Fhch%2Fxfsprogs.git xfs: report realtime rmap btree corruption errors to the health system 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 --- diff --git a/libxfs/xfs_fs_staging.h b/libxfs/xfs_fs_staging.h index 4e875efd3..84a510ce5 100644 --- a/libxfs/xfs_fs_staging.h +++ b/libxfs/xfs_fs_staging.h @@ -216,6 +216,7 @@ struct xfs_rtgroup_geometry { }; #define XFS_RTGROUP_GEOM_SICK_SUPER (1 << 0) /* superblock */ #define XFS_RTGROUP_GEOM_SICK_BITMAP (1 << 1) /* rtbitmap for this group */ +#define XFS_RTGROUP_GEOM_SICK_RMAPBT (1 << 2) /* reverse mappings */ #define XFS_IOC_RTGROUP_GEOMETRY _IOWR('X', 63, struct xfs_rtgroup_geometry) diff --git a/libxfs/xfs_health.h b/libxfs/xfs_health.h index 57316e961..ffbd102e7 100644 --- a/libxfs/xfs_health.h +++ b/libxfs/xfs_health.h @@ -68,6 +68,7 @@ struct xfs_rtgroup; #define XFS_SICK_RT_BITMAP (1 << 0) /* realtime bitmap */ #define XFS_SICK_RT_SUMMARY (1 << 1) /* realtime summary */ #define XFS_SICK_RT_SUPER (1 << 2) /* rt group superblock */ +#define XFS_SICK_RT_RMAPBT (1 << 3) /* reverse mappings */ /* Observable health issues for AG metadata. */ #define XFS_SICK_AG_SB (1 << 0) /* superblock */ @@ -107,7 +108,8 @@ struct xfs_rtgroup; #define XFS_SICK_RT_PRIMARY (XFS_SICK_RT_BITMAP | \ XFS_SICK_RT_SUMMARY | \ - XFS_SICK_RT_SUPER) + XFS_SICK_RT_SUPER | \ + XFS_SICK_RT_RMAPBT) #define XFS_SICK_AG_PRIMARY (XFS_SICK_AG_SB | \ XFS_SICK_AG_AGF | \ diff --git a/libxfs/xfs_inode_fork.c b/libxfs/xfs_inode_fork.c index bf0c9c29e..72a2e5e7c 100644 --- a/libxfs/xfs_inode_fork.c +++ b/libxfs/xfs_inode_fork.c @@ -264,8 +264,10 @@ xfs_iformat_data_fork( case XFS_DINODE_FMT_BTREE: return xfs_iformat_btree(ip, dip, XFS_DATA_FORK); case XFS_DINODE_FMT_RMAP: - if (!xfs_has_rtrmapbt(ip->i_mount)) + if (!xfs_has_rtrmapbt(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__, diff --git a/libxfs/xfs_rtrmap_btree.c b/libxfs/xfs_rtrmap_btree.c index a00b87356..5365e5f8b 100644 --- a/libxfs/xfs_rtrmap_btree.c +++ b/libxfs/xfs_rtrmap_btree.c @@ -25,6 +25,7 @@ #include "xfs_rtgroup.h" #include "xfs_bmap.h" #include "xfs_imeta.h" +#include "xfs_health.h" static struct kmem_cache *xfs_rtrmapbt_cur_cache; @@ -798,8 +799,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; + } xfs_iroot_alloc(ip, XFS_DATA_FORK, xfs_rtrmap_broot_space_calc(mp, level, numrecs)); diff --git a/man/man2/ioctl_xfs_rtgroup_geometry.2 b/man/man2/ioctl_xfs_rtgroup_geometry.2 index 83c4428da..8711e7b7e 100644 --- a/man/man2/ioctl_xfs_rtgroup_geometry.2 +++ b/man/man2/ioctl_xfs_rtgroup_geometry.2 @@ -73,6 +73,9 @@ Realtime group superblock. .TP .B XFS_RTGROUP_GEOM_SICK_BITMAP Realtime bitmap for this group. +.TP +.B XFS_RTGROUP_GEOM_SICK_RTRMAPBT +Reverse mapping btree for this group. .RE .SH RETURN VALUE On error, \-1 is returned, and