fs/afs/server_list.c
Source file repositories/reference/linux-study-clean/fs/afs/server_list.c
File Facts
- System
- Linux kernel
- Corpus path
fs/afs/server_list.c- Extension
.c- Size
- 6333 bytes
- Lines
- 250
- 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/kernel.hlinux/slab.hinternal.h
Detected Declarations
function Copyrightfunction afs_annotate_server_listfunction afs_attach_volume_to_serversfunction list_for_eachfunction afs_reattach_volume_to_serversfunction afs_detach_volume_from_servers
Annotated Snippet
if (newrep < usable / 2) {
slist->ro_replicating = AFS_RO_REPLICATING_USE_OLD;
} else {
slist->ro_replicating = AFS_RO_REPLICATING_USE_NEW;
use_newrepsites = true;
}
}
refcount_set(&slist->usage, 1);
rwlock_init(&slist->lock);
/* Make sure a records exists for each server in the list. */
for (i = 0; i < vldb->nr_servers; i++) {
unsigned long se_flags = 0;
bool newrepsite = vldb->vlsf_flags[i] & AFS_VLSF_NEWREPSITE;
if (!(vldb->fs_mask[i] & type_mask))
continue;
if (vldb->vlsf_flags[i] & AFS_VLSF_DONTUSE)
__set_bit(AFS_SE_EXCLUDED, &se_flags);
if (newrep && (newrepsite ^ use_newrepsites))
__set_bit(AFS_SE_EXCLUDED, &se_flags);
server = afs_lookup_server(volume->cell, key, &vldb->fs_server[i],
vldb->addr_version[i]);
if (IS_ERR(server)) {
ret = PTR_ERR(server);
if (ret == -ENOENT ||
ret == -ENOMEDIUM)
continue;
goto error_2;
}
/* Insertion-sort by UUID */
for (j = 0; j < slist->nr_servers; j++)
if (memcmp(&slist->servers[j].server->uuid,
&server->uuid,
sizeof(server->uuid)) >= 0)
break;
if (j < slist->nr_servers) {
if (slist->servers[j].server == server) {
afs_unuse_server_notime(volume->cell->net, server,
afs_server_trace_unuse_slist_isort);
continue;
}
memmove(slist->servers + j + 1,
slist->servers + j,
(slist->nr_servers - j) * sizeof(struct afs_server_entry));
}
slist->servers[j].server = server;
slist->servers[j].volume = volume;
slist->servers[j].flags = se_flags;
slist->servers[j].cb_expires_at = AFS_NO_CB_PROMISE;
slist->nr_servers++;
}
if (slist->nr_servers == 0) {
ret = -EDESTADDRREQ;
goto error_2;
}
return slist;
error_2:
afs_put_serverlist(volume->cell->net, slist);
error:
return ERR_PTR(ret);
}
/*
* Copy the annotations from an old server list to its potential replacement.
*/
bool afs_annotate_server_list(struct afs_server_list *new,
struct afs_server_list *old)
{
unsigned long mask = 1UL << AFS_SE_EXCLUDED;
int i;
if (old->nr_servers != new->nr_servers ||
old->ro_replicating != new->ro_replicating)
goto changed;
for (i = 0; i < old->nr_servers; i++) {
if (old->servers[i].server != new->servers[i].server)
goto changed;
if ((old->servers[i].flags & mask) != (new->servers[i].flags & mask))
goto changed;
}
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/slab.h`, `internal.h`.
- Detected declarations: `function Copyright`, `function afs_annotate_server_list`, `function afs_attach_volume_to_servers`, `function list_for_each`, `function afs_reattach_volume_to_servers`, `function afs_detach_volume_from_servers`.
- 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.