fs/orangefs/orangefs-debugfs.c
Source file repositories/reference/linux-study-clean/fs/orangefs/orangefs-debugfs.c
File Facts
- System
- Linux kernel
- Corpus path
fs/orangefs/orangefs-debugfs.c- Extension
.c- Size
- 25992 bytes
- Lines
- 1050
- 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/debugfs.hlinux/slab.hlinux/uaccess.horangefs-debugfs.hprotocol.horangefs-kernel.h
Detected Declarations
struct __keyword_mask_sstruct client_debug_maskfunction orangefs_debugfs_initfunction orangefs_kernel_debug_initfunction orangefs_debugfs_cleanupfunction orangefs_debug_help_openfunction singlefunction help_stopfunction help_showfunction orangefs_client_debug_initfunction orangefs_debug_openfunction orangefs_debug_readfunction orangefs_debug_writefunction orangefs_prepare_cdm_arrayfunction orangefs_prepare_debugfs_help_stringfunction debug_mask_to_stringfunction do_k_stringfunction do_c_stringfunction keyword_is_amalgamfunction check_amalgam_keywordfunction debug_string_to_maskfunction do_c_maskfunction do_k_maskfunction orangefs_debugfs_new_client_maskfunction orangefs_debugfs_new_client_stringfunction orangefs_debugfs_new_debug
Annotated Snippet
static const struct file_operations debug_help_fops = {
.owner = THIS_MODULE,
.open = orangefs_debug_help_open,
.read = seq_read,
.release = seq_release,
.llseek = seq_lseek,
};
static const struct file_operations kernel_debug_fops = {
.owner = THIS_MODULE,
.open = orangefs_debug_open,
.read = orangefs_debug_read,
.write = orangefs_debug_write,
.llseek = generic_file_llseek,
};
static int client_all_index;
static int client_verbose_index;
static struct client_debug_mask *cdm_array;
static int cdm_element_count;
static struct client_debug_mask client_debug_mask;
/*
* Used to protect data in ORANGEFS_KMOD_DEBUG_FILE and
* ORANGEFS_KMOD_DEBUG_FILE.
*/
static DEFINE_MUTEX(orangefs_debug_lock);
/* Used to protect data in ORANGEFS_KMOD_DEBUG_HELP_FILE */
static DEFINE_MUTEX(orangefs_help_file_lock);
/*
* initialize kmod debug operations, create orangefs debugfs dir and
* ORANGEFS_KMOD_DEBUG_HELP_FILE.
*/
void orangefs_debugfs_init(int debug_mask)
{
/* convert input debug mask to a 64-bit unsigned integer */
orangefs_gossip_debug_mask = (unsigned long long)debug_mask;
/*
* set the kernel's gossip debug string; invalid mask values will
* be ignored.
*/
debug_mask_to_string(&orangefs_gossip_debug_mask, 0);
/* remove any invalid values from the mask */
debug_string_to_mask(kernel_debug_string, &orangefs_gossip_debug_mask,
0);
/*
* if the mask has a non-zero value, then indicate that the mask
* was set when the kernel module was loaded. The orangefs dev ioctl
* command will look at this boolean to determine if the kernel's
* debug mask should be overwritten when the client-core is started.
*/
if (orangefs_gossip_debug_mask != 0)
kernel_mask_set_mod_init = true;
pr_info("%s: called with debug mask: :%s: :%llx:\n",
__func__,
kernel_debug_string,
(unsigned long long)orangefs_gossip_debug_mask);
debug_dir = debugfs_create_dir("orangefs", NULL);
debugfs_create_file(ORANGEFS_KMOD_DEBUG_HELP_FILE, 0444, debug_dir,
debug_help_string, &debug_help_fops);
orangefs_debug_disabled = 0;
orangefs_kernel_debug_init();
}
/*
* initialize the kernel-debug file.
*/
static void orangefs_kernel_debug_init(void)
{
static char k_buffer[ORANGEFS_MAX_DEBUG_STRING_LEN] = { };
size_t len =
strscpy(k_buffer, kernel_debug_string, sizeof(k_buffer) - 1);
if (len > 0) {
k_buffer[len] = '\n';
k_buffer[len + 1] = '\0';
} else {
strscpy(k_buffer, "none\n");
Annotation
- Immediate include surface: `linux/debugfs.h`, `linux/slab.h`, `linux/uaccess.h`, `orangefs-debugfs.h`, `protocol.h`, `orangefs-kernel.h`.
- Detected declarations: `struct __keyword_mask_s`, `struct client_debug_mask`, `function orangefs_debugfs_init`, `function orangefs_kernel_debug_init`, `function orangefs_debugfs_cleanup`, `function orangefs_debug_help_open`, `function single`, `function help_stop`, `function help_show`, `function orangefs_client_debug_init`.
- 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.