fs/afs/rotate.c
Source file repositories/reference/linux-study-clean/fs/afs/rotate.c
File Facts
- System
- Linux kernel
- Corpus path
fs/afs/rotate.c- Extension
.c- Size
- 23087 bytes
- Lines
- 764
- 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/kernel.hlinux/slab.hlinux/fs.hlinux/sched.hlinux/delay.hlinux/sched/signal.hinternal.hafs_fs.hprotocol_uae.h
Detected Declarations
function Copyrightfunction afs_start_fs_iterationfunction afs_busyfunction afs_sleep_and_retryfunction afs_select_fileserverfunction timefunction afs_dump_edestaddrreq
Annotated Snippet
if (server == cb_server) {
op->server_index = i;
goto found_interest;
}
}
/* If we have a lock outstanding on a server that's no longer
* serving this vnode, then we can't switch to another server
* and have to return an error.
*/
if (op->flags & AFS_OPERATION_CUR_ONLY) {
afs_op_set_error(op, -ESTALE);
trace_afs_rotate(op, afs_rotate_trace_stale_lock, 0);
return false;
}
/* Note that the callback promise is effectively broken */
write_seqlock(&vnode->cb_lock);
ASSERTCMP(cb_server, ==, vnode->cb_server);
vnode->cb_server = NULL;
if (afs_clear_cb_promise(vnode, afs_cb_promise_clear_rotate_server))
vnode->cb_break++;
write_sequnlock(&vnode->cb_lock);
}
found_interest:
return true;
}
/*
* Post volume busy note.
*/
static void afs_busy(struct afs_operation *op, u32 abort_code)
{
const char *m;
switch (abort_code) {
case VOFFLINE: m = "offline"; break;
case VRESTARTING: m = "restarting"; break;
case VSALVAGING: m = "being salvaged"; break;
default: m = "busy"; break;
}
pr_notice("kAFS: Volume %llu '%s' on server %pU is %s\n",
op->volume->vid, op->volume->name, &op->server->uuid, m);
}
/*
* Sleep and retry the operation to the same fileserver.
*/
static bool afs_sleep_and_retry(struct afs_operation *op)
{
trace_afs_rotate(op, afs_rotate_trace_busy_sleep, 0);
if (!(op->flags & AFS_OPERATION_UNINTR)) {
msleep_interruptible(1000);
if (signal_pending(current)) {
afs_op_set_error(op, -ERESTARTSYS);
return false;
}
} else {
msleep(1000);
}
return true;
}
/*
* Select the fileserver to use. May be called multiple times to rotate
* through the fileservers.
*/
bool afs_select_fileserver(struct afs_operation *op)
{
struct afs_addr_list *alist;
struct afs_server *server;
struct afs_vnode *vnode = op->file[0].vnode;
unsigned long set, failed;
s32 abort_code = op->call_abort_code;
int best_prio = 0;
int error = op->call_error, addr_index, i, j;
op->nr_iterations++;
_enter("OP=%x+%x,%llx,%u{%lx},%u{%lx},%d,%d",
op->debug_id, op->nr_iterations, op->volume->vid,
op->server_index, op->untried_servers,
op->addr_index, op->addr_tried,
error, abort_code);
if (op->flags & AFS_OPERATION_STOP) {
trace_afs_rotate(op, afs_rotate_trace_stopped, 0);
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/slab.h`, `linux/fs.h`, `linux/sched.h`, `linux/delay.h`, `linux/sched/signal.h`, `internal.h`, `afs_fs.h`.
- Detected declarations: `function Copyright`, `function afs_start_fs_iteration`, `function afs_busy`, `function afs_sleep_and_retry`, `function afs_select_fileserver`, `function time`, `function afs_dump_edestaddrreq`.
- 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.