summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorDarrick J. Wong <djwong@kernel.org>2022-07-14 11:06:21 -0700
committerDarrick J. Wong <djwong@kernel.org>2022-10-14 14:16:43 -0700
commitc3c546f5caf8cbb303048e7bce3be85d9a7a1e08 (patch)
tree811727c8e724c082cb036c8505d0c25132f0df86 /fs
parente00e3099a6c5adc6d334e14424e9d936f4b9c3c3 (diff)
xfs: separate the marking of sick and checked metadata
Split the setting of the sick and checked masks into separate functions as part of preparing to add the ability for regular runtime fs code (i.e. not scrub) to mark metadata structures sick when corruptions are found. Improve the documentation of libxfs' requirements for helper behavior. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/xfs/libxfs/xfs_health.h16
-rw-r--r--fs/xfs/scrub/health.c20
-rw-r--r--fs/xfs/xfs_health.c51
-rw-r--r--fs/xfs/xfs_mount.c5
4 files changed, 81 insertions, 11 deletions
diff --git a/fs/xfs/libxfs/xfs_health.h b/fs/xfs/libxfs/xfs_health.h
index 5571f6cb2539..aa4771fad505 100644
--- a/fs/xfs/libxfs/xfs_health.h
+++ b/fs/xfs/libxfs/xfs_health.h
@@ -101,24 +101,38 @@ struct xfs_fsop_geom;
XFS_SICK_INO_SYMLINK | \
XFS_SICK_INO_PARENT)
-/* These functions must be provided by the xfs implementation. */
+/*
+ * These functions must be provided by the xfs implementation. Function
+ * behavior with respect to the first argument should be as follows:
+ *
+ * xfs_*_mark_sick: set the sick flags and do not set checked flags.
+ * xfs_*_mark_checked: set the checked flags.
+ * xfs_*_mark_healthy: clear the sick flags and set the checked flags.
+ *
+ * xfs_*_measure_sickness: return the sick and check status in the provided
+ * out parameters.
+ */
void xfs_fs_mark_sick(struct xfs_mount *mp, unsigned int mask);
+void xfs_fs_mark_checked(struct xfs_mount *mp, unsigned int mask);
void xfs_fs_mark_healthy(struct xfs_mount *mp, unsigned int mask);
void xfs_fs_measure_sickness(struct xfs_mount *mp, unsigned int *sick,
unsigned int *checked);
void xfs_rt_mark_sick(struct xfs_mount *mp, unsigned int mask);
+void xfs_rt_mark_checked(struct xfs_mount *mp, unsigned int mask);
void xfs_rt_mark_healthy(struct xfs_mount *mp, unsigned int mask);
void xfs_rt_measure_sickness(struct xfs_mount *mp, unsigned int *sick,
unsigned int *checked);
void xfs_ag_mark_sick(struct xfs_perag *pag, unsigned int mask);
+void xfs_ag_mark_checked(struct xfs_perag *pag, unsigned int mask);
void xfs_ag_mark_healthy(struct xfs_perag *pag, unsigned int mask);
void xfs_ag_measure_sickness(struct xfs_perag *pag, unsigned int *sick,
unsigned int *checked);
void xfs_inode_mark_sick(struct xfs_inode *ip, unsigned int mask);
+void xfs_inode_mark_checked(struct xfs_inode *ip, unsigned int mask);
void xfs_inode_mark_healthy(struct xfs_inode *ip, unsigned int mask);
void xfs_inode_measure_sickness(struct xfs_inode *ip, unsigned int *sick,
unsigned int *checked);
diff --git a/fs/xfs/scrub/health.c b/fs/xfs/scrub/health.c
index 6749930b50a2..e5cc89d43808 100644
--- a/fs/xfs/scrub/health.c
+++ b/fs/xfs/scrub/health.c
@@ -144,30 +144,34 @@ xchk_update_health(
switch (type_to_health_flag[sc->sm->sm_type].group) {
case XHG_AG:
pag = xfs_perag_get(sc->mp, sc->sm->sm_agno);
- if (bad)
+ if (bad) {
xfs_ag_mark_sick(pag, sc->sick_mask);
- else
+ xfs_ag_mark_checked(pag, sc->sick_mask);
+ } else
xfs_ag_mark_healthy(pag, sc->sick_mask);
xfs_perag_put(pag);
break;
case XHG_INO:
if (!sc->ip)
return;
- if (bad)
+ if (bad) {
xfs_inode_mark_sick(sc->ip, sc->sick_mask);
- else
+ xfs_inode_mark_checked(sc->ip, sc->sick_mask);
+ } else
xfs_inode_mark_healthy(sc->ip, sc->sick_mask);
break;
case XHG_FS:
- if (bad)
+ if (bad) {
xfs_fs_mark_sick(sc->mp, sc->sick_mask);
- else
+ xfs_fs_mark_checked(sc->mp, sc->sick_mask);
+ } else
xfs_fs_mark_healthy(sc->mp, sc->sick_mask);
break;
case XHG_RT:
- if (bad)
+ if (bad) {
xfs_rt_mark_sick(sc->mp, sc->sick_mask);
- else
+ xfs_rt_mark_checked(sc->mp, sc->sick_mask);
+ } else
xfs_rt_mark_healthy(sc->mp, sc->sick_mask);
break;
default:
diff --git a/fs/xfs/xfs_health.c b/fs/xfs/xfs_health.c
index 9cf933a8f532..3ef91601bc2b 100644
--- a/fs/xfs/xfs_health.c
+++ b/fs/xfs/xfs_health.c
@@ -98,6 +98,18 @@ xfs_fs_mark_sick(
spin_lock(&mp->m_sb_lock);
mp->m_fs_sick |= mask;
+ spin_unlock(&mp->m_sb_lock);
+}
+
+/* Mark per-fs metadata as having been checked. */
+void
+xfs_fs_mark_checked(
+ struct xfs_mount *mp,
+ unsigned int mask)
+{
+ ASSERT(!(mask & ~XFS_SICK_FS_PRIMARY));
+
+ spin_lock(&mp->m_sb_lock);
mp->m_fs_checked |= mask;
spin_unlock(&mp->m_sb_lock);
}
@@ -141,6 +153,19 @@ xfs_rt_mark_sick(
spin_lock(&mp->m_sb_lock);
mp->m_rt_sick |= mask;
+ spin_unlock(&mp->m_sb_lock);
+}
+
+/* Mark realtime metadata as having been checked. */
+void
+xfs_rt_mark_checked(
+ struct xfs_mount *mp,
+ unsigned int mask)
+{
+ ASSERT(!(mask & ~XFS_SICK_RT_PRIMARY));
+ trace_xfs_rt_mark_sick(mp, mask);
+
+ spin_lock(&mp->m_sb_lock);
mp->m_rt_checked |= mask;
spin_unlock(&mp->m_sb_lock);
}
@@ -184,6 +209,18 @@ xfs_ag_mark_sick(
spin_lock(&pag->pag_state_lock);
pag->pag_sick |= mask;
+ spin_unlock(&pag->pag_state_lock);
+}
+
+/* Mark per-ag metadata as having been checked. */
+void
+xfs_ag_mark_checked(
+ struct xfs_perag *pag,
+ unsigned int mask)
+{
+ ASSERT(!(mask & ~XFS_SICK_AG_PRIMARY));
+
+ spin_lock(&pag->pag_state_lock);
pag->pag_checked |= mask;
spin_unlock(&pag->pag_state_lock);
}
@@ -227,7 +264,6 @@ xfs_inode_mark_sick(
spin_lock(&ip->i_flags_lock);
ip->i_sick |= mask;
- ip->i_checked |= mask;
spin_unlock(&ip->i_flags_lock);
/*
@@ -240,6 +276,19 @@ xfs_inode_mark_sick(
spin_unlock(&VFS_I(ip)->i_lock);
}
+/* Mark inode metadata as having been checked. */
+void
+xfs_inode_mark_checked(
+ struct xfs_inode *ip,
+ unsigned int mask)
+{
+ ASSERT(!(mask & ~XFS_SICK_INO_PRIMARY));
+
+ spin_lock(&ip->i_flags_lock);
+ ip->i_checked |= mask;
+ spin_unlock(&ip->i_flags_lock);
+}
+
/* Mark parts of an inode healed. */
void
xfs_inode_mark_healthy(
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
index e665adbb0ae3..c7bba1662914 100644
--- a/fs/xfs/xfs_mount.c
+++ b/fs/xfs/xfs_mount.c
@@ -494,8 +494,10 @@ xfs_check_summary_counts(
if (xfs_is_clean(mp) &&
(mp->m_sb.sb_fdblocks > mp->m_sb.sb_dblocks ||
!xfs_verify_icount(mp, mp->m_sb.sb_icount) ||
- mp->m_sb.sb_ifree > mp->m_sb.sb_icount))
+ mp->m_sb.sb_ifree > mp->m_sb.sb_icount)) {
xfs_fs_mark_sick(mp, XFS_SICK_FS_COUNTERS);
+ xfs_fs_mark_checked(mp, XFS_SICK_FS_COUNTERS);
+ }
/*
* We can safely re-initialise incore superblock counters from the
@@ -1254,6 +1256,7 @@ xfs_force_summary_recalc(
return;
xfs_fs_mark_sick(mp, XFS_SICK_FS_COUNTERS);
+ xfs_fs_mark_checked(mp, XFS_SICK_FS_COUNTERS);
}
/*