fs/ocfs2/stack_user.c
Source file repositories/reference/linux-study-clean/fs/ocfs2/stack_user.c
File Facts
- System
- Linux kernel
- Corpus path
fs/ocfs2/stack_user.c- Extension
.c- Size
- 29082 bytes
- Lines
- 1103
- Domain
- Core OS
- Bucket
- VFS And Filesystem Core
- Inferred role
- Core OS: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- 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/filelock.hlinux/miscdevice.hlinux/mutex.hlinux/slab.hlinux/reboot.hlinux/sched.hlinux/uaccess.hstackglue.hlinux/dlm_plock.h
Detected Declarations
struct ocfs2_live_connectionstruct ocfs2_control_privatestruct ocfs2_control_message_setnstruct ocfs2_control_message_setvstruct ocfs2_control_message_downenum ocfs2_connection_typefunction ocfs2_control_set_handshake_statefunction ocfs2_control_get_handshake_statefunction list_for_each_entryfunction fill_superfunction ocfs2_live_connection_dropfunction ocfs2_control_cfufunction ocfs2_control_validate_protocolfunction ocfs2_control_send_downfunction ocfs2_control_install_privatefunction ocfs2_control_get_this_nodefunction ocfs2_control_do_setnode_msgfunction ocfs2_control_do_setversion_msgfunction ocfs2_control_do_down_msgfunction ocfs2_control_messagefunction ocfs2_control_writefunction ocfs2_control_readfunction ocfs2_control_releasefunction ocfs2_control_openfunction ocfs2_control_initfunction ocfs2_control_exitfunction fsdlm_lock_ast_wrapperfunction fsdlm_blocking_ast_wrapperfunction user_dlm_lockfunction user_dlm_unlockfunction user_dlm_lock_statusfunction user_dlm_lvb_validfunction user_dlm_dump_lksbfunction fs_protocol_comparefunction lvb_to_versionfunction version_to_lvbfunction sync_wait_cbfunction sync_unlockfunction sync_lockfunction version_lockfunction version_unlockfunction get_protocol_versionfunction user_recover_prepfunction user_recover_donefunction user_cluster_disconnectfunction user_cluster_connectfunction user_cluster_this_nodefunction ocfs2_user_plugin_init
Annotated Snippet
static const struct file_operations ocfs2_control_fops = {
.open = ocfs2_control_open,
.release = ocfs2_control_release,
.read = ocfs2_control_read,
.write = ocfs2_control_write,
.owner = THIS_MODULE,
.llseek = default_llseek,
};
static struct miscdevice ocfs2_control_device = {
.minor = MISC_DYNAMIC_MINOR,
.name = "ocfs2_control",
.fops = &ocfs2_control_fops,
};
static int ocfs2_control_init(void)
{
int rc;
atomic_set(&ocfs2_control_opened, 0);
rc = misc_register(&ocfs2_control_device);
if (rc)
printk(KERN_ERR
"ocfs2: Unable to register ocfs2_control device "
"(errno %d)\n",
-rc);
return rc;
}
static void ocfs2_control_exit(void)
{
misc_deregister(&ocfs2_control_device);
}
static void fsdlm_lock_ast_wrapper(void *astarg)
{
struct ocfs2_dlm_lksb *lksb = astarg;
int status = lksb->lksb_fsdlm.sb_status;
/*
* For now we're punting on the issue of other non-standard errors
* where we can't tell if the unlock_ast or lock_ast should be called.
* The main "other error" that's possible is EINVAL which means the
* function was called with invalid args, which shouldn't be possible
* since the caller here is under our control. Other non-standard
* errors probably fall into the same category, or otherwise are fatal
* which means we can't carry on anyway.
*/
if (status == -DLM_EUNLOCK || status == -DLM_ECANCEL)
lksb->lksb_conn->cc_proto->lp_unlock_ast(lksb, 0);
else
lksb->lksb_conn->cc_proto->lp_lock_ast(lksb);
}
static void fsdlm_blocking_ast_wrapper(void *astarg, int level)
{
struct ocfs2_dlm_lksb *lksb = astarg;
lksb->lksb_conn->cc_proto->lp_blocking_ast(lksb, level);
}
static int user_dlm_lock(struct ocfs2_cluster_connection *conn,
int mode,
struct ocfs2_dlm_lksb *lksb,
u32 flags,
void *name,
unsigned int namelen)
{
if (!lksb->lksb_fsdlm.sb_lvbptr)
lksb->lksb_fsdlm.sb_lvbptr = (char *)lksb +
sizeof(struct dlm_lksb);
return dlm_lock(conn->cc_lockspace, mode, &lksb->lksb_fsdlm,
flags|DLM_LKF_NODLCKWT, name, namelen, 0,
fsdlm_lock_ast_wrapper, lksb,
fsdlm_blocking_ast_wrapper);
}
static int user_dlm_unlock(struct ocfs2_cluster_connection *conn,
struct ocfs2_dlm_lksb *lksb,
u32 flags)
{
return dlm_unlock(conn->cc_lockspace, lksb->lksb_fsdlm.sb_lkid,
flags, &lksb->lksb_fsdlm, lksb);
}
static int user_dlm_lock_status(struct ocfs2_dlm_lksb *lksb)
Annotation
- Immediate include surface: `linux/module.h`, `linux/fs.h`, `linux/filelock.h`, `linux/miscdevice.h`, `linux/mutex.h`, `linux/slab.h`, `linux/reboot.h`, `linux/sched.h`.
- Detected declarations: `struct ocfs2_live_connection`, `struct ocfs2_control_private`, `struct ocfs2_control_message_setn`, `struct ocfs2_control_message_setv`, `struct ocfs2_control_message_down`, `enum ocfs2_connection_type`, `function ocfs2_control_set_handshake_state`, `function ocfs2_control_get_handshake_state`, `function list_for_each_entry`, `function fill_super`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- 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.