fs/xfs/xfs_verify_media.c
Source file repositories/reference/linux-study-clean/fs/xfs/xfs_verify_media.c
File Facts
- System
- Linux kernel
- Corpus path
fs/xfs/xfs_verify_media.c- Extension
.c- Size
- 10550 bytes
- Lines
- 444
- 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.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
xfs_platform.hxfs_shared.hxfs_format.hxfs_log_format.hxfs_trans_resv.hxfs_mount.hxfs_bit.hxfs_btree.hxfs_inode.hxfs_icache.hxfs_trans.hxfs_alloc.hxfs_ag.hxfs_rmap.hxfs_rmap_btree.hxfs_rtgroup.hxfs_rtrmap_btree.hxfs_health.hxfs_healthmon.hxfs_trace.hxfs_verify_media.hlinux/fserror.h
Detected Declarations
struct xfs_group_data_lostfunction xfs_verify_report_data_lostfunction xfs_verify_report_lossesfunction xfs_verify_iosizefunction xfs_verify_alloc_foliofunction xfs_verify_media_errorfunction xfs_verify_mediafunction xfs_ioc_verify_media
Annotated Snippet
struct xfs_group_data_lost {
xfs_agblock_t startblock;
xfs_extlen_t blockcount;
};
/* Report lost file data from rmap records */
static int
xfs_verify_report_data_lost(
struct xfs_btree_cur *cur,
const struct xfs_rmap_irec *rec,
void *data)
{
struct xfs_mount *mp = cur->bc_mp;
struct xfs_inode *ip;
struct xfs_group_data_lost *lost = data;
xfs_fileoff_t fileoff = rec->rm_offset;
xfs_extlen_t blocks = rec->rm_blockcount;
const bool is_attr =
(rec->rm_flags & XFS_RMAP_ATTR_FORK);
const xfs_agblock_t lost_end =
lost->startblock + lost->blockcount;
const xfs_agblock_t rmap_end =
rec->rm_startblock + rec->rm_blockcount;
int error = 0;
if (XFS_RMAP_NON_INODE_OWNER(rec->rm_owner))
return 0;
error = xfs_iget(mp, cur->bc_tp, rec->rm_owner, 0, 0, &ip);
if (error)
return 0;
if (rec->rm_flags & XFS_RMAP_BMBT_BLOCK) {
xfs_bmap_mark_sick(ip, is_attr ? XFS_ATTR_FORK : XFS_DATA_FORK);
goto out_rele;
}
if (is_attr) {
xfs_inode_mark_sick(ip, XFS_SICK_INO_XATTR);
goto out_rele;
}
if (lost->startblock > rec->rm_startblock) {
fileoff += lost->startblock - rec->rm_startblock;
blocks -= lost->startblock - rec->rm_startblock;
}
if (rmap_end > lost_end)
blocks -= rmap_end - lost_end;
fserror_report_data_lost(VFS_I(ip), XFS_FSB_TO_B(mp, fileoff),
XFS_FSB_TO_B(mp, blocks), GFP_NOFS);
out_rele:
xfs_irele(ip);
return 0;
}
/* Walk reverse mappings to look for all file data loss */
static int
xfs_verify_report_losses(
struct xfs_mount *mp,
enum xfs_group_type type,
xfs_daddr_t daddr,
u64 bblen)
{
struct xfs_group *xg = NULL;
struct xfs_trans *tp;
xfs_fsblock_t start_bno, end_bno;
uint32_t start_gno, end_gno;
int error;
if (type == XG_TYPE_RTG) {
start_bno = xfs_daddr_to_rtb(mp, daddr);
end_bno = xfs_daddr_to_rtb(mp, daddr + bblen - 1);
} else {
start_bno = XFS_DADDR_TO_FSB(mp, daddr);
end_bno = XFS_DADDR_TO_FSB(mp, daddr + bblen - 1);
}
tp = xfs_trans_alloc_empty(mp);
start_gno = xfs_fsb_to_gno(mp, start_bno, type);
end_gno = xfs_fsb_to_gno(mp, end_bno, type);
while ((xg = xfs_group_next_range(mp, xg, start_gno, end_gno, type))) {
struct xfs_buf *agf_bp = NULL;
struct xfs_rtgroup *rtg = NULL;
struct xfs_btree_cur *cur;
struct xfs_rmap_irec ri_low = { };
struct xfs_rmap_irec ri_high;
struct xfs_group_data_lost lost;
Annotation
- Immediate include surface: `xfs_platform.h`, `xfs_shared.h`, `xfs_format.h`, `xfs_log_format.h`, `xfs_trans_resv.h`, `xfs_mount.h`, `xfs_bit.h`, `xfs_btree.h`.
- Detected declarations: `struct xfs_group_data_lost`, `function xfs_verify_report_data_lost`, `function xfs_verify_report_losses`, `function xfs_verify_iosize`, `function xfs_verify_alloc_folio`, `function xfs_verify_media_error`, `function xfs_verify_media`, `function xfs_ioc_verify_media`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: source implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
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.