fs/xfs/xfs_aops.c
Source file repositories/reference/linux-study-clean/fs/xfs/xfs_aops.c
File Facts
- System
- Linux kernel
- Corpus path
fs/xfs/xfs_aops.c- Extension
.c- Size
- 25425 bytes
- Lines
- 875
- 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.
- 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_inode.hxfs_trans.hxfs_iomap.hxfs_trace.hxfs_bmap.hxfs_bmap_util.hxfs_reflink.hxfs_errortag.hxfs_error.hxfs_icache.hxfs_zone_alloc.hxfs_rtgroup.hlinux/bio-integrity.h
Detected Declarations
struct xfs_writepage_ctxstruct xfs_zoned_writepage_ctxfunction XFS_WPCfunction xfs_ioend_is_appendfunction xfs_setfilesizefunction xfs_ioend_put_open_zonesfunction xfs_end_ioend_writefunction xfs_end_iofunction xfs_end_biofunction reservationfunction xfs_imap_validfunction checkedfunction XFS_WPCfunction xfs_map_blocksfunction xfs_writeback_rangefunction xfs_ioend_needs_wq_completionfunction xfs_writeback_submitfunction XFS_ZWPCfunction xfs_zoned_map_blocksfunction xfs_zoned_writeback_rangefunction xfs_zoned_writeback_submitfunction xfs_vm_writepagesfunction xfs_dax_writepagesfunction xfs_vm_bmapfunction xfs_bio_submit_readfunction xfs_get_iomap_read_opsfunction xfs_vm_read_foliofunction xfs_vm_readaheadfunction xfs_vm_swap_activate
Annotated Snippet
struct xfs_writepage_ctx {
struct iomap_writepage_ctx ctx;
unsigned int data_seq;
unsigned int cow_seq;
};
static inline struct xfs_writepage_ctx *
XFS_WPC(struct iomap_writepage_ctx *ctx)
{
return container_of(ctx, struct xfs_writepage_ctx, ctx);
}
/*
* Fast and loose check if this write could update the on-disk inode size.
*/
static inline bool xfs_ioend_is_append(struct iomap_ioend *ioend)
{
return ioend->io_offset + ioend->io_size >
XFS_I(ioend->io_inode)->i_disk_size;
}
/*
* Update on-disk file size now that data has been written to disk.
*/
int
xfs_setfilesize(
struct xfs_inode *ip,
xfs_off_t offset,
size_t size)
{
struct xfs_mount *mp = ip->i_mount;
struct xfs_trans *tp;
xfs_fsize_t isize;
int error;
error = xfs_trans_alloc(mp, &M_RES(mp)->tr_fsyncts, 0, 0, 0, &tp);
if (error)
return error;
xfs_ilock(ip, XFS_ILOCK_EXCL);
isize = xfs_new_eof(ip, offset + size);
if (!isize) {
xfs_iunlock(ip, XFS_ILOCK_EXCL);
xfs_trans_cancel(tp);
return 0;
}
trace_xfs_setfilesize(ip, offset, size);
ip->i_disk_size = isize;
xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
return xfs_trans_commit(tp);
}
static void
xfs_ioend_put_open_zones(
struct iomap_ioend *ioend)
{
struct iomap_ioend *tmp;
/*
* Put the open zone for all ioends merged into this one (if any).
*/
list_for_each_entry(tmp, &ioend->io_list, io_list)
xfs_open_zone_put(tmp->io_private);
/*
* The main ioend might not have an open zone if the submission failed
* before xfs_zone_alloc_and_submit got called.
*/
if (ioend->io_private)
xfs_open_zone_put(ioend->io_private);
}
/*
* IO write completion.
*/
STATIC void
xfs_end_ioend_write(
struct iomap_ioend *ioend)
{
struct xfs_inode *ip = XFS_I(ioend->io_inode);
struct xfs_mount *mp = ip->i_mount;
bool is_zoned = xfs_is_zoned_inode(ip);
xfs_off_t offset = ioend->io_offset;
size_t size = ioend->io_size;
unsigned int nofs_flag;
int error;
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_inode.h`, `xfs_trans.h`.
- Detected declarations: `struct xfs_writepage_ctx`, `struct xfs_zoned_writepage_ctx`, `function XFS_WPC`, `function xfs_ioend_is_append`, `function xfs_setfilesize`, `function xfs_ioend_put_open_zones`, `function xfs_end_ioend_write`, `function xfs_end_io`, `function xfs_end_bio`, `function reservation`.
- 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.