fs/xfs/xfs_health.c
Source file repositories/reference/linux-study-clean/fs/xfs/xfs_health.c
File Facts
- System
- Linux kernel
- Corpus path
fs/xfs/xfs_health.c- Extension
.c- Size
- 17729 bytes
- Lines
- 745
- Domain
- Core OS
- Bucket
- VFS And Filesystem Core
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
xfs_platform.hxfs_fs.hxfs_shared.hxfs_format.hxfs_log_format.hxfs_trans_resv.hxfs_mount.hxfs_inode.hxfs_trace.hxfs_health.hxfs_ag.hxfs_btree.hxfs_da_format.hxfs_da_btree.hxfs_quota_defs.hxfs_rtgroup.hxfs_healthmon.hlinux/fserror.h
Detected Declarations
struct ioctl_sick_mapfunction Copyrightfunction xfs_health_unmountfunction xfs_fs_mark_sickfunction xfs_fs_mark_corruptfunction xfs_fs_mark_healthyfunction xfs_fs_measure_sicknessfunction xfs_agno_mark_sickfunction xfs_group_check_maskfunction xfs_group_mark_sickfunction xfs_group_mark_corruptfunction xfs_group_mark_healthyfunction xfs_group_measure_sicknessfunction xfs_rgno_mark_sickfunction xfs_inode_report_fserrorfunction xfs_inode_mark_sickfunction xfs_inode_mark_corruptfunction xfs_inode_mark_healthyfunction xfs_inode_measure_sicknessfunction xfgeo_health_tickfunction xfs_fsop_geom_healthfunction xfs_healthmon_fs_maskfunction for_each_sick_mapfunction xfs_ag_geom_healthfunction xfs_healthmon_perag_maskfunction for_each_sick_mapfunction xfs_rtgroup_geom_healthfunction xfs_healthmon_rtgroup_maskfunction for_each_sick_mapfunction xfs_bulkstat_healthfunction xfs_healthmon_inode_maskfunction for_each_sick_mapfunction xfs_bmap_mark_sickfunction xfs_btree_mark_sickfunction xfs_dirattr_mark_sickfunction xfs_da_mark_sick
Annotated Snippet
struct ioctl_sick_map {
unsigned int sick_mask;
unsigned int ioctl_mask;
};
#define for_each_sick_map(map, m) \
for ((m) = (map); (m) < (map) + ARRAY_SIZE(map); (m)++)
static const struct ioctl_sick_map fs_map[] = {
{ XFS_SICK_FS_COUNTERS, XFS_FSOP_GEOM_SICK_COUNTERS},
{ XFS_SICK_FS_UQUOTA, XFS_FSOP_GEOM_SICK_UQUOTA },
{ XFS_SICK_FS_GQUOTA, XFS_FSOP_GEOM_SICK_GQUOTA },
{ XFS_SICK_FS_PQUOTA, XFS_FSOP_GEOM_SICK_PQUOTA },
{ XFS_SICK_FS_QUOTACHECK, XFS_FSOP_GEOM_SICK_QUOTACHECK },
{ XFS_SICK_FS_NLINKS, XFS_FSOP_GEOM_SICK_NLINKS },
{ XFS_SICK_FS_METADIR, XFS_FSOP_GEOM_SICK_METADIR },
{ XFS_SICK_FS_METAPATH, XFS_FSOP_GEOM_SICK_METAPATH },
};
static const struct ioctl_sick_map rt_map[] = {
{ XFS_SICK_RG_BITMAP, XFS_FSOP_GEOM_SICK_RT_BITMAP },
{ XFS_SICK_RG_SUMMARY, XFS_FSOP_GEOM_SICK_RT_SUMMARY },
};
static inline void
xfgeo_health_tick(
struct xfs_fsop_geom *geo,
unsigned int sick,
unsigned int checked,
const struct ioctl_sick_map *m)
{
if (checked & m->sick_mask)
geo->checked |= m->ioctl_mask;
if (sick & m->sick_mask)
geo->sick |= m->ioctl_mask;
}
/* Fill out fs geometry health info. */
void
xfs_fsop_geom_health(
struct xfs_mount *mp,
struct xfs_fsop_geom *geo)
{
struct xfs_rtgroup *rtg = NULL;
const struct ioctl_sick_map *m;
unsigned int sick;
unsigned int checked;
geo->sick = 0;
geo->checked = 0;
xfs_fs_measure_sickness(mp, &sick, &checked);
for_each_sick_map(fs_map, m)
xfgeo_health_tick(geo, sick, checked, m);
while ((rtg = xfs_rtgroup_next(mp, rtg))) {
xfs_group_measure_sickness(rtg_group(rtg), &sick, &checked);
for_each_sick_map(rt_map, m)
xfgeo_health_tick(geo, sick, checked, m);
}
}
/*
* Translate XFS_SICK_FS_* into XFS_FSOP_GEOM_SICK_* except for the rt free
* space codes, which are sent via the rtgroup events.
*/
unsigned int
xfs_healthmon_fs_mask(
unsigned int sick_mask)
{
const struct ioctl_sick_map *m;
unsigned int ioctl_mask = 0;
for_each_sick_map(fs_map, m) {
if (sick_mask & m->sick_mask)
ioctl_mask |= m->ioctl_mask;
}
return ioctl_mask;
}
static const struct ioctl_sick_map ag_map[] = {
{ XFS_SICK_AG_SB, XFS_AG_GEOM_SICK_SB },
{ XFS_SICK_AG_AGF, XFS_AG_GEOM_SICK_AGF },
{ XFS_SICK_AG_AGFL, XFS_AG_GEOM_SICK_AGFL },
{ XFS_SICK_AG_AGI, XFS_AG_GEOM_SICK_AGI },
{ XFS_SICK_AG_BNOBT, XFS_AG_GEOM_SICK_BNOBT },
{ XFS_SICK_AG_CNTBT, XFS_AG_GEOM_SICK_CNTBT },
{ XFS_SICK_AG_INOBT, XFS_AG_GEOM_SICK_INOBT },
{ XFS_SICK_AG_FINOBT, XFS_AG_GEOM_SICK_FINOBT },
Annotation
- Immediate include surface: `xfs_platform.h`, `xfs_fs.h`, `xfs_shared.h`, `xfs_format.h`, `xfs_log_format.h`, `xfs_trans_resv.h`, `xfs_mount.h`, `xfs_inode.h`.
- Detected declarations: `struct ioctl_sick_map`, `function Copyright`, `function xfs_health_unmount`, `function xfs_fs_mark_sick`, `function xfs_fs_mark_corrupt`, `function xfs_fs_mark_healthy`, `function xfs_fs_measure_sickness`, `function xfs_agno_mark_sick`, `function xfs_group_check_mask`, `function xfs_group_mark_sick`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.