fs/dlm/ast.c
Source file repositories/reference/linux-study-clean/fs/dlm/ast.c
File Facts
- System
- Linux kernel
- Corpus path
fs/dlm/ast.c- Extension
.c- Size
- 7065 bytes
- Lines
- 276
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
trace/events/dlm.hdlm_internal.hlvb_table.hmemory.hlock.huser.hast.h
Detected Declarations
function Copyrightfunction dlm_do_callbackfunction dlm_callback_workfunction dlm_may_skip_callbackfunction dlm_get_cbfunction dlm_get_queue_cbfunction dlm_add_cbfunction dlm_callback_startfunction dlm_callback_stopfunction dlm_callback_suspendfunction dlm_callback_resume
Annotated Snippet
if (lkb->lkb_last_cast_cb_mode != -1) {
if (dlm_modes_compat(mode, lkb->lkb_last_cast_cb_mode)) {
log_debug(ls, "skip %x bast mode %d for cast mode %d",
lkb->lkb_id, mode,
lkb->lkb_last_cast_cb_mode);
return true;
}
}
/*
* Suppress some redundant basts here, do more on removal.
* Don't even add a bast if the callback just before it
* is a bast for the same mode or a more restrictive mode.
* (the addional > PR check is needed for PR/CW inversion)
*/
if (lkb->lkb_last_cb_mode != -1 &&
lkb->lkb_last_cb_flags & DLM_CB_BAST) {
prev_mode = lkb->lkb_last_cb_mode;
if ((prev_mode == mode) ||
(prev_mode > mode && prev_mode > DLM_LOCK_PR)) {
log_debug(ls, "skip %x add bast mode %d for bast mode %d",
lkb->lkb_id, mode, prev_mode);
return true;
}
}
lkb->lkb_last_bast_time = ktime_get();
lkb->lkb_last_bast_cb_mode = mode;
} else if (flags & DLM_CB_CAST) {
if (test_bit(DLM_DFL_USER_BIT, &lkb->lkb_dflags)) {
prev_mode = lkb->lkb_last_cast_cb_mode;
if (!status && lkb->lkb_lksb->sb_lvbptr &&
dlm_lvb_operations[prev_mode + 1][mode + 1]) {
if (copy_lvb)
*copy_lvb = 1;
}
}
lkb->lkb_last_cast_cb_mode = mode;
lkb->lkb_last_cast_time = ktime_get();
}
lkb->lkb_last_cb_mode = mode;
lkb->lkb_last_cb_flags = flags;
return false;
}
int dlm_get_cb(struct dlm_lkb *lkb, uint32_t flags, int mode,
int status, uint32_t sbflags,
struct dlm_callback **cb)
{
struct dlm_rsb *rsb = lkb->lkb_resource;
struct dlm_ls *ls = rsb->res_ls;
*cb = dlm_allocate_cb();
if (WARN_ON_ONCE(!*cb))
return -ENOMEM;
/* for tracing */
(*cb)->lkb_id = lkb->lkb_id;
(*cb)->ls_id = ls->ls_global_id;
memcpy((*cb)->res_name, rsb->res_name, rsb->res_length);
(*cb)->res_length = rsb->res_length;
(*cb)->flags = flags;
(*cb)->mode = mode;
(*cb)->sb_status = status;
(*cb)->sb_flags = (sbflags & 0x000000FF);
(*cb)->lkb_lksb = lkb->lkb_lksb;
return 0;
}
static int dlm_get_queue_cb(struct dlm_lkb *lkb, uint32_t flags, int mode,
int status, uint32_t sbflags,
struct dlm_callback **cb)
{
int rv;
rv = dlm_get_cb(lkb, flags, mode, status, sbflags, cb);
if (rv)
return rv;
(*cb)->astfn = lkb->lkb_astfn;
(*cb)->bastfn = lkb->lkb_bastfn;
(*cb)->astparam = lkb->lkb_astparam;
INIT_WORK(&(*cb)->work, dlm_callback_work);
Annotation
- Immediate include surface: `trace/events/dlm.h`, `dlm_internal.h`, `lvb_table.h`, `memory.h`, `lock.h`, `user.h`, `ast.h`.
- Detected declarations: `function Copyright`, `function dlm_do_callback`, `function dlm_callback_work`, `function dlm_may_skip_callback`, `function dlm_get_cb`, `function dlm_get_queue_cb`, `function dlm_add_cb`, `function dlm_callback_start`, `function dlm_callback_stop`, `function dlm_callback_suspend`.
- 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.