fs/dlm/midcomms.c
Source file repositories/reference/linux-study-clean/fs/dlm/midcomms.c
File Facts
- System
- Linux kernel
- Corpus path
fs/dlm/midcomms.c- Extension
.c- Size
- 40113 bytes
- Lines
- 1515
- 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.hnet/tcp.hdlm_internal.hlowcomms.hconfig.hmemory.hlock.hutil.hmidcomms.h
Detected Declarations
struct midcomms_nodestruct dlm_mhandlestruct dlm_rawmsg_datafunction dlm_midcomms_flagsfunction dlm_midcomms_send_queue_cntfunction dlm_midcomms_versionfunction hlist_for_each_entry_srcufunction dlm_mhandle_releasefunction dlm_mhandle_deletefunction dlm_send_queue_flushfunction midcomms_node_resetfunction dlm_midcomms_addrfunction dlm_send_ackfunction dlm_send_ack_thresholdfunction dlm_send_finfunction dlm_receive_ackfunction dlm_pas_fin_ack_rcvfunction dlm_receive_buffer_3_2_tracefunction dlm_midcomms_receive_bufferfunction dlm_opts_check_msglenfunction dlm_midcomms_receive_buffer_3_2function dlm_midcomms_receive_buffer_3_1function dlm_validate_incoming_bufferfunction dlm_process_incoming_bufferfunction dlm_midcomms_unack_msg_resendfunction dlm_fill_opts_headerfunction midcomms_new_msg_cbfunction dlm_midcomms_commit_msg_3_2_tracefunction dlm_midcomms_commit_msg_3_2function dlm_midcomms_commit_mhandlefunction dlm_midcomms_startfunction dlm_midcomms_stopfunction dlm_midcomms_initfunction midcomms_node_releasefunction dlm_midcomms_exitfunction hlist_for_each_entry_srcufunction dlm_act_fin_ack_rcvfunction dlm_midcomms_add_memberfunction dlm_midcomms_remove_memberfunction dlm_midcomms_closefunction dlm_midcomms_stopfunction dlm_midcomms_version_waitfunction hlist_for_each_entry_srcufunction midcomms_shutdownfunction dlm_midcomms_shutdownfunction hlist_for_each_entry_srcufunction hlist_for_each_entry_srcufunction dlm_midcomms_close
Annotated Snippet
struct midcomms_node {
int nodeid;
uint32_t version;
atomic_t seq_send;
atomic_t seq_next;
/* These queues are unbound because we cannot drop any message in dlm.
* We could send a fence signal for a specific node to the cluster
* manager if queues hits some maximum value, however this handling
* not supported yet.
*/
struct list_head send_queue;
spinlock_t send_queue_lock;
atomic_t send_queue_cnt;
#define DLM_NODE_FLAG_CLOSE 1
#define DLM_NODE_FLAG_STOP_TX 2
#define DLM_NODE_FLAG_STOP_RX 3
atomic_t ulp_delivered;
unsigned long flags;
wait_queue_head_t shutdown_wait;
/* dlm tcp termination state */
#define DLM_CLOSED 1
#define DLM_ESTABLISHED 2
#define DLM_FIN_WAIT1 3
#define DLM_FIN_WAIT2 4
#define DLM_CLOSE_WAIT 5
#define DLM_LAST_ACK 6
#define DLM_CLOSING 7
int state;
spinlock_t state_lock;
/* counts how many lockspaces are using this node
* this refcount is necessary to determine if the
* node wants to disconnect.
*/
int users;
/* not protected by srcu, node_hash lifetime */
void *debugfs;
struct hlist_node hlist;
struct rcu_head rcu;
};
struct dlm_mhandle {
const union dlm_packet *inner_p;
struct midcomms_node *node;
struct dlm_opts *opts;
struct dlm_msg *msg;
bool committed;
uint32_t seq;
void (*ack_rcv)(struct midcomms_node *node);
/* get_mhandle/commit srcu idx exchange */
int idx;
struct list_head list;
struct rcu_head rcu;
};
static struct hlist_head node_hash[CONN_HASH_SIZE];
static DEFINE_SPINLOCK(nodes_lock);
DEFINE_STATIC_SRCU(nodes_srcu);
/* This mutex prevents that midcomms_close() is running while
* stop() or remove(). As I experienced invalid memory access
* behaviours when DLM_DEBUG_FENCE_TERMINATION is enabled and
* resetting machines. I will end in some double deletion in nodes
* datastructure.
*/
static DEFINE_MUTEX(close_lock);
struct kmem_cache *dlm_midcomms_cache_create(void)
{
return KMEM_CACHE(dlm_mhandle, 0);
}
static inline const char *dlm_state_str(int state)
{
switch (state) {
case DLM_CLOSED:
return "CLOSED";
case DLM_ESTABLISHED:
return "ESTABLISHED";
case DLM_FIN_WAIT1:
return "FIN_WAIT1";
case DLM_FIN_WAIT2:
return "FIN_WAIT2";
case DLM_CLOSE_WAIT:
Annotation
- Immediate include surface: `trace/events/dlm.h`, `net/tcp.h`, `dlm_internal.h`, `lowcomms.h`, `config.h`, `memory.h`, `lock.h`, `util.h`.
- Detected declarations: `struct midcomms_node`, `struct dlm_mhandle`, `struct dlm_rawmsg_data`, `function dlm_midcomms_flags`, `function dlm_midcomms_send_queue_cnt`, `function dlm_midcomms_version`, `function hlist_for_each_entry_srcu`, `function dlm_mhandle_release`, `function dlm_mhandle_delete`, `function dlm_send_queue_flush`.
- 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.