fs/nfs/fscache.h
Source file repositories/reference/linux-study-clean/fs/nfs/fscache.h
File Facts
- System
- Linux kernel
- Corpus path
fs/nfs/fscache.h- Extension
.h- Size
- 6700 bytes
- Lines
- 203
- 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/swap.hlinux/nfs_fs.hlinux/nfs_mount.hlinux/nfs4_mount.hlinux/fscache.hlinux/iversion.h
Detected Declarations
struct nfs_fscache_inode_auxdatastruct nfs_netfs_io_datafunction nfs_netfs_getfunction nfs_netfs_putfunction nfs_netfs_inode_initfunction nfs_fscache_release_foliofunction nfs_fscache_update_auxdatafunction nfs_fscache_invalidatefunction nfs_netfs_set_pgio_headerfunction nfs_netfs_set_pageio_descriptorfunction nfs_netfs_reset_pageio_descriptorfunction nfs_netfs_inode_initfunction nfs_fscache_release_super_cookiefunction nfs_netfs_read_foliofunction nfs_fscache_release_foliofunction nfs_fscache_invalidatefunction nfs_netfs_set_pgio_header
Annotated Snippet
struct nfs_fscache_inode_auxdata {
s64 mtime_sec;
s64 mtime_nsec;
s64 ctime_sec;
s64 ctime_nsec;
u64 change_attr;
};
struct nfs_netfs_io_data {
/*
* NFS may split a netfs_io_subrequest into multiple RPCs, each
* with their own read completion. In netfs, we can only call
* netfs_subreq_terminated() once for each subrequest. Use the
* refcount here to double as a marker of the last RPC completion,
* and only call netfs via netfs_subreq_terminated() once.
*/
refcount_t refcount;
struct netfs_io_subrequest *sreq;
/*
* Final disposition of the netfs_io_subrequest, sent in
* netfs_subreq_terminated()
*/
atomic64_t transferred;
int error;
};
static inline void nfs_netfs_get(struct nfs_netfs_io_data *netfs)
{
refcount_inc(&netfs->refcount);
}
static inline void nfs_netfs_put(struct nfs_netfs_io_data *netfs)
{
/* Only the last RPC completion should call netfs_subreq_terminated() */
if (!refcount_dec_and_test(&netfs->refcount))
return;
/*
* The NFS pageio interface may read a complete page, even when netfs
* only asked for a partial page. Specifically, this may be seen when
* one thread is truncating a file while another one is reading the last
* page of the file.
* Correct the final length here to be no larger than the netfs subrequest
* length, and thus avoid netfs's "Subreq overread" warning message.
*/
netfs->sreq->transferred = min_t(s64, netfs->sreq->len,
atomic64_read(&netfs->transferred));
netfs->sreq->error = netfs->error;
netfs_read_subreq_terminated(netfs->sreq);
kfree(netfs);
}
static inline void nfs_netfs_inode_init(struct nfs_inode *nfsi)
{
netfs_inode_init(&nfsi->netfs, &nfs_netfs_ops, false);
}
extern void nfs_netfs_initiate_read(struct nfs_pgio_header *hdr);
extern void nfs_netfs_read_completion(struct nfs_pgio_header *hdr);
extern int nfs_netfs_folio_unlock(struct folio *folio);
/*
* fscache.c
*/
extern int nfs_fscache_get_super_cookie(struct super_block *, const char *, int);
extern void nfs_fscache_release_super_cookie(struct super_block *);
extern void nfs_fscache_init_inode(struct inode *);
extern void nfs_fscache_clear_inode(struct inode *);
extern void nfs_fscache_open_file(struct inode *, struct file *);
extern void nfs_fscache_release_file(struct inode *, struct file *);
extern int nfs_netfs_readahead(struct readahead_control *ractl);
extern int nfs_netfs_read_folio(struct file *file, struct folio *folio);
static inline bool nfs_fscache_release_folio(struct folio *folio, gfp_t gfp)
{
if (folio_test_private_2(folio)) { /* [DEPRECATED] */
if (current_is_kswapd() || !(gfp & __GFP_FS))
return false;
folio_wait_private_2(folio);
}
fscache_note_page_release(netfs_i_cookie(netfs_inode(folio->mapping->host)));
return true;
}
static inline void nfs_fscache_update_auxdata(struct nfs_fscache_inode_auxdata *auxdata,
struct inode *inode)
{
memset(auxdata, 0, sizeof(*auxdata));
auxdata->mtime_sec = inode_get_mtime(inode).tv_sec;
auxdata->mtime_nsec = inode_get_mtime(inode).tv_nsec;
Annotation
- Immediate include surface: `linux/swap.h`, `linux/nfs_fs.h`, `linux/nfs_mount.h`, `linux/nfs4_mount.h`, `linux/fscache.h`, `linux/iversion.h`.
- Detected declarations: `struct nfs_fscache_inode_auxdata`, `struct nfs_netfs_io_data`, `function nfs_netfs_get`, `function nfs_netfs_put`, `function nfs_netfs_inode_init`, `function nfs_fscache_release_folio`, `function nfs_fscache_update_auxdata`, `function nfs_fscache_invalidate`, `function nfs_netfs_set_pgio_header`, `function nfs_netfs_set_pageio_descriptor`.
- 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.