fs/erofs/fscache.c
Source file repositories/reference/linux-study-clean/fs/erofs/fscache.c
File Facts
- System
- Linux kernel
- Corpus path
fs/erofs/fscache.c- Extension
.c- Size
- 16593 bytes
- Lines
- 665
- 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/fscache.hinternal.h
Detected Declarations
struct erofs_fscache_iostruct erofs_fscache_rqstruct erofs_fscache_biofunction erofs_fscache_io_putfunction erofs_fscache_req_completefunction erofs_fscache_req_putfunction erofs_fscache_req_io_putfunction erofs_fscache_req_end_iofunction erofs_fscache_read_io_asyncfunction erofs_fscache_bio_endiofunction erofs_fscache_submit_biofunction erofs_fscache_meta_read_foliofunction erofs_fscache_data_read_slicefunction erofs_fscache_data_readfunction erofs_fscache_read_foliofunction erofs_fscache_readaheadfunction erofs_fscache_domain_putfunction erofs_fscache_register_volumefunction erofs_fscache_init_domainfunction erofs_fscache_register_domainfunction erofs_fscache_relinquish_cookiefunction erofs_fscache_unregister_cookiefunction erofs_fscache_register_fsfunction erofs_fscache_unregister_fs
Annotated Snippet
struct erofs_fscache_io {
struct netfs_cache_resources cres;
struct iov_iter iter;
netfs_io_terminated_t end_io;
void *private;
refcount_t ref;
};
struct erofs_fscache_rq {
struct address_space *mapping; /* The mapping being accessed */
loff_t start; /* Start position */
size_t len; /* Length of the request */
size_t submitted; /* Length of submitted */
short error; /* 0 or error that occurred */
refcount_t ref;
};
static bool erofs_fscache_io_put(struct erofs_fscache_io *io)
{
if (!refcount_dec_and_test(&io->ref))
return false;
if (io->cres.ops)
io->cres.ops->end_operation(&io->cres);
kfree(io);
return true;
}
static void erofs_fscache_req_complete(struct erofs_fscache_rq *req)
{
struct folio *folio;
bool failed = req->error;
pgoff_t start_page = req->start / PAGE_SIZE;
pgoff_t last_page = ((req->start + req->len) / PAGE_SIZE) - 1;
XA_STATE(xas, &req->mapping->i_pages, start_page);
rcu_read_lock();
xas_for_each(&xas, folio, last_page) {
if (xas_retry(&xas, folio))
continue;
if (!failed)
folio_mark_uptodate(folio);
folio_unlock(folio);
}
rcu_read_unlock();
}
static void erofs_fscache_req_put(struct erofs_fscache_rq *req)
{
if (!refcount_dec_and_test(&req->ref))
return;
erofs_fscache_req_complete(req);
kfree(req);
}
static struct erofs_fscache_rq *erofs_fscache_req_alloc(struct address_space *mapping,
loff_t start, size_t len)
{
struct erofs_fscache_rq *req = kzalloc_obj(*req);
if (!req)
return NULL;
req->mapping = mapping;
req->start = start;
req->len = len;
refcount_set(&req->ref, 1);
return req;
}
static void erofs_fscache_req_io_put(struct erofs_fscache_io *io)
{
struct erofs_fscache_rq *req = io->private;
if (erofs_fscache_io_put(io))
erofs_fscache_req_put(req);
}
static void erofs_fscache_req_end_io(void *priv, ssize_t transferred_or_error)
{
struct erofs_fscache_io *io = priv;
struct erofs_fscache_rq *req = io->private;
if (IS_ERR_VALUE(transferred_or_error))
req->error = transferred_or_error;
erofs_fscache_req_io_put(io);
}
static struct erofs_fscache_io *erofs_fscache_req_io_alloc(struct erofs_fscache_rq *req)
{
struct erofs_fscache_io *io = kzalloc_obj(*io);
Annotation
- Immediate include surface: `linux/fscache.h`, `internal.h`.
- Detected declarations: `struct erofs_fscache_io`, `struct erofs_fscache_rq`, `struct erofs_fscache_bio`, `function erofs_fscache_io_put`, `function erofs_fscache_req_complete`, `function erofs_fscache_req_put`, `function erofs_fscache_req_io_put`, `function erofs_fscache_req_end_io`, `function erofs_fscache_read_io_async`, `function erofs_fscache_bio_endio`.
- 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.