fs/hpfs/buffer.c
Source file repositories/reference/linux-study-clean/fs/hpfs/buffer.c
File Facts
- System
- Linux kernel
- Corpus path
fs/hpfs/buffer.c- Extension
.c- Size
- 5441 bytes
- Lines
- 233
- 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/sched.hlinux/slab.hlinux/blkdev.hhpfs_fn.h
Detected Declarations
function Patockafunction hpfs_search_hotfix_map_for_rangefunction hpfs_prefetch_sectorsfunction hpfs_brelse4function hpfs_mark_4buffers_dirty
Annotated Snippet
if (sbi->hotfix_from[i] == sec) {
return sbi->hotfix_to[i];
}
}
return sec;
}
unsigned hpfs_search_hotfix_map_for_range(struct super_block *s, secno sec, unsigned n)
{
unsigned i;
struct hpfs_sb_info *sbi = hpfs_sb(s);
for (i = 0; unlikely(i < sbi->n_hotfixes); i++) {
if (sbi->hotfix_from[i] >= sec && sbi->hotfix_from[i] < sec + n) {
n = sbi->hotfix_from[i] - sec;
}
}
return n;
}
void hpfs_prefetch_sectors(struct super_block *s, unsigned secno, int n)
{
struct buffer_head *bh;
struct blk_plug plug;
if (n <= 0 || unlikely(secno >= hpfs_sb(s)->sb_fs_size))
return;
if (unlikely(hpfs_search_hotfix_map_for_range(s, secno, n) != n))
return;
bh = sb_find_get_block(s, secno);
if (bh) {
if (buffer_uptodate(bh)) {
brelse(bh);
return;
}
brelse(bh);
}
blk_start_plug(&plug);
while (n > 0) {
if (unlikely(secno >= hpfs_sb(s)->sb_fs_size))
break;
sb_breadahead(s, secno);
secno++;
n--;
}
blk_finish_plug(&plug);
}
/* Map a sector into a buffer and return pointers to it and to the buffer. */
void *hpfs_map_sector(struct super_block *s, unsigned secno, struct buffer_head **bhp,
int ahead)
{
struct buffer_head *bh;
hpfs_lock_assert(s);
hpfs_prefetch_sectors(s, secno, ahead);
cond_resched();
*bhp = bh = sb_bread(s, hpfs_search_hotfix_map(s, secno));
if (bh != NULL)
return bh->b_data;
else {
pr_err("%s(): read error\n", __func__);
return NULL;
}
}
/* Like hpfs_map_sector but don't read anything */
void *hpfs_get_sector(struct super_block *s, unsigned secno, struct buffer_head **bhp)
{
struct buffer_head *bh;
/*return hpfs_map_sector(s, secno, bhp, 0);*/
hpfs_lock_assert(s);
cond_resched();
if ((*bhp = bh = sb_getblk(s, hpfs_search_hotfix_map(s, secno))) != NULL) {
if (!buffer_uptodate(bh)) wait_on_buffer(bh);
set_buffer_uptodate(bh);
return bh->b_data;
} else {
pr_err("%s(): getblk failed\n", __func__);
return NULL;
Annotation
- Immediate include surface: `linux/sched.h`, `linux/slab.h`, `linux/blkdev.h`, `hpfs_fn.h`.
- Detected declarations: `function Patocka`, `function hpfs_search_hotfix_map_for_range`, `function hpfs_prefetch_sectors`, `function hpfs_brelse4`, `function hpfs_mark_4buffers_dirty`.
- 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.