fs/nfs/nfs4client.c
Source file repositories/reference/linux-study-clean/fs/nfs/nfs4client.c
File Facts
- System
- Linux kernel
- Corpus path
fs/nfs/nfs4client.c- Extension
.c- Size
- 31872 bytes
- Lines
- 1204
- 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/module.hlinux/nfs_fs.hlinux/nfs_mount.hlinux/sunrpc/addr.hlinux/sunrpc/auth.hlinux/sunrpc/xprt.hlinux/sunrpc/bc_xprt.hlinux/sunrpc/rpc_pipe_fs.hnet/handshake.hinternal.hcallback.hdelegation.hnfs4session.hnfs4idmap.hpnfs.hnetns.hsysfs.h
Detected Declarations
struct nfs4_ds_serverfunction Copyrightfunction nfs4_find_ds_clientfunction nfs4_add_ds_clientfunction nfs4_alloc_ds_serverfunction nfs4_free_ds_serverfunction nfs4_find_or_create_ds_clientfunction nfs4_shutdown_ds_clientsfunction nfs4_cleanup_callbackfunction nfs41_shutdown_clientfunction nfs4_destroy_callbackfunction nfs4_shutdown_clientfunction nfs4_free_clientfunction nfs4_init_callbackfunction nfs41_init_clientfunction nfs4_init_client_minor_versionfunction nfs4_add_trunkfunction nfs4_match_client_owner_idfunction nfs4_match_clientfunction nfs4_check_serverowner_major_idfunction nfs4_check_server_scopefunction nfs4_detect_session_trunkingfunction nfs41_walk_client_listfunction nfs4_destroy_serverfunction nfs4_find_client_identfunction nfs4_cb_match_clientfunction nfs4_find_client_sessionidfunction nfs4_set_clientfunction nfs4_session_limit_rwsizefunction nfs4_session_limit_xasizefunction nfs4_server_common_setupfunction nfs4_init_serverfunction drainedexport nfs4_find_or_create_ds_clientexport nfs4_set_ds_client
Annotated Snippet
struct nfs4_ds_server {
struct list_head list; /* ds_clp->cl_ds_clients */
struct rpc_clnt *rpc_clnt;
};
/**
* nfs4_find_ds_client - Common lookup case for DS I/O
* @ds_clp: pointer to the DS's nfs_client
* @flavor: rpc auth flavour to match
*/
static struct nfs4_ds_server *
nfs4_find_ds_client(struct nfs_client *ds_clp, rpc_authflavor_t flavor)
{
struct nfs4_ds_server *dss;
rcu_read_lock();
list_for_each_entry_rcu(dss, &ds_clp->cl_ds_clients, list) {
if (dss->rpc_clnt->cl_auth->au_flavor != flavor)
continue;
goto out;
}
dss = NULL;
out:
rcu_read_unlock();
return dss;
}
static struct nfs4_ds_server *
nfs4_add_ds_client(struct nfs_client *ds_clp, rpc_authflavor_t flavor,
struct nfs4_ds_server *new)
{
struct nfs4_ds_server *dss;
spin_lock(&ds_clp->cl_lock);
list_for_each_entry(dss, &ds_clp->cl_ds_clients, list) {
if (dss->rpc_clnt->cl_auth->au_flavor != flavor)
continue;
goto out;
}
if (new)
list_add_rcu(&new->list, &ds_clp->cl_ds_clients);
dss = new;
out:
spin_unlock(&ds_clp->cl_lock); /* need some lock to protect list */
return dss;
}
static struct nfs4_ds_server *
nfs4_alloc_ds_server(struct nfs_client *ds_clp, rpc_authflavor_t flavor)
{
struct nfs4_ds_server *dss;
dss = kmalloc_obj(*dss, GFP_NOFS);
if (dss == NULL)
return ERR_PTR(-ENOMEM);
dss->rpc_clnt = rpc_clone_client_set_auth(ds_clp->cl_rpcclient, flavor);
if (IS_ERR(dss->rpc_clnt)) {
int err = PTR_ERR(dss->rpc_clnt);
kfree (dss);
return ERR_PTR(err);
}
INIT_LIST_HEAD(&dss->list);
return dss;
}
static void
nfs4_free_ds_server(struct nfs4_ds_server *dss)
{
rpc_release_client(dss->rpc_clnt);
kfree(dss);
}
/**
* nfs4_find_or_create_ds_client - Find or create a DS rpc client
* @ds_clp: pointer to the DS's nfs_client
* @inode: pointer to the inode
*
* Find or create a DS rpc client with th MDS server rpc client auth flavor
* in the nfs_client cl_ds_clients list.
*/
struct rpc_clnt *
nfs4_find_or_create_ds_client(struct nfs_client *ds_clp, struct inode *inode)
{
struct nfs4_ds_server *dss, *new;
rpc_authflavor_t flavor = NFS_SERVER(inode)->client->cl_auth->au_flavor;
dss = nfs4_find_ds_client(ds_clp, flavor);
if (dss != NULL)
Annotation
- Immediate include surface: `linux/module.h`, `linux/nfs_fs.h`, `linux/nfs_mount.h`, `linux/sunrpc/addr.h`, `linux/sunrpc/auth.h`, `linux/sunrpc/xprt.h`, `linux/sunrpc/bc_xprt.h`, `linux/sunrpc/rpc_pipe_fs.h`.
- Detected declarations: `struct nfs4_ds_server`, `function Copyright`, `function nfs4_find_ds_client`, `function nfs4_add_ds_client`, `function nfs4_alloc_ds_server`, `function nfs4_free_ds_server`, `function nfs4_find_or_create_ds_client`, `function nfs4_shutdown_ds_clients`, `function nfs4_cleanup_callback`, `function nfs41_shutdown_client`.
- 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.