fs/nfs/read.c
Source file repositories/reference/linux-study-clean/fs/nfs/read.c
File Facts
- System
- Linux kernel
- Corpus path
fs/nfs/read.c- Extension
.c- Size
- 11907 bytes
- Lines
- 477
- 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.
- 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/time.hlinux/kernel.hlinux/errno.hlinux/fcntl.hlinux/stat.hlinux/mm.hlinux/slab.hlinux/task_io_accounting_ops.hlinux/pagemap.hlinux/sunrpc/clnt.hlinux/nfs_fs.hlinux/nfs_page.hlinux/module.hnfs4_fs.hinternal.hiostat.hfscache.hpnfs.hnfstrace.hdelegation.h
Detected Declarations
function nfs_readhdr_freefunction nfs_return_empty_foliofunction nfs_pageio_init_readfunction nfs_pageio_complete_readfunction nfs_pageio_reset_read_mdsfunction nfs_read_alloc_scratchfunction nfs_readpage_releasefunction nfs_page_group_set_uptodatefunction nfs_read_completionfunction nfs_initiate_readfunction nfs_async_read_errorfunction occurredfunction nfs_readpage_retryfunction nfs_readpage_resultfunction nfs_read_add_foliofunction nfs_do_read_foliofunction nfs_read_foliofunction nfs_readaheadfunction nfs_init_readpagecachefunction nfs_destroy_readpagecacheexport nfs_pageio_init_readexport nfs_pageio_reset_read_mdsexport nfs_read_alloc_scratch
Annotated Snippet
if (test_bit(NFS_IOHDR_EOF, &hdr->flags)) {
/* note: regions of the page not covered by a
* request are zeroed in nfs_read_add_folio
*/
if (bytes > hdr->good_bytes) {
/* nothing in this request was good, so zero
* the full extent of the request */
folio_zero_segment(folio, start, end);
} else if (hdr->good_bytes - bytes < req->wb_bytes) {
/* part of this request has good bytes, but
* not all. zero the bad bytes */
start += hdr->good_bytes - bytes;
WARN_ON(start < req->wb_pgbase);
folio_zero_segment(folio, start, end);
}
}
error = 0;
bytes += req->wb_bytes;
if (test_bit(NFS_IOHDR_ERROR, &hdr->flags)) {
if (bytes <= hdr->good_bytes)
nfs_page_group_set_uptodate(req);
else {
error = hdr->error;
xchg(&nfs_req_openctx(req)->error, error);
}
} else
nfs_page_group_set_uptodate(req);
nfs_list_remove_request(req);
nfs_readpage_release(req, error);
}
nfs_netfs_read_completion(hdr);
out:
hdr->release(hdr);
}
static void nfs_initiate_read(struct nfs_pgio_header *hdr,
struct rpc_message *msg,
const struct nfs_rpc_ops *rpc_ops,
struct rpc_task_setup *task_setup_data, int how)
{
rpc_ops->read_setup(hdr, msg);
nfs_netfs_initiate_read(hdr);
trace_nfs_initiate_read(hdr);
}
static void
nfs_async_read_error(struct list_head *head, int error)
{
struct nfs_page *req;
while (!list_empty(head)) {
req = nfs_list_entry(head->next);
nfs_list_remove_request(req);
nfs_readpage_release(req, error);
}
}
const struct nfs_pgio_completion_ops nfs_async_read_completion_ops = {
.error_cleanup = nfs_async_read_error,
.completion = nfs_read_completion,
};
/*
* This is the callback from RPC telling us whether a reply was
* received or some error occurred (timeout or socket shutdown).
*/
static int nfs_readpage_done(struct rpc_task *task,
struct nfs_pgio_header *hdr,
struct inode *inode)
{
int status = NFS_PROTO(inode)->read_done(task, hdr);
if (status != 0)
return status;
nfs_add_stats(inode, NFSIOS_SERVERREADBYTES, hdr->res.count);
trace_nfs_readpage_done(task, hdr);
if (task->tk_status == -ESTALE) {
nfs_set_inode_stale(inode);
nfs_mark_for_revalidate(inode);
}
return 0;
}
static void nfs_readpage_retry(struct rpc_task *task,
struct nfs_pgio_header *hdr)
{
struct nfs_pgio_args *argp = &hdr->args;
Annotation
- Immediate include surface: `linux/time.h`, `linux/kernel.h`, `linux/errno.h`, `linux/fcntl.h`, `linux/stat.h`, `linux/mm.h`, `linux/slab.h`, `linux/task_io_accounting_ops.h`.
- Detected declarations: `function nfs_readhdr_free`, `function nfs_return_empty_folio`, `function nfs_pageio_init_read`, `function nfs_pageio_complete_read`, `function nfs_pageio_reset_read_mds`, `function nfs_read_alloc_scratch`, `function nfs_readpage_release`, `function nfs_page_group_set_uptodate`, `function nfs_read_completion`, `function nfs_initiate_read`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: integration 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.