fs/ocfs2/dlm/dlmmaster.c
Source file repositories/reference/linux-study-clean/fs/ocfs2/dlm/dlmmaster.c
File Facts
- System
- Linux kernel
- Corpus path
fs/ocfs2/dlm/dlmmaster.c- Extension
.c- Size
- 99020 bytes
- Lines
- 3552
- 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/module.hlinux/fs.hlinux/types.hlinux/slab.hlinux/highmem.hlinux/init.hlinux/sysctl.hlinux/random.hlinux/blkdev.hlinux/socket.hlinux/inet.hlinux/spinlock.hlinux/delay.hlinux/string_choices.h../cluster/heartbeat.h../cluster/nodemanager.h../cluster/tcp.hdlmapi.hdlmcommon.hdlmdomain.hdlmdebug.h../cluster/masklog.h
Detected Declarations
struct dlm_bitmap_diff_iterenum dlm_node_state_changefunction dlm_mle_equalfunction dlm_is_host_downfunction __dlm_mle_attach_hb_eventsfunction __dlm_mle_detach_hb_eventsfunction dlm_mle_detach_hb_eventsfunction dlm_get_mle_inusefunction dlm_put_mle_inusefunction __dlm_put_mlefunction dlm_put_mlefunction dlm_get_mlefunction dlm_init_mlefunction __dlm_unlink_mlefunction __dlm_insert_mlefunction dlm_find_mlefunction dlm_hb_event_notify_attachedfunction list_for_each_entryfunction dlm_mle_node_downfunction dlm_mle_node_upfunction dlm_init_mle_cachefunction dlm_destroy_mle_cachefunction dlm_mle_releasefunction dlm_init_master_cachesfunction dlm_destroy_master_cachesfunction dlm_lockres_releasefunction dlm_lockres_putfunction dlm_init_lockresfunction dlm_lockres_set_refmap_bitfunction dlm_lockres_clear_refmap_bitfunction __dlm_lockres_grab_inflight_reffunction dlm_lockres_grab_inflight_reffunction dlm_lockres_drop_inflight_reffunction __dlm_lockres_grab_inflight_workerfunction __dlm_lockres_drop_inflight_workerfunction dlm_lockres_drop_inflight_workerfunction assert_masterfunction dlm_wait_for_lock_masteryfunction dlm_bitmap_diff_iter_initfunction dlm_bitmap_diff_iter_nextfunction dlm_restart_lock_masteryfunction dlm_do_master_requestfunction dlm_master_request_handlerfunction __dlm_lookup_lockresfunction dlm_do_assert_masterfunction dlm_assert_master_handlerfunction dlm_assert_master_post_handlerfunction dlm_dispatch_assert_master
Annotated Snippet
if (hlist_unhashed(&tmpres->hash_node)) {
spin_unlock(&tmpres->spinlock);
dlm_lockres_put(tmpres);
tmpres = NULL;
goto lookup;
}
/* Wait on the thread that is mastering the resource */
if (tmpres->owner == DLM_LOCK_RES_OWNER_UNKNOWN) {
__dlm_wait_on_lockres(tmpres);
BUG_ON(tmpres->owner == DLM_LOCK_RES_OWNER_UNKNOWN);
spin_unlock(&tmpres->spinlock);
dlm_lockres_put(tmpres);
tmpres = NULL;
goto lookup;
}
/* Wait on the resource purge to complete before continuing */
if (tmpres->state & DLM_LOCK_RES_DROPPING_REF) {
BUG_ON(tmpres->owner == dlm->node_num);
__dlm_wait_on_lockres_flags(tmpres,
DLM_LOCK_RES_DROPPING_REF);
spin_unlock(&tmpres->spinlock);
dlm_lockres_put(tmpres);
tmpres = NULL;
goto lookup;
}
/* Grab inflight ref to pin the resource */
dlm_lockres_grab_inflight_ref(dlm, tmpres);
spin_unlock(&tmpres->spinlock);
if (res) {
spin_lock(&dlm->track_lock);
if (!list_empty(&res->tracking))
list_del_init(&res->tracking);
else
mlog(ML_ERROR, "Resource %.*s not "
"on the Tracking list\n",
res->lockname.len,
res->lockname.name);
spin_unlock(&dlm->track_lock);
dlm_lockres_put(res);
}
res = tmpres;
goto leave;
}
if (!res) {
spin_unlock(&dlm->spinlock);
mlog(0, "allocating a new resource\n");
/* nothing found and we need to allocate one. */
alloc_mle = kmem_cache_alloc(dlm_mle_cache, GFP_NOFS);
if (!alloc_mle)
goto leave;
res = dlm_new_lockres(dlm, lockid, namelen);
if (!res)
goto leave;
goto lookup;
}
mlog(0, "no lockres found, allocated our own: %p\n", res);
if (flags & LKM_LOCAL) {
/* caller knows it's safe to assume it's not mastered elsewhere
* DONE! return right away */
spin_lock(&res->spinlock);
dlm_change_lockres_owner(dlm, res, dlm->node_num);
__dlm_insert_lockres(dlm, res);
dlm_lockres_grab_inflight_ref(dlm, res);
spin_unlock(&res->spinlock);
spin_unlock(&dlm->spinlock);
/* lockres still marked IN_PROGRESS */
goto wake_waiters;
}
/* check master list to see if another node has started mastering it */
spin_lock(&dlm->master_lock);
/* if we found a block, wait for lock to be mastered by another node */
blocked = dlm_find_mle(dlm, &mle, (char *)lockid, namelen);
if (blocked) {
int mig;
if (mle->type == DLM_MLE_MASTER) {
mlog(ML_ERROR, "master entry for nonexistent lock!\n");
BUG();
}
mig = (mle->type == DLM_MLE_MIGRATION);
/* if there is a migration in progress, let the migration
* finish before continuing. we can wait for the absence
Annotation
- Immediate include surface: `linux/module.h`, `linux/fs.h`, `linux/types.h`, `linux/slab.h`, `linux/highmem.h`, `linux/init.h`, `linux/sysctl.h`, `linux/random.h`.
- Detected declarations: `struct dlm_bitmap_diff_iter`, `enum dlm_node_state_change`, `function dlm_mle_equal`, `function dlm_is_host_down`, `function __dlm_mle_attach_hb_events`, `function __dlm_mle_detach_hb_events`, `function dlm_mle_detach_hb_events`, `function dlm_get_mle_inuse`, `function dlm_put_mle_inuse`, `function __dlm_put_mle`.
- 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.