fs/afs/cell.c
Source file repositories/reference/linux-study-clean/fs/afs/cell.c
File Facts
- System
- Linux kernel
- Corpus path
fs/afs/cell.c- Extension
.c- Size
- 23244 bytes
- Lines
- 925
- 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.
- 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/slab.hlinux/key.hlinux/ctype.hlinux/dns_resolver.hlinux/sched.hlinux/inet.hlinux/namei.hkeys/rxrpc-type.hinternal.h
Detected Declarations
function afs_dec_cells_outstandingfunction afs_set_cell_statefunction afs_cell_initfunction afs_update_cellfunction afs_cell_destroyfunction afs_destroy_cell_workfunction afs_put_cellfunction afs_unuse_cellfunction afs_see_cellfunction afs_queue_cellfunction afs_cell_timerfunction afs_set_cell_timerfunction afs_activate_cellfunction afs_deactivate_cellfunction afs_has_cell_expiredfunction afs_manage_cellfunction afs_manage_cell_workfunction afs_cell_purge
Annotated Snippet
if (IS_ERR(vllist)) {
ret = PTR_ERR(vllist);
vllist = NULL;
goto parse_failed;
}
vllist->source = DNS_RECORD_FROM_CONFIG;
vllist->status = DNS_LOOKUP_NOT_DONE;
cell->dns_expiry = TIME64_MAX;
} else {
ret = -ENOMEM;
vllist = afs_alloc_vlserver_list(0);
if (!vllist)
goto error;
vllist->source = DNS_RECORD_UNAVAILABLE;
vllist->status = DNS_LOOKUP_NOT_DONE;
cell->dns_expiry = ktime_get_real_seconds();
}
rcu_assign_pointer(cell->vl_servers, vllist);
cell->dns_source = vllist->source;
cell->dns_status = vllist->status;
smp_store_release(&cell->dns_lookup_count, 1); /* vs source/status */
atomic_inc(&net->cells_outstanding);
ret = idr_alloc_cyclic(&net->cells_dyn_ino, cell,
2, INT_MAX / 2, GFP_KERNEL);
if (ret < 0)
goto error;
cell->dynroot_ino = ret;
cell->debug_id = atomic_inc_return(&cell_debug_id);
trace_afs_cell(cell->debug_id, 1, 0, afs_cell_trace_alloc);
_leave(" = %p", cell);
return cell;
parse_failed:
if (ret == -EINVAL)
printk(KERN_ERR "kAFS: bad VL server IP address\n");
error:
afs_put_vlserverlist(cell->net, vllist);
kfree(cell->name - 1);
kfree(cell);
_leave(" = %d", ret);
return ERR_PTR(ret);
}
/*
* afs_lookup_cell - Look up or create a cell record.
* @net: The network namespace
* @name: The name of the cell.
* @namesz: The strlen of the cell name.
* @vllist: A colon/comma separated list of numeric IP addresses or NULL.
* @reason: The reason we're doing the lookup
* @trace: The reason to be logged if the lookup is successful.
*
* Look up a cell record by name and query the DNS for VL server addresses if
* needed. Note that that actual DNS query is punted off to the manager thread
* so that this function can return immediately if interrupted whilst allowing
* cell records to be shared even if not yet fully constructed.
*/
struct afs_cell *afs_lookup_cell(struct afs_net *net,
const char *name, unsigned int namesz,
const char *vllist,
enum afs_lookup_cell_for reason,
enum afs_cell_trace trace)
{
struct afs_cell *cell, *candidate, *cursor;
struct rb_node *parent, **pp;
enum afs_cell_state state;
int ret, n;
_enter("%s,%s,%u", name, vllist, reason);
if (reason != AFS_LOOKUP_CELL_PRELOAD) {
cell = afs_find_cell(net, name, namesz, trace);
if (!IS_ERR(cell)) {
if (reason == AFS_LOOKUP_CELL_DYNROOT)
goto no_wait;
if (cell->state == AFS_CELL_SETTING_UP ||
cell->state == AFS_CELL_UNLOOKED)
goto lookup_cell;
goto wait_for_cell;
}
}
/* Assume we're probably going to create a cell and preallocate and
* mostly set up a candidate record. We can then use this to stash the
* name, the net namespace and VL server addresses.
Annotation
- Immediate include surface: `linux/slab.h`, `linux/key.h`, `linux/ctype.h`, `linux/dns_resolver.h`, `linux/sched.h`, `linux/inet.h`, `linux/namei.h`, `keys/rxrpc-type.h`.
- Detected declarations: `function afs_dec_cells_outstanding`, `function afs_set_cell_state`, `function afs_cell_init`, `function afs_update_cell`, `function afs_cell_destroy`, `function afs_destroy_cell_work`, `function afs_put_cell`, `function afs_unuse_cell`, `function afs_see_cell`, `function afs_queue_cell`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: source 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.