kernel/liveupdate/luo_flb.c
Source file repositories/reference/linux-study-clean/kernel/liveupdate/luo_flb.c
File Facts
- System
- Linux kernel
- Corpus path
kernel/liveupdate/luo_flb.c- Extension
.c- Size
- 18242 bytes
- Lines
- 619
- Domain
- Core OS
- Bucket
- Scheduler, Processes, Timers, Sync, And Syscalls
- 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/cleanup.hlinux/err.hlinux/errno.hlinux/io.hlinux/kexec_handover.hlinux/kho/abi/luo.hlinux/list_private.hlinux/liveupdate.hlinux/module.hlinux/mutex.hlinux/slab.hluo_internal.h
Detected Declarations
struct luo_flb_headerstruct luo_flb_globalstruct luo_flb_linkfunction luo_flb_file_preserve_onefunction scoped_guardfunction luo_flb_file_unpreserve_onefunction scoped_guardfunction luo_flb_retrieve_onefunction liveupdate_flb_put_incomingfunction scoped_guardfunction luo_flb_file_preservefunction luo_flb_file_unpreservefunction luo_flb_file_finishfunction luo_flb_unregister_onefunction luo_flb_unregister_allfunction liveupdate_register_flbfunction list_private_for_each_entryfunction liveupdate_register_flbfunction incomingfunction outgoingfunction luo_flb_setup_outgoingfunction luo_flb_setup_incomingfunction preserved
Annotated Snippet
struct luo_flb_header {
struct luo_flb_header_ser *header_ser;
struct luo_flb_ser *ser;
bool active;
};
struct luo_flb_global {
struct luo_flb_header incoming;
struct luo_flb_header outgoing;
struct list_head list;
long count;
};
static struct luo_flb_global luo_flb_global = {
.list = LIST_HEAD_INIT(luo_flb_global.list),
};
/*
* struct luo_flb_link - Links an FLB definition to a file handler's internal
* list of dependencies.
* @flb: A pointer to the registered &struct liveupdate_flb definition.
* @list: The list_head for linking.
*/
struct luo_flb_link {
struct liveupdate_flb *flb;
struct list_head list;
};
/* luo_flb_get_private - Access private field, and if needed initialize it. */
static struct luo_flb_private *luo_flb_get_private(struct liveupdate_flb *flb)
{
struct luo_flb_private *private = &ACCESS_PRIVATE(flb, private);
static DEFINE_SPINLOCK(luo_flb_init_lock);
if (smp_load_acquire(&private->initialized))
return private;
guard(spinlock)(&luo_flb_init_lock);
if (!private->initialized) {
mutex_init(&private->incoming.lock);
mutex_init(&private->outgoing.lock);
INIT_LIST_HEAD(&private->list);
private->users = 0;
smp_store_release(&private->initialized, true);
}
return private;
}
static int luo_flb_file_preserve_one(struct liveupdate_flb *flb)
{
struct luo_flb_private *private = luo_flb_get_private(flb);
scoped_guard(mutex, &private->outgoing.lock) {
if (!refcount_read(&private->outgoing.count)) {
struct liveupdate_flb_op_args args = {0};
int err;
if (!try_module_get(flb->ops->owner))
return -ENODEV;
args.flb = flb;
err = flb->ops->preserve(&args);
if (err) {
module_put(flb->ops->owner);
return err;
}
private->outgoing.data = args.data;
private->outgoing.obj = args.obj;
refcount_set(&private->outgoing.count, 1);
} else {
refcount_inc(&private->outgoing.count);
}
}
return 0;
}
static void luo_flb_file_unpreserve_one(struct liveupdate_flb *flb)
{
struct luo_flb_private *private = luo_flb_get_private(flb);
scoped_guard(mutex, &private->outgoing.lock) {
if (refcount_dec_and_test(&private->outgoing.count)) {
struct liveupdate_flb_op_args args = {0};
args.flb = flb;
args.data = private->outgoing.data;
args.obj = private->outgoing.obj;
Annotation
- Immediate include surface: `linux/cleanup.h`, `linux/err.h`, `linux/errno.h`, `linux/io.h`, `linux/kexec_handover.h`, `linux/kho/abi/luo.h`, `linux/list_private.h`, `linux/liveupdate.h`.
- Detected declarations: `struct luo_flb_header`, `struct luo_flb_global`, `struct luo_flb_link`, `function luo_flb_file_preserve_one`, `function scoped_guard`, `function luo_flb_file_unpreserve_one`, `function scoped_guard`, `function luo_flb_retrieve_one`, `function liveupdate_flb_put_incoming`, `function scoped_guard`.
- Atlas domain: Core OS / Scheduler, Processes, Timers, Sync, And Syscalls.
- 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.