fs/f2fs/sysfs.c
Source file repositories/reference/linux-study-clean/fs/f2fs/sysfs.c
File Facts
- System
- Linux kernel
- Corpus path
fs/f2fs/sysfs.c- Extension
.c- Size
- 58565 bytes
- Lines
- 2111
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/compiler.hlinux/proc_fs.hlinux/f2fs_fs.hlinux/seq_file.hlinux/unicode.hlinux/ioprio.hlinux/sysfs.hf2fs.hsegment.hgc.hiostat.htrace/events/f2fs.h
Detected Declarations
struct f2fs_attrstruct f2fs_base_attrfunction dirty_segments_showfunction free_segments_showfunction ovp_segments_showfunction lifetime_write_kbytes_showfunction sb_status_showfunction cp_status_showfunction pending_discard_showfunction issued_discard_showfunction queued_discard_showfunction undiscard_blks_showfunction atgc_enabled_showfunction gc_mode_showfunction features_showfunction current_reserved_blocks_showfunction unusable_showfunction encoding_showfunction encoding_flags_showfunction effective_lookup_mode_showfunction mounted_time_sec_showfunction moved_blocks_foreground_showfunction moved_blocks_background_showfunction avg_vblocks_showfunction defrag_blocks_showfunction main_blkaddr_showfunction __sbi_show_valuefunction f2fs_sbi_showfunction __sbi_store_valuefunction __sbi_storefunction f2fs_sbi_storefunction f2fs_attr_showfunction f2fs_attr_storefunction f2fs_sb_releasefunction f2fs_base_attr_showfunction f2fs_base_attr_storefunction f2fs_feature_showfunction f2fs_tune_showfunction f2fs_tune_storefunction f2fs_sb_feature_showfunction f2fs_stat_attr_showfunction f2fs_stat_attr_storefunction f2fs_stat_kobj_releasefunction f2fs_sb_feat_attr_showfunction f2fs_feature_list_kobj_releasefunction segment_info_seq_showfunction segment_bits_seq_showfunction victim_bits_seq_show
Annotated Snippet
struct f2fs_attr {
struct attribute attr;
ssize_t (*show)(struct f2fs_attr *a, struct f2fs_sb_info *sbi, char *buf);
ssize_t (*store)(struct f2fs_attr *a, struct f2fs_sb_info *sbi,
const char *buf, size_t len);
int struct_type;
int offset;
int size;
int id;
};
struct f2fs_base_attr {
struct attribute attr;
ssize_t (*show)(struct f2fs_base_attr *a, char *buf);
ssize_t (*store)(struct f2fs_base_attr *a, const char *buf, size_t len);
};
static ssize_t f2fs_sbi_show(struct f2fs_attr *a,
struct f2fs_sb_info *sbi, char *buf);
static unsigned char *__struct_ptr(struct f2fs_sb_info *sbi, int struct_type)
{
if (struct_type == GC_THREAD)
return (unsigned char *)sbi->gc_thread;
else if (struct_type == SM_INFO)
return (unsigned char *)SM_I(sbi);
else if (struct_type == DCC_INFO)
return (unsigned char *)SM_I(sbi)->dcc_info;
else if (struct_type == NM_INFO)
return (unsigned char *)NM_I(sbi);
else if (struct_type == F2FS_SBI || struct_type == RESERVED_BLOCKS)
return (unsigned char *)sbi;
#ifdef CONFIG_F2FS_FAULT_INJECTION
else if (struct_type == FAULT_INFO_RATE ||
struct_type == FAULT_INFO_TYPE ||
struct_type == FAULT_INFO_TIMEOUT)
return (unsigned char *)&F2FS_OPTION(sbi).fault_info;
#endif
#ifdef CONFIG_F2FS_STAT_FS
else if (struct_type == STAT_INFO)
return (unsigned char *)F2FS_STAT(sbi);
#endif
else if (struct_type == CPRC_INFO)
return (unsigned char *)&sbi->cprc_info;
else if (struct_type == ATGC_INFO)
return (unsigned char *)&sbi->am;
return NULL;
}
static ssize_t dirty_segments_show(struct f2fs_attr *a,
struct f2fs_sb_info *sbi, char *buf)
{
return sysfs_emit(buf, "%llu\n",
(unsigned long long)(dirty_segments(sbi)));
}
static ssize_t free_segments_show(struct f2fs_attr *a,
struct f2fs_sb_info *sbi, char *buf)
{
return sysfs_emit(buf, "%llu\n",
(unsigned long long)(free_segments(sbi)));
}
static ssize_t ovp_segments_show(struct f2fs_attr *a,
struct f2fs_sb_info *sbi, char *buf)
{
return sysfs_emit(buf, "%llu\n",
(unsigned long long)(overprovision_segments(sbi)));
}
static ssize_t lifetime_write_kbytes_show(struct f2fs_attr *a,
struct f2fs_sb_info *sbi, char *buf)
{
return sysfs_emit(buf, "%llu\n",
(unsigned long long)(sbi->kbytes_written +
((f2fs_get_sectors_written(sbi) -
sbi->sectors_written_start) >> 1)));
}
static ssize_t sb_status_show(struct f2fs_attr *a,
struct f2fs_sb_info *sbi, char *buf)
{
return sysfs_emit(buf, "%lx\n", sbi->s_flag);
}
static ssize_t cp_status_show(struct f2fs_attr *a,
struct f2fs_sb_info *sbi, char *buf)
{
return sysfs_emit(buf, "%x\n", le32_to_cpu(F2FS_CKPT(sbi)->ckpt_flags));
}
Annotation
- Immediate include surface: `linux/compiler.h`, `linux/proc_fs.h`, `linux/f2fs_fs.h`, `linux/seq_file.h`, `linux/unicode.h`, `linux/ioprio.h`, `linux/sysfs.h`, `f2fs.h`.
- Detected declarations: `struct f2fs_attr`, `struct f2fs_base_attr`, `function dirty_segments_show`, `function free_segments_show`, `function ovp_segments_show`, `function lifetime_write_kbytes_show`, `function sb_status_show`, `function cp_status_show`, `function pending_discard_show`, `function issued_discard_show`.
- 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.