include/linux/iomap.h
Source file repositories/reference/linux-study-clean/include/linux/iomap.h
File Facts
- System
- Linux kernel
- Corpus path
include/linux/iomap.h- Extension
.h- Size
- 22238 bytes
- Lines
- 652
- Domain
- Core OS
- Bucket
- Core Kernel Interface
- 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
linux/atomic.hlinux/bitmap.hlinux/blk_types.hlinux/mm.hlinux/types.hlinux/mm_types.hlinux/blkdev.hlinux/folio_batch.h
Detected Declarations
struct address_spacestruct fiemap_extent_infostruct inodestruct iomap_iterstruct iomap_diostruct iomap_writepage_ctxstruct iomap_read_folio_ctxstruct iov_iterstruct kiocbstruct pagestruct vm_area_structstruct vm_faultstruct iomapstruct iomap_write_opsstruct iomap_opsstruct iomap_iterstruct iomap_ioendstruct iomap_writeback_opsstruct iomap_writepage_ctxstruct iomap_read_folio_ctxstruct iomap_read_opsstruct iomap_dio_opsstruct filestruct swap_info_structfunction iomap_sectorfunction iomap_length_trimfunction iomap_lengthfunction iomap_iter_advance_fullfunction iomap_last_written_blockfunction iomap_want_unshare_iterfunction iomap_bio_read_foliofunction iomap_bio_readahead
Annotated Snippet
struct iomap {
u64 addr; /* disk offset of mapping, bytes */
loff_t offset; /* file offset of mapping, bytes */
u64 length; /* length of mapping, bytes */
u16 type; /* type of mapping */
u16 flags; /* flags for mapping */
struct block_device *bdev; /* block device for I/O */
struct dax_device *dax_dev; /* dax_dev for dax operations */
void *inline_data;
void *private; /* filesystem private */
u64 validity_cookie; /* used with .iomap_valid() */
};
static inline sector_t iomap_sector(const struct iomap *iomap, loff_t pos)
{
if (iomap->flags & IOMAP_F_ANON_WRITE)
return U64_MAX; /* invalid */
return (iomap->addr + pos - iomap->offset) >> SECTOR_SHIFT;
}
/*
* Returns the inline data pointer for logical offset @pos.
*/
static inline void *iomap_inline_data(const struct iomap *iomap, loff_t pos)
{
return iomap->inline_data + pos - iomap->offset;
}
/*
* When get_folio succeeds, put_folio will always be called to do any
* cleanup work necessary. put_folio is responsible for unlocking and putting
* @folio.
*/
struct iomap_write_ops {
struct folio *(*get_folio)(struct iomap_iter *iter, loff_t pos,
unsigned len);
void (*put_folio)(struct inode *inode, loff_t pos, unsigned copied,
struct folio *folio);
/*
* Check that the cached iomap still maps correctly to the filesystem's
* internal extent map. FS internal extent maps can change while iomap
* is iterating a cached iomap, so this hook allows iomap to detect that
* the iomap needs to be refreshed during a long running write
* operation.
*
* The filesystem can store internal state (e.g. a sequence number) in
* iomap->validity_cookie when the iomap is first mapped to be able to
* detect changes between mapping time and whenever .iomap_valid() is
* called.
*
* This is called with the folio over the specified file position held
* locked by the iomap code.
*/
bool (*iomap_valid)(struct inode *inode, const struct iomap *iomap);
/*
* Optional if the filesystem wishes to provide a custom handler for
* reading in the contents of a folio, otherwise iomap will default to
* submitting a bio read request.
*
* The read must be done synchronously.
*/
int (*read_folio_range)(const struct iomap_iter *iter,
struct folio *folio, loff_t pos, size_t len);
};
/*
* Flags for iomap_begin / iomap_end. No flag implies a read.
*/
#define IOMAP_WRITE (1 << 0) /* writing, must allocate blocks */
#define IOMAP_ZERO (1 << 1) /* zeroing operation, may skip holes */
#define IOMAP_REPORT (1 << 2) /* report extent status, e.g. FIEMAP */
#define IOMAP_FAULT (1 << 3) /* mapping for page fault */
#define IOMAP_DIRECT (1 << 4) /* direct I/O */
#define IOMAP_NOWAIT (1 << 5) /* do not block */
#define IOMAP_OVERWRITE_ONLY (1 << 6) /* only pure overwrites allowed */
#define IOMAP_UNSHARE (1 << 7) /* unshare_file_range */
#ifdef CONFIG_FS_DAX
#define IOMAP_DAX (1 << 8) /* DAX mapping */
#else
#define IOMAP_DAX 0
#endif /* CONFIG_FS_DAX */
#define IOMAP_ATOMIC (1 << 9) /* torn-write protection */
#define IOMAP_DONTCACHE (1 << 10)
struct iomap_ops {
/*
* Return the existing mapping at pos, or reserve space starting at
* pos for up to length, as long as we can do it as a single mapping.
Annotation
- Immediate include surface: `linux/atomic.h`, `linux/bitmap.h`, `linux/blk_types.h`, `linux/mm.h`, `linux/types.h`, `linux/mm_types.h`, `linux/blkdev.h`, `linux/folio_batch.h`.
- Detected declarations: `struct address_space`, `struct fiemap_extent_info`, `struct inode`, `struct iomap_iter`, `struct iomap_dio`, `struct iomap_writepage_ctx`, `struct iomap_read_folio_ctx`, `struct iov_iter`, `struct kiocb`, `struct page`.
- Atlas domain: Core OS / Core Kernel Interface.
- 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.