fs/nfs/pagelist.c
Source file repositories/reference/linux-study-clean/fs/nfs/pagelist.c
File Facts
- System
- Linux kernel
- Corpus path
fs/nfs/pagelist.c- Extension
.c- Size
- 39266 bytes
- Lines
- 1497
- 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/slab.hlinux/file.hlinux/sched.hlinux/sunrpc/clnt.hlinux/nfs.hlinux/nfs3.hlinux/nfs4.hlinux/nfs_fs.hlinux/nfs_page.hlinux/nfs_mount.hlinux/export.hlinux/filelock.hinternal.hpnfs.hnfstrace.hfscache.h
Detected Declarations
struct nfs_page_iter_pagefunction nfs_page_iter_page_initfunction nfs_page_iter_page_advancefunction nfs_pgio_get_mirrorfunction nfs_pgio_current_mirrorfunction nfs_pgio_set_current_mirrorfunction nfs_pgheader_initfunction nfs_set_pgio_errorfunction nfs_page_freefunction nfs_iocounter_waitfunction nfs_async_iocounter_waitfunction nfs_page_set_headlockfunction nfs_page_clear_headlockfunction nfs_page_group_lockfunction nfs_page_group_unlockfunction nfs_page_group_sync_on_bit_lockedfunction nfs_page_group_sync_on_bitfunction groupfunction nfs_page_group_destroyfunction nfs_page_assign_foliofunction nfs_page_assign_pagefunction nfs_create_subreqfunction nfs_unlock_requestfunction nfs_unlock_and_release_requestfunction nfs_clear_requestfunction nfs_free_requestfunction nfs_release_requestfunction nfs_generic_pg_testfunction nfs_pgio_data_destroyfunction nfs_pgio_header_freefunction nfs_pgio_rpcsetupfunction nfs_pgio_preparefunction nfs_initiate_pgiofunction nfs_pgio_errorfunction nfs_pgio_releasefunction nfs_pageio_mirror_initfunction nfs_pageio_initfunction nfs_pgio_resultfunction nfs_generic_pgiofunction nfs_generic_pg_pgiosfunction nfs_pageio_alloc_mirrorsfunction nfs_pageio_setup_mirroringfunction nfs_pageio_cleanup_mirroringfunction nfs_match_lock_contextfunction nfs_page_is_contiguousfunction nfs_coalesce_sizefunction nfs_pageio_do_add_requestfunction nfs_pageio_doio
Annotated Snippet
struct nfs_page_iter_page {
const struct nfs_page *req;
size_t count;
};
static void nfs_page_iter_page_init(struct nfs_page_iter_page *i,
const struct nfs_page *req)
{
i->req = req;
i->count = 0;
}
static void nfs_page_iter_page_advance(struct nfs_page_iter_page *i, size_t sz)
{
const struct nfs_page *req = i->req;
size_t tmp = i->count + sz;
i->count = (tmp < req->wb_bytes) ? tmp : req->wb_bytes;
}
static struct page *nfs_page_iter_page_get(struct nfs_page_iter_page *i)
{
const struct nfs_page *req = i->req;
struct page *page;
if (i->count != req->wb_bytes) {
size_t base = i->count + req->wb_pgbase;
size_t len = PAGE_SIZE - offset_in_page(base);
page = nfs_page_to_page(req, base);
nfs_page_iter_page_advance(i, len);
return page;
}
return NULL;
}
static struct nfs_pgio_mirror *
nfs_pgio_get_mirror(struct nfs_pageio_descriptor *desc, u32 idx)
{
if (desc->pg_ops->pg_get_mirror)
return desc->pg_ops->pg_get_mirror(desc, idx);
return &desc->pg_mirrors[0];
}
struct nfs_pgio_mirror *
nfs_pgio_current_mirror(struct nfs_pageio_descriptor *desc)
{
return nfs_pgio_get_mirror(desc, desc->pg_mirror_idx);
}
EXPORT_SYMBOL_GPL(nfs_pgio_current_mirror);
static u32
nfs_pgio_set_current_mirror(struct nfs_pageio_descriptor *desc, u32 idx)
{
if (desc->pg_ops->pg_set_mirror)
return desc->pg_ops->pg_set_mirror(desc, idx);
return desc->pg_mirror_idx;
}
void nfs_pgheader_init(struct nfs_pageio_descriptor *desc,
struct nfs_pgio_header *hdr,
void (*release)(struct nfs_pgio_header *hdr))
{
struct nfs_pgio_mirror *mirror = nfs_pgio_current_mirror(desc);
hdr->req = nfs_list_entry(mirror->pg_list.next);
hdr->inode = desc->pg_inode;
hdr->cred = nfs_req_openctx(hdr->req)->cred;
hdr->io_start = req_offset(hdr->req);
hdr->good_bytes = mirror->pg_count;
hdr->io_completion = desc->pg_io_completion;
hdr->dreq = desc->pg_dreq;
nfs_netfs_set_pgio_header(hdr, desc);
hdr->release = release;
hdr->completion_ops = desc->pg_completion_ops;
if (hdr->completion_ops->init_hdr)
hdr->completion_ops->init_hdr(hdr);
hdr->pgio_mirror_idx = desc->pg_mirror_idx;
}
EXPORT_SYMBOL_GPL(nfs_pgheader_init);
void nfs_set_pgio_error(struct nfs_pgio_header *hdr, int error, loff_t pos)
{
unsigned int new = pos - hdr->io_start;
trace_nfs_pgio_error(hdr, error, pos);
if (hdr->good_bytes > new) {
hdr->good_bytes = new;
Annotation
- Immediate include surface: `linux/slab.h`, `linux/file.h`, `linux/sched.h`, `linux/sunrpc/clnt.h`, `linux/nfs.h`, `linux/nfs3.h`, `linux/nfs4.h`, `linux/nfs_fs.h`.
- Detected declarations: `struct nfs_page_iter_page`, `function nfs_page_iter_page_init`, `function nfs_page_iter_page_advance`, `function nfs_pgio_get_mirror`, `function nfs_pgio_current_mirror`, `function nfs_pgio_set_current_mirror`, `function nfs_pgheader_init`, `function nfs_set_pgio_error`, `function nfs_page_free`, `function nfs_iocounter_wait`.
- 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.