fs/ocfs2/dlmfs/dlmfs.c
Source file repositories/reference/linux-study-clean/fs/ocfs2/dlmfs/dlmfs.c
File Facts
- System
- Linux kernel
- Corpus path
fs/ocfs2/dlmfs/dlmfs.c- Extension
.c- Size
- 15140 bytes
- Lines
- 638
- 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/fs_context.hlinux/pagemap.hlinux/types.hlinux/slab.hlinux/highmem.hlinux/init.hlinux/string.hlinux/backing-dev.hlinux/poll.hlinux/uaccess.h../stackglue.huserdlm.h../cluster/masklog.h
Detected Declarations
function param_set_dlmfs_capabilitiesfunction param_get_dlmfs_capabilitiesfunction dlmfs_decode_open_flagsfunction dlmfs_file_openfunction dlmfs_file_releasefunction dlmfs_file_setattrfunction dlmfs_file_pollfunction dlmfs_file_readfunction dlmfs_file_writefunction dlmfs_init_oncefunction dlmfs_free_inodefunction dlmfs_evict_inodefunction dlmfs_createfunction dlmfs_unlinkfunction dlmfs_fill_superfunction dlmfs_get_treefunction dlmfs_init_fs_contextfunction init_dlmfs_fsfunction exit_dlmfs_fsmodule init init_dlmfs_fs
Annotated Snippet
static const struct file_operations dlmfs_file_operations;
static const struct inode_operations dlmfs_dir_inode_operations;
static const struct inode_operations dlmfs_root_inode_operations;
static const struct inode_operations dlmfs_file_inode_operations;
static struct kmem_cache *dlmfs_inode_cache;
struct workqueue_struct *user_dlm_worker;
/*
* These are the ABI capabilities of dlmfs.
*
* Over time, dlmfs has added some features that were not part of the
* initial ABI. Unfortunately, some of these features are not detectable
* via standard usage. For example, Linux's default poll always returns
* EPOLLIN, so there is no way for a caller of poll(2) to know when dlmfs
* added poll support. Instead, we provide this list of new capabilities.
*
* Capabilities is a read-only attribute. We do it as a module parameter
* so we can discover it whether dlmfs is built in, loaded, or even not
* loaded.
*
* The ABI features are local to this machine's dlmfs mount. This is
* distinct from the locking protocol, which is concerned with inter-node
* interaction.
*
* Capabilities:
* - bast : EPOLLIN against the file descriptor of a held lock
* signifies a bast fired on the lock.
*/
#define DLMFS_CAPABILITIES "bast stackglue"
static int param_set_dlmfs_capabilities(const char *val,
const struct kernel_param *kp)
{
printk(KERN_ERR "%s: readonly parameter\n", kp->name);
return -EINVAL;
}
static int param_get_dlmfs_capabilities(char *buffer,
const struct kernel_param *kp)
{
return sysfs_emit(buffer, DLMFS_CAPABILITIES);
}
module_param_call(capabilities, param_set_dlmfs_capabilities,
param_get_dlmfs_capabilities, NULL, 0444);
MODULE_PARM_DESC(capabilities, DLMFS_CAPABILITIES);
/*
* decodes a set of open flags into a valid lock level and a set of flags.
* returns < 0 if we have invalid flags
* flags which mean something to us:
* O_RDONLY -> PRMODE level
* O_WRONLY -> EXMODE level
*
* O_NONBLOCK -> NOQUEUE
*/
static int dlmfs_decode_open_flags(int open_flags,
int *level,
int *flags)
{
if (open_flags & (O_WRONLY|O_RDWR))
*level = DLM_LOCK_EX;
else
*level = DLM_LOCK_PR;
*flags = 0;
if (open_flags & O_NONBLOCK)
*flags |= DLM_LKF_NOQUEUE;
return 0;
}
static int dlmfs_file_open(struct inode *inode,
struct file *file)
{
int status, level, flags;
struct dlmfs_filp_private *fp = NULL;
struct dlmfs_inode_private *ip;
if (S_ISDIR(inode->i_mode))
BUG();
mlog(0, "open called on inode %llu, flags 0x%x\n", inode->i_ino,
file->f_flags);
status = dlmfs_decode_open_flags(file->f_flags, &level, &flags);
if (status < 0)
goto bail;
Annotation
- Immediate include surface: `linux/module.h`, `linux/fs.h`, `linux/fs_context.h`, `linux/pagemap.h`, `linux/types.h`, `linux/slab.h`, `linux/highmem.h`, `linux/init.h`.
- Detected declarations: `function param_set_dlmfs_capabilities`, `function param_get_dlmfs_capabilities`, `function dlmfs_decode_open_flags`, `function dlmfs_file_open`, `function dlmfs_file_release`, `function dlmfs_file_setattr`, `function dlmfs_file_poll`, `function dlmfs_file_read`, `function dlmfs_file_write`, `function dlmfs_init_once`.
- 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.