fs/nfs/dns_resolve.c
Source file repositories/reference/linux-study-clean/fs/nfs/dns_resolve.c
File Facts
- System
- Linux kernel
- Corpus path
fs/nfs/dns_resolve.c- Extension
.c- Size
- 10490 bytes
- Lines
- 481
- 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/module.hlinux/sunrpc/clnt.hlinux/sunrpc/addr.hdns_resolve.hlinux/dns_resolver.hlinux/hash.hlinux/string.hlinux/kmod.hlinux/slab.hlinux/socket.hlinux/seq_file.hlinux/inet.hlinux/sunrpc/cache.hlinux/sunrpc/svcauth.hlinux/sunrpc/rpc_pipe_fs.hlinux/nfs_fs.hnfs4_fs.hcache_lib.hnetns.h
Detected Declarations
struct nfs_dns_entfunction Copyrightfunction nfs_dns_ent_updatefunction nfs_dns_ent_initfunction nfs_dns_ent_free_rcufunction nfs_dns_ent_putfunction nfs_dns_hashfunction nfs_dns_requestfunction nfs_dns_upcallfunction nfs_dns_matchfunction nfs_dns_showfunction nfs_dns_parsefunction do_cache_lookupfunction do_cache_lookup_nowaitfunction do_cache_lookup_waitfunction nfs_dns_resolve_namefunction nfs_dns_resolver_cache_initfunction nfs_dns_resolver_cache_destroyfunction nfs4_dns_net_initfunction nfs4_dns_net_exitfunction rpc_pipefs_eventfunction nfs_dns_resolver_initfunction nfs_dns_resolver_destroy
Annotated Snippet
struct nfs_dns_ent {
struct cache_head h;
char *hostname;
size_t namelen;
struct sockaddr_storage addr;
size_t addrlen;
struct rcu_head rcu_head;
};
static void nfs_dns_ent_update(struct cache_head *cnew,
struct cache_head *ckey)
{
struct nfs_dns_ent *new;
struct nfs_dns_ent *key;
new = container_of(cnew, struct nfs_dns_ent, h);
key = container_of(ckey, struct nfs_dns_ent, h);
memcpy(&new->addr, &key->addr, key->addrlen);
new->addrlen = key->addrlen;
}
static void nfs_dns_ent_init(struct cache_head *cnew,
struct cache_head *ckey)
{
struct nfs_dns_ent *new;
struct nfs_dns_ent *key;
new = container_of(cnew, struct nfs_dns_ent, h);
key = container_of(ckey, struct nfs_dns_ent, h);
kfree(new->hostname);
new->hostname = kmemdup_nul(key->hostname, key->namelen, GFP_KERNEL);
if (new->hostname) {
new->namelen = key->namelen;
nfs_dns_ent_update(cnew, ckey);
} else {
new->namelen = 0;
new->addrlen = 0;
}
}
static void nfs_dns_ent_free_rcu(struct rcu_head *head)
{
struct nfs_dns_ent *item;
item = container_of(head, struct nfs_dns_ent, rcu_head);
kfree(item->hostname);
kfree(item);
}
static void nfs_dns_ent_put(struct kref *ref)
{
struct nfs_dns_ent *item;
item = container_of(ref, struct nfs_dns_ent, h.ref);
call_rcu(&item->rcu_head, nfs_dns_ent_free_rcu);
}
static struct cache_head *nfs_dns_ent_alloc(void)
{
struct nfs_dns_ent *item = kmalloc_obj(*item);
if (item != NULL) {
item->hostname = NULL;
item->namelen = 0;
item->addrlen = 0;
return &item->h;
}
return NULL;
};
static unsigned int nfs_dns_hash(const struct nfs_dns_ent *key)
{
return hash_str(key->hostname, NFS_DNS_HASHBITS);
}
static void nfs_dns_request(struct cache_detail *cd,
struct cache_head *ch,
char **bpp, int *blen)
{
struct nfs_dns_ent *key = container_of(ch, struct nfs_dns_ent, h);
qword_add(bpp, blen, key->hostname);
(*bpp)[-1] = '\n';
}
Annotation
- Immediate include surface: `linux/module.h`, `linux/sunrpc/clnt.h`, `linux/sunrpc/addr.h`, `dns_resolve.h`, `linux/dns_resolver.h`, `linux/hash.h`, `linux/string.h`, `linux/kmod.h`.
- Detected declarations: `struct nfs_dns_ent`, `function Copyright`, `function nfs_dns_ent_update`, `function nfs_dns_ent_init`, `function nfs_dns_ent_free_rcu`, `function nfs_dns_ent_put`, `function nfs_dns_hash`, `function nfs_dns_request`, `function nfs_dns_upcall`, `function nfs_dns_match`.
- 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.