fs/xfs/xfs_notify_failure.c
Source file repositories/reference/linux-study-clean/fs/xfs/xfs_notify_failure.c
File Facts
- System
- Linux kernel
- Corpus path
fs/xfs/xfs_notify_failure.c- Extension
.c- Size
- 9996 bytes
- Lines
- 398
- 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.
- 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_alloc.hxfs_bit.hxfs_btree.hxfs_inode.hxfs_icache.hxfs_rmap.hxfs_rmap_btree.hxfs_rtalloc.hxfs_trans.hxfs_ag.hxfs_notify_failure.hxfs_rtgroup.hxfs_rtrmap_btree.hxfs_healthmon.hlinux/mm.hlinux/dax.hlinux/fs.hlinux/fserror.h
Detected Declarations
struct xfs_failure_infofunction xfs_failure_pgofffunction xfs_failure_pgcntfunction xfs_dax_failure_fnfunction xfs_dax_notify_failure_freezefunction xfs_dax_notify_failure_thawfunction xfs_dax_translate_rangefunction xfs_dax_notify_logdev_failurefunction xfs_dax_notify_dev_failurefunction xfs_dax_notify_failure
Annotated Snippet
struct xfs_failure_info {
xfs_agblock_t startblock;
xfs_extlen_t blockcount;
int mf_flags;
bool want_shutdown;
};
static pgoff_t
xfs_failure_pgoff(
struct xfs_mount *mp,
const struct xfs_rmap_irec *rec,
const struct xfs_failure_info *notify)
{
loff_t pos = XFS_FSB_TO_B(mp, rec->rm_offset);
if (notify->startblock > rec->rm_startblock)
pos += XFS_FSB_TO_B(mp,
notify->startblock - rec->rm_startblock);
return pos >> PAGE_SHIFT;
}
static unsigned long
xfs_failure_pgcnt(
struct xfs_mount *mp,
const struct xfs_rmap_irec *rec,
const struct xfs_failure_info *notify)
{
xfs_agblock_t end_rec;
xfs_agblock_t end_notify;
xfs_agblock_t start_cross;
xfs_agblock_t end_cross;
start_cross = max(rec->rm_startblock, notify->startblock);
end_rec = rec->rm_startblock + rec->rm_blockcount;
end_notify = notify->startblock + notify->blockcount;
end_cross = min(end_rec, end_notify);
return XFS_FSB_TO_B(mp, end_cross - start_cross) >> PAGE_SHIFT;
}
static int
xfs_dax_failure_fn(
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_failure_info *notify = data;
struct address_space *mapping;
pgoff_t pgoff;
unsigned long pgcnt;
int error = 0;
if (XFS_RMAP_NON_INODE_OWNER(rec->rm_owner) ||
(rec->rm_flags & (XFS_RMAP_ATTR_FORK | XFS_RMAP_BMBT_BLOCK))) {
/* Continue the query because this isn't a failure. */
if (notify->mf_flags & MF_MEM_PRE_REMOVE)
return 0;
notify->want_shutdown = true;
return 0;
}
/* Get files that incore, filter out others that are not in use. */
error = xfs_iget(mp, cur->bc_tp, rec->rm_owner, XFS_IGET_INCORE,
0, &ip);
/* Continue the rmap query if the inode isn't incore */
if (error == -ENODATA)
return 0;
if (error) {
notify->want_shutdown = true;
return 0;
}
mapping = VFS_I(ip)->i_mapping;
pgoff = xfs_failure_pgoff(mp, rec, notify);
pgcnt = xfs_failure_pgcnt(mp, rec, notify);
/* Continue the rmap query if the inode isn't a dax file. */
if (dax_mapping(mapping))
error = mf_dax_kill_procs(mapping, pgoff, pgcnt,
notify->mf_flags);
/* Invalidate the cache in dax pages. */
if (notify->mf_flags & MF_MEM_PRE_REMOVE)
invalidate_inode_pages2_range(mapping, pgoff,
pgoff + pgcnt - 1);
fserror_report_data_lost(VFS_I(ip), (u64)pgoff << PAGE_SHIFT,
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_alloc.h`, `xfs_bit.h`.
- Detected declarations: `struct xfs_failure_info`, `function xfs_failure_pgoff`, `function xfs_failure_pgcnt`, `function xfs_dax_failure_fn`, `function xfs_dax_notify_failure_freeze`, `function xfs_dax_notify_failure_thaw`, `function xfs_dax_translate_range`, `function xfs_dax_notify_logdev_failure`, `function xfs_dax_notify_dev_failure`, `function xfs_dax_notify_failure`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: source implementation candidate.
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.