fs/nfs_common/nfslocalio.c
Source file repositories/reference/linux-study-clean/fs/nfs_common/nfslocalio.c
File Facts
- System
- Linux kernel
- Corpus path
fs/nfs_common/nfslocalio.c- Extension
.c- Size
- 10382 bytes
- Lines
- 374
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/list.hlinux/nfslocalio.hlinux/nfs3.hlinux/nfs4.hlinux/nfs_fs.hnet/netns/generic.hlocalio_trace.h
Detected Declarations
function nfs_uuid_initfunction nfs_uuid_beginfunction nfs_uuid_endfunction nfs_uuid_lookup_lockedfunction nfs_uuid_is_localfunction nfs_localio_enable_clientfunction nfs_uuid_putfunction nfs_localio_disable_clientfunction nfs_localio_invalidate_clientsfunction nfs_uuid_add_filefunction nfsd_file_putfunction nfs_close_local_fhexport nfs_uuid_initexport nfs_uuid_beginexport nfs_uuid_endexport nfs_uuid_is_localexport nfs_localio_enable_clientexport nfs_localio_disable_clientexport nfs_localio_invalidate_clientsexport nfs_open_local_fhexport nfs_close_local_fhexport nfs_to
Annotated Snippet
if (!rcu_access_pointer(nfs_uuid->net)) {
/* Not local, remove from nfs_uuids */
spin_lock(&nfs_uuids_lock);
list_del_init(&nfs_uuid->list);
spin_unlock(&nfs_uuids_lock);
}
spin_unlock(&nfs_uuid->lock);
}
}
EXPORT_SYMBOL_GPL(nfs_uuid_end);
static nfs_uuid_t * nfs_uuid_lookup_locked(const uuid_t *uuid)
{
nfs_uuid_t *nfs_uuid;
list_for_each_entry(nfs_uuid, &nfs_uuids, list)
if (uuid_equal(&nfs_uuid->uuid, uuid))
return nfs_uuid;
return NULL;
}
static struct module *nfsd_mod;
void nfs_uuid_is_local(const uuid_t *uuid, struct list_head *list,
spinlock_t *list_lock, struct net *net,
struct auth_domain *dom, struct module *mod)
{
nfs_uuid_t *nfs_uuid;
spin_lock(&nfs_uuids_lock);
nfs_uuid = nfs_uuid_lookup_locked(uuid);
if (!nfs_uuid) {
spin_unlock(&nfs_uuids_lock);
return;
}
/*
* We don't hold a ref on the net, but instead put
* ourselves on @list (nn->local_clients) so the net
* pointer can be invalidated.
*/
spin_lock(list_lock); /* list_lock is nn->local_clients_lock */
list_move(&nfs_uuid->list, list);
spin_unlock(list_lock);
spin_unlock(&nfs_uuids_lock);
/* Once nfs_uuid is parented to @list, avoid global nfs_uuids_lock */
spin_lock(&nfs_uuid->lock);
__module_get(mod);
nfsd_mod = mod;
nfs_uuid->list_lock = list_lock;
kref_get(&dom->ref);
nfs_uuid->dom = dom;
rcu_assign_pointer(nfs_uuid->net, net);
spin_unlock(&nfs_uuid->lock);
}
EXPORT_SYMBOL_GPL(nfs_uuid_is_local);
void nfs_localio_enable_client(struct nfs_client *clp)
{
/* nfs_uuid_is_local() does the actual enablement */
trace_nfs_localio_enable_client(clp);
}
EXPORT_SYMBOL_GPL(nfs_localio_enable_client);
/*
* Cleanup the nfs_uuid_t embedded in an nfs_client.
* This is the long-form of nfs_uuid_init().
*/
static bool nfs_uuid_put(nfs_uuid_t *nfs_uuid)
{
struct nfs_file_localio *nfl;
spin_lock(&nfs_uuid->lock);
if (unlikely(!rcu_access_pointer(nfs_uuid->net))) {
spin_unlock(&nfs_uuid->lock);
return false;
}
RCU_INIT_POINTER(nfs_uuid->net, NULL);
if (nfs_uuid->dom) {
auth_domain_put(nfs_uuid->dom);
nfs_uuid->dom = NULL;
}
/* Walk list of files and ensure their last references dropped */
Annotation
- Immediate include surface: `linux/module.h`, `linux/list.h`, `linux/nfslocalio.h`, `linux/nfs3.h`, `linux/nfs4.h`, `linux/nfs_fs.h`, `net/netns/generic.h`, `localio_trace.h`.
- Detected declarations: `function nfs_uuid_init`, `function nfs_uuid_begin`, `function nfs_uuid_end`, `function nfs_uuid_lookup_locked`, `function nfs_uuid_is_local`, `function nfs_localio_enable_client`, `function nfs_uuid_put`, `function nfs_localio_disable_client`, `function nfs_localio_invalidate_clients`, `function nfs_uuid_add_file`.
- 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.