From: Darrick J. Wong <djwong@xxxxxxxxxx> 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@xxxxxxxxxx> --- libxfs/xfs_fs.h | 1 + libxfs/xfs_health.h | 4 +++- libxfs/xfs_inode_fork.c | 4 +++- libxfs/xfs_rtrefcount_btree.c | 5 ++++- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/libxfs/xfs_fs.h b/libxfs/xfs_fs.h index 8547ba85c55..5819576a51a 100644 --- a/libxfs/xfs_fs.h +++ b/libxfs/xfs_fs.h @@ -314,6 +314,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_RTGROUP_GEOM_SICK_REFCNTBT (1 << 3) /* reference counts */ /* * Structures for XFS_IOC_FSGROWFSDATA, XFS_IOC_FSGROWFSLOG & XFS_IOC_FSGROWFSRT diff --git a/libxfs/xfs_health.h b/libxfs/xfs_health.h index d5976f6b0de..13128216754 100644 --- a/libxfs/xfs_health.h +++ b/libxfs/xfs_health.h @@ -68,6 +68,7 @@ struct xfs_rtgroup; #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 */ +#define XFS_SICK_RT_REFCNTBT (1 << 4) /* reference counts */ /* Observable health issues for AG metadata. */ #define XFS_SICK_AG_SB (1 << 0) /* superblock */ @@ -106,7 +107,8 @@ struct xfs_rtgroup; #define XFS_SICK_RT_PRIMARY (XFS_SICK_RT_BITMAP | \ XFS_SICK_RT_SUMMARY | \ XFS_SICK_RT_SUPER | \ - XFS_SICK_RT_RMAPBT) + XFS_SICK_RT_RMAPBT | \ + XFS_SICK_RT_REFCNTBT) #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 b019cbeb5fd..4bdcfcda234 100644 --- a/libxfs/xfs_inode_fork.c +++ b/libxfs/xfs_inode_fork.c @@ -266,8 +266,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__, diff --git a/libxfs/xfs_rtrefcount_btree.c b/libxfs/xfs_rtrefcount_btree.c index 5e9930d315c..537287c1696 100644 --- a/libxfs/xfs_rtrefcount_btree.c +++ b/libxfs/xfs_rtrefcount_btree.c @@ -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; @@ -691,8 +692,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));