fs/nfs/pnfs.c
Source file repositories/reference/linux-study-clean/fs/nfs/pnfs.c
File Facts
- System
- Linux kernel
- Corpus path
fs/nfs/pnfs.c- Extension
.c- Size
- 95329 bytes
- Lines
- 3536
- 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/nfs_fs.hlinux/nfs_page.hlinux/module.hlinux/sort.hinternal.hpnfs.hiostat.hnfs4trace.hdelegation.hnfs42.hnfs4_fs.h
Detected Declarations
function find_pnfs_driver_lockedfunction find_pnfs_driverfunction pnfs_put_layoutdriverfunction unset_pnfs_layoutdriverfunction ld_cmpfunction set_pnfs_layoutdriverfunction pnfs_register_layoutdriverfunction pnfs_unregister_layoutdriverfunction pnfs_get_layout_hdrfunction pnfs_alloc_layout_hdrfunction pnfs_free_layout_hdrfunction pnfs_detach_layout_hdrfunction pnfs_put_layout_hdrfunction pnfs_grab_inode_layout_hdrfunction pnfs_seqid_is_newerfunction pnfs_barrier_updatefunction pnfs_set_plh_return_infofunction pnfs_clear_layoutreturn_infofunction pnfs_clear_layoutreturn_waitbitfunction pnfs_clear_lseg_statefunction nfs4_layout_refresh_old_stateidfunction nfs4_stateid_match_otherfunction pnfs_mark_layout_stateid_invalidfunction pnfs_mark_layout_stateid_returnfunction pnfs_iomode_to_fail_bitfunction pnfs_layout_set_fail_bitfunction pnfs_layout_clear_fail_bitfunction pnfs_layout_io_set_failedfunction pnfs_layout_io_test_failedfunction pnfs_init_lsegfunction pnfs_free_lsegfunction pnfs_layout_remove_lsegfunction pnfs_cache_lseg_for_layoutreturnfunction pnfs_put_lsegfunction pnfs_lseg_range_containedfunction pnfs_lseg_dec_and_remove_zerofunction mark_lseg_invalidfunction pnfs_should_free_rangefunction pnfs_match_lseg_recallfunction pnfs_mark_matching_lsegs_invalidfunction pnfs_reset_return_infofunction pnfs_free_returned_lsegsfunction list_for_each_entry_safefunction pnfs_free_lseg_listfunction list_for_each_entry_safefunction pnfs_destroy_layoutfunction pnfs_destroy_layout_finalfunction pnfs_layout_add_bulk_destroy_list
Annotated Snippet
if (!ld_type) {
request_module("%s-%u", LAYOUT_NFSV4_1_MODULE_PREFIX,
id);
ld_type = find_pnfs_driver(id);
}
if (ld_type)
break;
}
if (!ld_type) {
dprintk("%s: No pNFS module found!\n", __func__);
goto out_no_driver;
}
server->pnfs_curr_ld = ld_type;
if (ld_type->set_layoutdriver
&& ld_type->set_layoutdriver(server, mntfh)) {
printk(KERN_ERR "NFS: %s: Error initializing pNFS layout "
"driver %u.\n", __func__, id);
module_put(ld_type->owner);
goto out_no_driver;
}
/* Bump the MDS count */
atomic_inc(&server->nfs_client->cl_mds_count);
dprintk("%s: pNFS module for %u set\n", __func__, id);
return;
out_no_driver:
dprintk("%s: Using NFSv4 I/O\n", __func__);
server->pnfs_curr_ld = NULL;
}
int
pnfs_register_layoutdriver(struct pnfs_layoutdriver_type *ld_type)
{
int status = -EINVAL;
struct pnfs_layoutdriver_type *tmp;
if (ld_type->id == 0) {
printk(KERN_ERR "NFS: %s id 0 is reserved\n", __func__);
return status;
}
if (!ld_type->alloc_lseg || !ld_type->free_lseg) {
printk(KERN_ERR "NFS: %s Layout driver must provide "
"alloc_lseg and free_lseg.\n", __func__);
return status;
}
spin_lock(&pnfs_spinlock);
tmp = find_pnfs_driver_locked(ld_type->id);
if (!tmp) {
list_add(&ld_type->pnfs_tblid, &pnfs_modules_tbl);
status = 0;
dprintk("%s Registering id:%u name:%s\n", __func__, ld_type->id,
ld_type->name);
} else {
printk(KERN_ERR "NFS: %s Module with id %d already loaded!\n",
__func__, ld_type->id);
}
spin_unlock(&pnfs_spinlock);
return status;
}
EXPORT_SYMBOL_GPL(pnfs_register_layoutdriver);
void
pnfs_unregister_layoutdriver(struct pnfs_layoutdriver_type *ld_type)
{
dprintk("%s Deregistering id:%u\n", __func__, ld_type->id);
spin_lock(&pnfs_spinlock);
list_del(&ld_type->pnfs_tblid);
spin_unlock(&pnfs_spinlock);
}
EXPORT_SYMBOL_GPL(pnfs_unregister_layoutdriver);
/*
* pNFS client layout cache
*/
/* Need to hold i_lock if caller does not already hold reference */
void
pnfs_get_layout_hdr(struct pnfs_layout_hdr *lo)
{
refcount_inc(&lo->plh_refcount);
}
static struct pnfs_layout_hdr *
pnfs_alloc_layout_hdr(struct inode *ino, gfp_t gfp_flags)
{
Annotation
- Immediate include surface: `linux/nfs_fs.h`, `linux/nfs_page.h`, `linux/module.h`, `linux/sort.h`, `internal.h`, `pnfs.h`, `iostat.h`, `nfs4trace.h`.
- Detected declarations: `function find_pnfs_driver_locked`, `function find_pnfs_driver`, `function pnfs_put_layoutdriver`, `function unset_pnfs_layoutdriver`, `function ld_cmp`, `function set_pnfs_layoutdriver`, `function pnfs_register_layoutdriver`, `function pnfs_unregister_layoutdriver`, `function pnfs_get_layout_hdr`, `function pnfs_alloc_layout_hdr`.
- 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.