fs/ntfs/iomap.c
Source file repositories/reference/linux-study-clean/fs/ntfs/iomap.c
File Facts
- System
- Linux kernel
- Corpus path
fs/ntfs/iomap.c- Extension
.c- Size
- 22351 bytes
- Lines
- 820
- 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
linux/writeback.hattrib.hmft.hntfs.hiomap.h
Detected Declarations
function Copyrightfunction ntfs_iomap_put_foliofunction ntfs_read_iomap_begin_residentfunction i_sizefunction __ntfs_read_iomap_beginfunction ntfs_read_iomap_beginfunction iomap_zero_rangefunction ntfs_seek_iomap_beginfunction ntfs_zero_read_iomap_endfunction ntfs_dio_zero_rangefunction ntfs_zero_rangefunction ntfs_write_simple_iomap_begin_non_residentfunction ntfs_write_da_iomap_begin_non_residentfunction ntfs_write_iomap_begin_residentfunction ntfs_write_iomap_begin_non_residentfunction __ntfs_write_iomap_beginfunction ntfs_write_iomap_beginfunction ntfs_write_iomap_end_residentfunction ntfs_write_iomap_endfunction ntfs_page_mkwrite_iomap_beginfunction ntfs_dio_iomap_beginfunction ntfs_writeback_range
Annotated Snippet
if (init < pos) {
loff_t offset = offset_in_folio(folio, pos + len);
if (offset == 0)
offset = folio_size(folio);
folio_zero_segments(folio,
offset_in_folio(folio, init),
offset_in_folio(folio, pos),
offset,
folio_size(folio));
} else {
loff_t offset = max_t(loff_t, pos + len, init);
offset = offset_in_folio(folio, offset);
if (offset == 0)
offset = folio_size(folio);
folio_zero_segment(folio,
offset,
folio_size(folio));
}
} else if (init <= pos) {
loff_t offset = 0, offset2 = offset_in_folio(folio, pos + len);
if ((init >> folio_shift(folio)) == (pos >> folio_shift(folio)))
offset = offset_in_folio(folio, init);
if (offset2 == 0)
offset2 = folio_size(folio);
folio_zero_segments(folio,
offset,
offset_in_folio(folio, pos),
offset2,
folio_size(folio));
}
folio_unlock(folio);
folio_put(folio);
}
/*
* iomap_zero_range is called for an area beyond the initialized size,
* garbage values can be read, so zeroing out is needed.
*/
static void ntfs_iomap_put_folio(struct inode *inode, loff_t pos,
unsigned int len, struct folio *folio)
{
if (NInoNonResident(NTFS_I(inode)))
return ntfs_iomap_put_folio_non_resident(inode, pos,
len, folio);
folio_unlock(folio);
folio_put(folio);
}
const struct iomap_write_ops ntfs_iomap_folio_ops = {
.put_folio = ntfs_iomap_put_folio,
};
static int ntfs_read_iomap_begin_resident(struct inode *inode, loff_t offset, loff_t length,
unsigned int flags, struct iomap *iomap)
{
struct ntfs_inode *base_ni, *ni = NTFS_I(inode);
struct ntfs_attr_search_ctx *ctx;
loff_t i_size;
u32 attr_len;
int err = 0;
char *kattr;
if (NInoAttr(ni))
base_ni = ni->ext.base_ntfs_ino;
else
base_ni = ni;
ctx = ntfs_attr_get_search_ctx(base_ni, NULL);
if (!ctx) {
err = -ENOMEM;
goto out;
}
err = ntfs_attr_lookup(ni->type, ni->name, ni->name_len,
CASE_SENSITIVE, 0, NULL, 0, ctx);
if (unlikely(err))
goto out;
attr_len = le32_to_cpu(ctx->attr->data.resident.value_length);
if (unlikely(attr_len > ni->initialized_size))
attr_len = ni->initialized_size;
i_size = i_size_read(inode);
if (unlikely(attr_len > i_size)) {
/* Race with shrinking truncate. */
attr_len = i_size;
Annotation
- Immediate include surface: `linux/writeback.h`, `attrib.h`, `mft.h`, `ntfs.h`, `iomap.h`.
- Detected declarations: `function Copyright`, `function ntfs_iomap_put_folio`, `function ntfs_read_iomap_begin_resident`, `function i_size`, `function __ntfs_read_iomap_begin`, `function ntfs_read_iomap_begin`, `function iomap_zero_range`, `function ntfs_seek_iomap_begin`, `function ntfs_zero_read_iomap_end`, `function ntfs_dio_zero_range`.
- 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.