fs/xfs/xfs_iomap.c
Source file repositories/reference/linux-study-clean/fs/xfs/xfs_iomap.c
File Facts
- System
- Linux kernel
- Corpus path
fs/xfs/xfs_iomap.c- Extension
.c- Size
- 67307 bytes
- Lines
- 2392
- 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_btree.hxfs_bmap_btree.hxfs_bmap.hxfs_bmap_util.hxfs_errortag.hxfs_error.hxfs_trans.hxfs_trans_space.hxfs_inode_item.hxfs_iomap.hxfs_trace.hxfs_quota.hxfs_rtgroup.hxfs_dquot_item.hxfs_dquot.hxfs_reflink.hxfs_health.hxfs_rtbitmap.hxfs_icache.hxfs_zone_alloc.h
Detected Declarations
function Copyrightfunction xfs_iomap_inode_sequencefunction xfs_iomap_validfunction xfs_bmbt_to_iomapfunction isnullstartblockfunction xfs_hole_to_iomapfunction xfs_iomap_end_fsbfunction xfs_eof_alignmentfunction xfs_iomap_eof_align_last_fsbfunction xfs_iomap_write_directfunction xfs_quota_need_throttlefunction xfs_quota_calc_throttlefunction xfs_iomap_freespfunction xfs_iomap_prealloc_sizefunction xfs_iomap_write_unwrittenfunction imap_needs_allocfunction imap_needs_cowfunction xfs_ilock_data_map_sharedfunction imap_spans_rangefunction xfs_bmap_hw_atomic_write_possiblefunction xfs_direct_write_iomap_beginfunction xfs_zoned_direct_write_iomap_beginfunction xfs_check_atomic_cow_conversionfunction xfs_atomic_write_cow_iomap_beginfunction xfs_dax_write_iomap_endfunction currentfunction xfs_bmapi_reserve_delallocfunction xfs_zoned_buffered_write_iomap_beginfunction xfs_buffered_write_iomap_beginfunction xfs_buffered_write_delalloc_punchfunction xfs_buffered_write_iomap_endfunction xfs_read_iomap_beginfunction xfs_seek_iomap_beginfunction xfs_xattr_iomap_beginfunction xfs_zero_rangefunction xfs_truncate_page
Annotated Snippet
xfs_iomap_inode_sequence(ip, iomap->flags)) {
trace_xfs_iomap_invalid(ip, iomap);
return false;
}
XFS_ERRORTAG_DELAY(ip->i_mount, XFS_ERRTAG_WRITE_DELAY_MS);
return true;
}
const struct iomap_write_ops xfs_iomap_write_ops = {
.iomap_valid = xfs_iomap_valid,
};
int
xfs_bmbt_to_iomap(
struct xfs_inode *ip,
struct iomap *iomap,
struct xfs_bmbt_irec *imap,
unsigned int mapping_flags,
u16 iomap_flags,
u64 sequence_cookie)
{
struct xfs_mount *mp = ip->i_mount;
struct xfs_buftarg *target = xfs_inode_buftarg(ip);
if (unlikely(!xfs_valid_startblock(ip, imap->br_startblock))) {
xfs_bmap_mark_sick(ip, XFS_DATA_FORK);
return xfs_alert_fsblock_zero(ip, imap);
}
iomap->flags = iomap_flags;
if (imap->br_startblock == HOLESTARTBLOCK) {
iomap->addr = IOMAP_NULL_ADDR;
iomap->type = IOMAP_HOLE;
} else if (imap->br_startblock == DELAYSTARTBLOCK ||
isnullstartblock(imap->br_startblock)) {
iomap->addr = IOMAP_NULL_ADDR;
iomap->type = IOMAP_DELALLOC;
} else {
xfs_daddr_t daddr = xfs_fsb_to_db(ip, imap->br_startblock);
iomap->addr = BBTOB(daddr);
if (mapping_flags & IOMAP_DAX)
iomap->addr += target->bt_dax_part_off;
if (imap->br_state == XFS_EXT_UNWRITTEN)
iomap->type = IOMAP_UNWRITTEN;
else
iomap->type = IOMAP_MAPPED;
/*
* Mark iomaps starting at the first sector of a RTG as merge
* boundary so that each I/O completions is contained to a
* single RTG.
*/
if (XFS_IS_REALTIME_INODE(ip) && xfs_has_rtgroups(mp) &&
xfs_rtbno_is_group_start(mp, imap->br_startblock))
iomap->flags |= IOMAP_F_BOUNDARY;
}
iomap->offset = XFS_FSB_TO_B(mp, imap->br_startoff);
iomap->length = XFS_FSB_TO_B(mp, imap->br_blockcount);
if (mapping_flags & IOMAP_DAX) {
iomap->dax_dev = target->bt_daxdev;
} else {
iomap->bdev = target->bt_bdev;
if (bdev_has_integrity_csum(iomap->bdev))
iomap->flags |= IOMAP_F_INTEGRITY;
}
/*
* If the inode is dirty for datasync purposes, let iomap know so it
* doesn't elide the IO completion journal flushes on O_DSYNC IO.
*/
if (ip->i_itemp) {
struct xfs_inode_log_item *iip = ip->i_itemp;
spin_lock(&iip->ili_lock);
if (iip->ili_datasync_seq)
iomap->flags |= IOMAP_F_DIRTY;
spin_unlock(&iip->ili_lock);
}
iomap->validity_cookie = sequence_cookie;
return 0;
}
static void
xfs_hole_to_iomap(
struct xfs_inode *ip,
struct iomap *iomap,
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: `function Copyright`, `function xfs_iomap_inode_sequence`, `function xfs_iomap_valid`, `function xfs_bmbt_to_iomap`, `function isnullstartblock`, `function xfs_hole_to_iomap`, `function xfs_iomap_end_fsb`, `function xfs_eof_alignment`, `function xfs_iomap_eof_align_last_fsb`, `function xfs_iomap_write_direct`.
- 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.