fs/ntfs/bdev-io.c
Source file repositories/reference/linux-study-clean/fs/ntfs/bdev-io.c
File Facts
- System
- Linux kernel
- Corpus path
fs/ntfs/bdev-io.c- Extension
.c- Size
- 3221 bytes
- Lines
- 121
- 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.
- 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/blkdev.hntfs.h
Detected Declarations
function Copyrightfunction ntfs_bdev_write
Annotated Snippet
if (!added) {
struct bio *prev = bio;
bio = bio_alloc(prev->bi_bdev,
bio_max_segs(DIV_ROUND_UP(size - done, PAGE_SIZE)),
prev->bi_opf, GFP_KERNEL);
bio->bi_iter.bi_sector = bio_end_sector(prev);
bio_chain(prev, bio);
submit_bio(prev);
}
done += added;
} while (done < size);
error = submit_bio_wait(bio);
bio_put(bio);
if (op == REQ_OP_READ)
invalidate_kernel_vmap_range(data, size);
return error;
}
/*
* ntfs_bdev_write - Update block device contents via page cache
* @sb: super block of the mounted NTFS filesystem
* @buf: source buffer containing data to write
* @start: starting byte offset on the block device
* @size: number of bytes to write
*
* Writes @size bytes from @buf to the block device (sb->s_bdev) starting
* at byte offset @start. The write is performed entirely through the page
* cache of the block device's address space.
*/
int ntfs_bdev_write(struct super_block *sb, void *buf, loff_t start, size_t size)
{
pgoff_t idx, idx_end;
loff_t offset, end = start + size;
u32 from, to, buf_off = 0;
struct folio *folio;
idx = start >> PAGE_SHIFT;
idx_end = end >> PAGE_SHIFT;
from = start & ~PAGE_MASK;
if (idx == idx_end)
idx_end++;
for (; idx < idx_end; idx++, from = 0) {
u32 len;
folio = read_mapping_folio(sb->s_bdev->bd_mapping, idx, NULL);
if (IS_ERR(folio)) {
ntfs_error(sb, "Unable to read %ld page", idx);
return PTR_ERR(folio);
}
offset = (loff_t)idx << PAGE_SHIFT;
to = min_t(u32, end - offset, PAGE_SIZE);
len = to - from;
memcpy_to_folio(folio, from, buf + buf_off, len);
buf_off += len;
folio_mark_uptodate(folio);
folio_mark_dirty(folio);
folio_put(folio);
}
return 0;
}
Annotation
- Immediate include surface: `linux/blkdev.h`, `ntfs.h`.
- Detected declarations: `function Copyright`, `function ntfs_bdev_write`.
- 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.