fs/dlm/lock.c
Source file repositories/reference/linux-study-clean/fs/dlm/lock.c
File Facts
- System
- Linux kernel
- Corpus path
fs/dlm/lock.c- Extension
.c- Size
- 167187 bytes
- Lines
- 6339
- 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
trace/events/dlm.hlinux/types.hlinux/rbtree.hlinux/slab.hdlm_internal.hlinux/dlm_device.hmemory.hmidcomms.hrequestqueue.hutil.hdir.hmember.hlockspace.hast.hlock.hrcom.hrecover.hlvb_table.huser.hconfig.h
Detected Declarations
function dlm_modes_compatfunction dlm_print_lkbfunction dlm_print_rsbfunction dlm_dump_rsbfunction dlm_lock_recoveryfunction dlm_unlock_recoveryfunction dlm_lock_recovery_tryfunction can_be_queuedfunction force_blocking_astsfunction is_demotedfunction is_altmodefunction is_grantedfunction is_remotefunction is_process_copyfunction is_master_copyfunction middle_conversionfunction down_conversionfunction is_overlap_unlockfunction is_overlap_cancelfunction is_overlapfunction queue_castfunction queue_cast_overlapfunction queue_bastfunction rsb_toss_jiffiesfunction hold_rsbfunction dlm_hold_rsbfunction dlm_refcount_dec_and_write_lock_bhfunction dlm_kref_put_write_lock_bhfunction put_rsbfunction dlm_put_rsbfunction resume_scan_timerfunction resume_scan_timerfunction del_scanfunction add_scanfunction dlm_rsb_scanfunction get_rsb_structfunction dlm_search_rsb_treefunction rsb_insertfunction find_rsbfunction lookupfunction inactivefunction find_rsb_nodirfunction firstfunction validate_master_nodeidfunction __dlm_master_lookupfunction find_rsbfunction dlm_master_lookupfunction dlm_dump_rsb_hash
Annotated Snippet
if (!rv) {
/* rearm again try timer */
enable_scan_timer(ls, DLM_TOSS_TIMER_RETRY);
break;
}
r = list_first_entry_or_null(&ls->ls_scan_list, struct dlm_rsb,
res_scan_list);
if (!r) {
/* the next add_scan will enable the timer again */
spin_unlock(&ls->ls_scan_lock);
break;
}
/*
* If the first rsb is not yet expired, then stop because the
* list is sorted with nearest expiration first.
*/
if (time_before(jiffies, r->res_toss_time)) {
/* rearm with the next rsb to expire in the future */
enable_scan_timer(ls, r->res_toss_time);
spin_unlock(&ls->ls_scan_lock);
break;
}
/* in find_rsb_dir/nodir there is a reverse order of this
* lock, however this is only a trylock if we hit some
* possible contention we try it again.
*/
rv = write_trylock(&ls->ls_rsbtbl_lock);
if (!rv) {
spin_unlock(&ls->ls_scan_lock);
/* rearm again try timer */
enable_scan_timer(ls, DLM_TOSS_TIMER_RETRY);
break;
}
list_del(&r->res_slow_list);
rhashtable_remove_fast(&ls->ls_rsbtbl, &r->res_node,
dlm_rhash_rsb_params);
rsb_clear_flag(r, RSB_HASHED);
/* ls_rsbtbl_lock is not needed when calling send_remove() */
write_unlock(&ls->ls_rsbtbl_lock);
list_del_init(&r->res_scan_list);
spin_unlock(&ls->ls_scan_lock);
/* An rsb that is a dir record for a remote master rsb
* cannot be removed, and should not have a timer enabled.
*/
WARN_ON(!dlm_no_directory(ls) &&
(r->res_master_nodeid != our_nodeid) &&
(dlm_dir_nodeid(r) == our_nodeid));
/* We're the master of this rsb but we're not
* the directory record, so we need to tell the
* dir node to remove the dir record
*/
if (!dlm_no_directory(ls) &&
(r->res_master_nodeid == our_nodeid) &&
(dlm_dir_nodeid(r) != our_nodeid))
send_remove(r);
free_inactive_rsb(r);
}
}
/* If ls->ls_new_rsb is empty, return -EAGAIN, so the caller can
unlock any spinlocks, go back and call pre_rsb_struct again.
Otherwise, take an rsb off the list and return it. */
static int get_rsb_struct(struct dlm_ls *ls, const void *name, int len,
struct dlm_rsb **r_ret)
{
struct dlm_rsb *r;
r = dlm_allocate_rsb();
if (!r)
return -ENOMEM;
r->res_ls = ls;
r->res_length = len;
memcpy(r->res_name, name, len);
spin_lock_init(&r->res_lock);
INIT_LIST_HEAD(&r->res_lookup);
INIT_LIST_HEAD(&r->res_grantqueue);
INIT_LIST_HEAD(&r->res_convertqueue);
INIT_LIST_HEAD(&r->res_waitqueue);
Annotation
- Immediate include surface: `trace/events/dlm.h`, `linux/types.h`, `linux/rbtree.h`, `linux/slab.h`, `dlm_internal.h`, `linux/dlm_device.h`, `memory.h`, `midcomms.h`.
- Detected declarations: `function dlm_modes_compat`, `function dlm_print_lkb`, `function dlm_print_rsb`, `function dlm_dump_rsb`, `function dlm_lock_recovery`, `function dlm_unlock_recovery`, `function dlm_lock_recovery_try`, `function can_be_queued`, `function force_blocking_asts`, `function is_demoted`.
- 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.