From: Darrick J. Wong <djwong@xxxxxxxxxx> Make a report to the health monitoring subsystem any time we encounter something in the metadata directory tree that looks like corruption. Signed-off-by: Darrick J. Wong <djwong@xxxxxxxxxx> --- libxfs/xfs_fs.h | 1 + libxfs/xfs_health.h | 4 +++- libxfs/xfs_imeta.c | 28 ++++++++++++++++++++++------ 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/libxfs/xfs_fs.h b/libxfs/xfs_fs.h index 6e0c45fcfee..c4995f6557d 100644 --- a/libxfs/xfs_fs.h +++ b/libxfs/xfs_fs.h @@ -197,6 +197,7 @@ struct xfs_fsop_geom { #define XFS_FSOP_GEOM_SICK_RT_SUMMARY (1 << 5) /* realtime summary */ #define XFS_FSOP_GEOM_SICK_QUOTACHECK (1 << 6) /* quota counts */ #define XFS_FSOP_GEOM_SICK_NLINKS (1 << 7) /* inode link counts */ +#define XFS_FSOP_GEOM_SICK_METADIR (1 << 8) /* metadata directory */ /* Output for XFS_FS_COUNTS */ typedef struct xfs_fsop_counts { diff --git a/libxfs/xfs_health.h b/libxfs/xfs_health.h index 252334bc048..99d53bae9c1 100644 --- a/libxfs/xfs_health.h +++ b/libxfs/xfs_health.h @@ -60,6 +60,7 @@ struct xfs_da_args; #define XFS_SICK_FS_PQUOTA (1 << 3) /* project quota */ #define XFS_SICK_FS_QUOTACHECK (1 << 4) /* quota counts */ #define XFS_SICK_FS_NLINKS (1 << 5) /* inode link counts */ +#define XFS_SICK_FS_METADIR (1 << 6) /* metadata directory tree */ /* Observable health issues for realtime volume metadata. */ #define XFS_SICK_RT_BITMAP (1 << 0) /* realtime bitmap */ @@ -96,7 +97,8 @@ struct xfs_da_args; XFS_SICK_FS_GQUOTA | \ XFS_SICK_FS_PQUOTA | \ XFS_SICK_FS_QUOTACHECK | \ - XFS_SICK_FS_NLINKS) + XFS_SICK_FS_NLINKS | \ + XFS_SICK_FS_METADIR) #define XFS_SICK_RT_PRIMARY (XFS_SICK_RT_BITMAP | \ XFS_SICK_RT_SUMMARY) diff --git a/libxfs/xfs_imeta.c b/libxfs/xfs_imeta.c index eaf63275c08..a5d8e6057bb 100644 --- a/libxfs/xfs_imeta.c +++ b/libxfs/xfs_imeta.c @@ -25,6 +25,7 @@ #include "xfs_dir2.h" #include "xfs_dir2_priv.h" #include "xfs_ag.h" +#include "xfs_health.h" /* * Metadata Inode Number Management @@ -404,16 +405,22 @@ xfs_imeta_dir_lookup_component( trace_xfs_imeta_dir_lookup_component(dp, xname, NULLFSINO); - if (!S_ISDIR(VFS_I(dp)->i_mode)) + if (!S_ISDIR(VFS_I(dp)->i_mode)) { + xfs_fs_mark_sick(dp->i_mount, XFS_SICK_FS_METADIR); return -EFSCORRUPTED; + } error = xfs_imeta_dir_lookup(dp, xname, ino); if (error) return error; - if (!xfs_verify_ino(dp->i_mount, *ino)) + if (!xfs_verify_ino(dp->i_mount, *ino)) { + xfs_fs_mark_sick(dp->i_mount, XFS_SICK_FS_METADIR); return -EFSCORRUPTED; - if (type_wanted != XFS_DIR3_FT_UNKNOWN && xname->type != type_wanted) + } + if (type_wanted != XFS_DIR3_FT_UNKNOWN && xname->type != type_wanted) { + xfs_fs_mark_sick(dp->i_mount, XFS_SICK_FS_METADIR); return -EFSCORRUPTED; + } trace_xfs_imeta_dir_lookup_found(dp, xname, *ino); return 0; @@ -712,6 +719,7 @@ xfs_imeta_dir_unlink( /* Metadata directory root cannot be unlinked. */ if (xfs_imeta_path_compare(path, &XFS_IMETA_METADIR)) { ASSERT(0); + xfs_fs_mark_sick(mp, XFS_SICK_FS_METADIR); return -EFSCORRUPTED; } @@ -727,6 +735,7 @@ xfs_imeta_dir_unlink( error = -ENOENT; break; case -ENOENT: + xfs_fs_mark_sick(mp, XFS_SICK_FS_METADIR); error = -EFSCORRUPTED; break; } @@ -778,6 +787,7 @@ xfs_imeta_dir_link( /* Metadata directory root cannot be linked. */ if (xfs_imeta_path_compare(path, &XFS_IMETA_METADIR)) { ASSERT(0); + xfs_fs_mark_sick(mp, XFS_SICK_FS_METADIR); return -EFSCORRUPTED; } @@ -855,16 +865,20 @@ xfs_imeta_lookup( if (xfs_has_metadir(mp)) { error = xfs_imeta_dir_lookup_int(mp, path, &ino); - if (error == -ENOENT) + if (error == -ENOENT) { + xfs_fs_mark_sick(mp, XFS_SICK_FS_METADIR); return -EFSCORRUPTED; + } } else { error = xfs_imeta_sb_lookup(mp, path, &ino); } if (error) return error; - if (!xfs_imeta_verify(mp, ino)) + if (!xfs_imeta_verify(mp, ino)) { + xfs_fs_mark_sick(mp, XFS_SICK_FS_METADIR); return -EFSCORRUPTED; + } *inop = ino; return 0; @@ -1040,8 +1054,10 @@ xfs_imeta_start_update( * to exist. */ error = xfs_imeta_dir_parent(mp, path, &upd->dp); - if (error == -ENOENT) + if (error == -ENOENT) { + xfs_fs_mark_sick(mp, XFS_SICK_FS_METADIR); return -EFSCORRUPTED; + } if (error) return error;