fs/ocfs2/dlm/dlmthread.c
Source file repositories/reference/linux-study-clean/fs/ocfs2/dlm/dlmthread.c
File Facts
- System
- Linux kernel
- Corpus path
fs/ocfs2/dlm/dlmthread.c- Extension
.c- Size
- 22195 bytes
- Lines
- 810
- 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
linux/module.hlinux/fs.hlinux/types.hlinux/highmem.hlinux/init.hlinux/sysctl.hlinux/random.hlinux/blkdev.hlinux/socket.hlinux/inet.hlinux/timer.hlinux/kthread.hlinux/delay.h../cluster/heartbeat.h../cluster/nodemanager.h../cluster/tcp.hdlmapi.hdlmcommon.hdlmdomain.h../cluster/masklog.h
Detected Declarations
function __dlm_wait_on_lockres_flagsfunction __dlm_lockres_has_locksfunction locksfunction __dlm_lockres_calc_usagefunction dlm_lockres_calc_usagefunction __dlm_do_purge_lockresfunction dlm_purge_lockresfunction dlm_run_purge_listfunction dlm_shuffle_listsfunction list_for_each_entryfunction list_for_each_entryfunction list_for_each_entryfunction dlm_kick_threadfunction __dlm_dirty_lockresfunction dlm_launch_threadfunction dlm_complete_threadfunction dlm_dirty_list_emptyfunction dlm_flush_astsfunction dlm_thread
Annotated Snippet
if (list_empty(&res->purge)) {
mlog(0, "%s: Adding res %.*s to purge list\n",
dlm->name, res->lockname.len, res->lockname.name);
res->last_used = jiffies;
dlm_lockres_get(res);
list_add_tail(&res->purge, &dlm->purge_list);
dlm->purge_count++;
}
} else if (!list_empty(&res->purge)) {
mlog(0, "%s: Removing res %.*s from purge list\n",
dlm->name, res->lockname.len, res->lockname.name);
list_del_init(&res->purge);
dlm_lockres_put(res);
dlm->purge_count--;
}
}
void dlm_lockres_calc_usage(struct dlm_ctxt *dlm,
struct dlm_lock_resource *res)
{
spin_lock(&dlm->spinlock);
spin_lock(&res->spinlock);
__dlm_lockres_calc_usage(dlm, res);
spin_unlock(&res->spinlock);
spin_unlock(&dlm->spinlock);
}
/*
* Do the real purge work:
* unhash the lockres, and
* clear flag DLM_LOCK_RES_DROPPING_REF.
* It requires dlm and lockres spinlock to be taken.
*/
void __dlm_do_purge_lockres(struct dlm_ctxt *dlm,
struct dlm_lock_resource *res)
{
assert_spin_locked(&dlm->spinlock);
assert_spin_locked(&res->spinlock);
if (!list_empty(&res->purge)) {
mlog(0, "%s: Removing res %.*s from purgelist\n",
dlm->name, res->lockname.len, res->lockname.name);
list_del_init(&res->purge);
dlm_lockres_put(res);
dlm->purge_count--;
}
if (!__dlm_lockres_unused(res)) {
mlog(ML_ERROR, "%s: res %.*s in use after deref\n",
dlm->name, res->lockname.len, res->lockname.name);
__dlm_print_one_lock_resource(res);
BUG();
}
__dlm_unhash_lockres(dlm, res);
spin_lock(&dlm->track_lock);
if (!list_empty(&res->tracking))
list_del_init(&res->tracking);
else {
mlog(ML_ERROR, "%s: Resource %.*s not on the Tracking list\n",
dlm->name, res->lockname.len, res->lockname.name);
__dlm_print_one_lock_resource(res);
}
spin_unlock(&dlm->track_lock);
/*
* lockres is not in the hash now. drop the flag and wake up
* any processes waiting in dlm_get_lock_resource.
*/
res->state &= ~DLM_LOCK_RES_DROPPING_REF;
}
static void dlm_purge_lockres(struct dlm_ctxt *dlm,
struct dlm_lock_resource *res)
{
int master;
int ret = 0;
assert_spin_locked(&dlm->spinlock);
assert_spin_locked(&res->spinlock);
master = (res->owner == dlm->node_num);
mlog(0, "%s: Purging res %.*s, master %d\n", dlm->name,
res->lockname.len, res->lockname.name, master);
Annotation
- Immediate include surface: `linux/module.h`, `linux/fs.h`, `linux/types.h`, `linux/highmem.h`, `linux/init.h`, `linux/sysctl.h`, `linux/random.h`, `linux/blkdev.h`.
- Detected declarations: `function __dlm_wait_on_lockres_flags`, `function __dlm_lockres_has_locks`, `function locks`, `function __dlm_lockres_calc_usage`, `function dlm_lockres_calc_usage`, `function __dlm_do_purge_lockres`, `function dlm_purge_lockres`, `function dlm_run_purge_list`, `function dlm_shuffle_lists`, `function list_for_each_entry`.
- 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.