Skip to content

Commit be42fc1

Browse files
author
Darrick J. Wong
committed
xfs: record health problems with the metadata directory
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@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de>
1 parent 61b6bdb commit be42fc1

6 files changed

Lines changed: 17 additions & 4 deletions

File tree

fs/xfs/libxfs/xfs_fs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ struct xfs_fsop_geom {
198198
#define XFS_FSOP_GEOM_SICK_RT_SUMMARY (1 << 5) /* realtime summary */
199199
#define XFS_FSOP_GEOM_SICK_QUOTACHECK (1 << 6) /* quota counts */
200200
#define XFS_FSOP_GEOM_SICK_NLINKS (1 << 7) /* inode link counts */
201+
#define XFS_FSOP_GEOM_SICK_METADIR (1 << 8) /* metadata directory */
201202

202203
/* Output for XFS_FS_COUNTS */
203204
typedef struct xfs_fsop_counts {

fs/xfs/libxfs/xfs_health.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ struct xfs_da_args;
6262
#define XFS_SICK_FS_PQUOTA (1 << 3) /* project quota */
6363
#define XFS_SICK_FS_QUOTACHECK (1 << 4) /* quota counts */
6464
#define XFS_SICK_FS_NLINKS (1 << 5) /* inode link counts */
65+
#define XFS_SICK_FS_METADIR (1 << 6) /* metadata directory tree */
6566

6667
/* Observable health issues for realtime volume metadata. */
6768
#define XFS_SICK_RT_BITMAP (1 << 0) /* realtime bitmap */
@@ -105,7 +106,8 @@ struct xfs_da_args;
105106
XFS_SICK_FS_GQUOTA | \
106107
XFS_SICK_FS_PQUOTA | \
107108
XFS_SICK_FS_QUOTACHECK | \
108-
XFS_SICK_FS_NLINKS)
109+
XFS_SICK_FS_NLINKS | \
110+
XFS_SICK_FS_METADIR)
109111

110112
#define XFS_SICK_RT_PRIMARY (XFS_SICK_RT_BITMAP | \
111113
XFS_SICK_RT_SUMMARY)

fs/xfs/libxfs/xfs_metadir.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "xfs_dir2.h"
2929
#include "xfs_dir2_priv.h"
3030
#include "xfs_parent.h"
31+
#include "xfs_health.h"
3132

3233
/*
3334
* Metadata Directory Tree
@@ -94,19 +95,25 @@ xfs_metadir_lookup(
9495
};
9596
int error;
9697

97-
if (!S_ISDIR(VFS_I(dp)->i_mode))
98+
if (!S_ISDIR(VFS_I(dp)->i_mode)) {
99+
xfs_fs_mark_sick(mp, XFS_SICK_FS_METADIR);
98100
return -EFSCORRUPTED;
101+
}
99102
if (xfs_is_shutdown(mp))
100103
return -EIO;
101104

102105
error = xfs_dir_lookup_args(&args);
103106
if (error)
104107
return error;
105108

106-
if (!xfs_verify_ino(mp, args.inumber))
109+
if (!xfs_verify_ino(mp, args.inumber)) {
110+
xfs_fs_mark_sick(mp, XFS_SICK_FS_METADIR);
107111
return -EFSCORRUPTED;
108-
if (xname->type != XFS_DIR3_FT_UNKNOWN && xname->type != args.filetype)
112+
}
113+
if (xname->type != XFS_DIR3_FT_UNKNOWN && xname->type != args.filetype) {
114+
xfs_fs_mark_sick(mp, XFS_SICK_FS_METADIR);
109115
return -EFSCORRUPTED;
116+
}
110117

111118
trace_xfs_metadir_lookup(dp, xname, args.inumber);
112119
*ino = args.inumber;

fs/xfs/xfs_health.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,7 @@ static const struct ioctl_sick_map fs_map[] = {
380380
{ XFS_SICK_FS_PQUOTA, XFS_FSOP_GEOM_SICK_PQUOTA },
381381
{ XFS_SICK_FS_QUOTACHECK, XFS_FSOP_GEOM_SICK_QUOTACHECK },
382382
{ XFS_SICK_FS_NLINKS, XFS_FSOP_GEOM_SICK_NLINKS },
383+
{ XFS_SICK_FS_METADIR, XFS_FSOP_GEOM_SICK_METADIR },
383384
{ 0, 0 },
384385
};
385386

fs/xfs/xfs_icache.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -878,6 +878,7 @@ xfs_trans_metafile_iget(
878878
whine:
879879
xfs_err(mp, "metadata inode 0x%llx type %u is corrupt", ino,
880880
metafile_type);
881+
xfs_fs_mark_sick(mp, XFS_SICK_FS_METADIR);
881882
return -EFSCORRUPTED;
882883
}
883884

fs/xfs/xfs_inode.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,7 @@ xfs_lookup(
560560
* a metadata file.
561561
*/
562562
if (XFS_IS_CORRUPT(dp->i_mount, xfs_is_metadir_inode(*ipp))) {
563+
xfs_fs_mark_sick(dp->i_mount, XFS_SICK_FS_METADIR);
563564
error = -EFSCORRUPTED;
564565
goto out_irele;
565566
}

0 commit comments

Comments
 (0)