fs/squashfs/block.c
Source file repositories/reference/linux-study-clean/fs/squashfs/block.c
File Facts
- System
- Linux kernel
- Corpus path
fs/squashfs/block.c- Extension
.c- Size
- 9458 bytes
- Lines
- 387
- 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.hlinux/fs.hlinux/vfs.hlinux/slab.hlinux/pagemap.hlinux/string.hlinux/bio.hsquashfs_fs.hsquashfs_fs_sb.hsquashfs.hdecompressor.hpage_actor.h
Detected Declarations
function Copyrightfunction squashfs_bio_read_cachedfunction bio_for_each_folio_allfunction squashfs_bio_readfunction read
Annotated Snippet
if (actor_offset >= PAGE_SIZE) {
actor_addr = squashfs_next_page(actor);
if (!actor_addr)
break;
actor_offset = 0;
}
if (offset >= bvec->bv_len) {
if (!bio_next_segment(bio, &iter_all))
break;
offset = 0;
}
}
squashfs_finish_page(actor);
return copied_bytes;
}
static int squashfs_bio_read_cached(struct bio *fullbio,
struct address_space *cache_mapping, u64 index, int length,
u64 read_start, u64 read_end, int page_count)
{
struct folio *head_to_cache = NULL, *tail_to_cache = NULL;
struct block_device *bdev = fullbio->bi_bdev;
int start_idx = 0, end_idx = 0;
struct folio_iter fi;
struct bio *bio = NULL;
int idx = 0;
int err = 0;
#ifdef CONFIG_SQUASHFS_COMP_CACHE_FULL
struct folio **cache_folios = kmalloc_objs(*cache_folios, page_count,
GFP_KERNEL | __GFP_ZERO);
#endif
bio_for_each_folio_all(fi, fullbio) {
struct folio *folio = fi.folio;
if (folio->mapping == cache_mapping) {
idx++;
continue;
}
/*
* We only use this when the device block size is the same as
* the page size, so read_start and read_end cover full pages.
*
* Compare these to the original required index and length to
* only cache pages which were requested partially, since these
* are the ones which are likely to be needed when reading
* adjacent blocks.
*/
if (idx == 0 && index != read_start)
head_to_cache = folio;
else if (idx == page_count - 1 && index + length != read_end)
tail_to_cache = folio;
#ifdef CONFIG_SQUASHFS_COMP_CACHE_FULL
/* Cache all pages in the BIO for repeated reads */
else if (cache_folios)
cache_folios[idx] = folio;
#endif
if (!bio || idx != end_idx) {
struct bio *new = bio_alloc_clone(bdev, fullbio,
GFP_NOIO, &fs_bio_set);
if (bio) {
bio_trim(bio, start_idx * PAGE_SECTORS,
(end_idx - start_idx) * PAGE_SECTORS);
bio_chain(bio, new);
submit_bio(bio);
}
bio = new;
start_idx = idx;
}
idx++;
end_idx = idx;
}
if (bio) {
bio_trim(bio, start_idx * PAGE_SECTORS,
(end_idx - start_idx) * PAGE_SECTORS);
err = submit_bio_wait(bio);
bio_put(bio);
}
if (err)
return err;
if (head_to_cache) {
int ret = filemap_add_folio(cache_mapping, head_to_cache,
Annotation
- Immediate include surface: `linux/blkdev.h`, `linux/fs.h`, `linux/vfs.h`, `linux/slab.h`, `linux/pagemap.h`, `linux/string.h`, `linux/bio.h`, `squashfs_fs.h`.
- Detected declarations: `function Copyright`, `function squashfs_bio_read_cached`, `function bio_for_each_folio_all`, `function squashfs_bio_read`, `function read`.
- 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.