fs/netfs/fscache_io.c
Source file repositories/reference/linux-study-clean/fs/netfs/fscache_io.c
File Facts
- System
- Linux kernel
- Corpus path
fs/netfs/fscache_io.c- Extension
.c- Size
- 8032 bytes
- Lines
- 291
- Domain
- Core OS
- Bucket
- VFS And Filesystem Core
- Inferred role
- Core OS: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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-cache.hlinux/uio.hlinux/bvec.hlinux/slab.hinternal.h
Detected Declarations
struct fscache_write_requestfunction Copyrightfunction fscache_begin_operationfunction __fscache_begin_read_operationfunction __fscache_begin_write_operationfunction __fscache_clear_page_bitsfunction xas_for_eachfunction fscache_wreq_donefunction __fscache_write_to_cachefunction __fscache_resize_cookieexport fscache_wait_for_operationexport __fscache_begin_read_operationexport __fscache_begin_write_operationexport __fscache_clear_page_bitsexport __fscache_write_to_cacheexport __fscache_resize_cookie
Annotated Snippet
struct fscache_write_request {
struct netfs_cache_resources cache_resources;
struct address_space *mapping;
loff_t start;
size_t len;
bool set_bits;
bool using_pgpriv2;
netfs_io_terminated_t term_func;
void *term_func_priv;
};
void __fscache_clear_page_bits(struct address_space *mapping,
loff_t start, size_t len)
{
pgoff_t first = start / PAGE_SIZE;
pgoff_t last = (start + len - 1) / PAGE_SIZE;
struct page *page;
if (len) {
XA_STATE(xas, &mapping->i_pages, first);
rcu_read_lock();
xas_for_each(&xas, page, last) {
folio_end_private_2(page_folio(page));
}
rcu_read_unlock();
}
}
EXPORT_SYMBOL(__fscache_clear_page_bits);
/*
* Deal with the completion of writing the data to the cache.
*/
static void fscache_wreq_done(void *priv, ssize_t transferred_or_error)
{
struct fscache_write_request *wreq = priv;
if (wreq->using_pgpriv2)
fscache_clear_page_bits(wreq->mapping, wreq->start, wreq->len,
wreq->set_bits);
if (wreq->term_func)
wreq->term_func(wreq->term_func_priv, transferred_or_error);
fscache_end_operation(&wreq->cache_resources);
kfree(wreq);
}
void __fscache_write_to_cache(struct fscache_cookie *cookie,
struct address_space *mapping,
loff_t start, size_t len, loff_t i_size,
netfs_io_terminated_t term_func,
void *term_func_priv,
bool using_pgpriv2, bool cond)
{
struct fscache_write_request *wreq;
struct netfs_cache_resources *cres;
struct iov_iter iter;
int ret = -ENOBUFS;
if (len == 0)
goto abandon;
_enter("%llx,%zx", start, len);
wreq = kzalloc_obj(struct fscache_write_request, GFP_NOFS);
if (!wreq)
goto abandon;
wreq->mapping = mapping;
wreq->start = start;
wreq->len = len;
wreq->using_pgpriv2 = using_pgpriv2;
wreq->set_bits = cond;
wreq->term_func = term_func;
wreq->term_func_priv = term_func_priv;
cres = &wreq->cache_resources;
if (fscache_begin_operation(cres, cookie, FSCACHE_WANT_WRITE,
fscache_access_io_write) < 0)
goto abandon_free;
ret = cres->ops->prepare_write(cres, &start, &len, len, i_size, false);
if (ret < 0)
goto abandon_end;
/* TODO: Consider clearing page bits now for space the write isn't
* covering. This is more complicated than it appears when THPs are
* taken into account.
*/
iov_iter_xarray(&iter, ITER_SOURCE, &mapping->i_pages, start, len);
Annotation
- Immediate include surface: `linux/fscache-cache.h`, `linux/uio.h`, `linux/bvec.h`, `linux/slab.h`, `internal.h`.
- Detected declarations: `struct fscache_write_request`, `function Copyright`, `function fscache_begin_operation`, `function __fscache_begin_read_operation`, `function __fscache_begin_write_operation`, `function __fscache_clear_page_bits`, `function xas_for_each`, `function fscache_wreq_done`, `function __fscache_write_to_cache`, `function __fscache_resize_cookie`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: integration 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.