fs/btrfs/sysfs.c
Source file repositories/reference/linux-study-clean/fs/btrfs/sysfs.c
File Facts
- System
- Linux kernel
- Corpus path
fs/btrfs/sysfs.c- Extension
.c- Size
- 72925 bytes
- Lines
- 2703
- 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
linux/sched.hlinux/sched/mm.hlinux/slab.hlinux/spinlock.hlinux/completion.hlinux/bug.hlinux/list.hlinux/string_choices.hmessages.hctree.hdiscard.hdisk-io.hsend.htransaction.hsysfs.hvolumes.hspace-info.hblock-group.hqgroup.hmisc.hfs.haccessors.h
Detected Declarations
struct btrfs_feature_attrstruct raid_kobjectfunction get_featuresfunction set_featuresfunction can_modify_featurefunction btrfs_feature_attr_showfunction btrfs_feature_attr_storefunction btrfs_feature_visiblefunction rmdir_subvol_showfunction supported_checksums_showfunction send_stream_version_showfunction supported_rescue_options_showfunction supported_sectorsizes_showfunction acl_showfunction temp_fsid_supported_showfunction btrfs_discardable_bytes_showfunction btrfs_discardable_extents_showfunction btrfs_discard_bitmap_bytes_showfunction btrfs_discard_bytes_saved_showfunction btrfs_discard_extent_bytes_showfunction btrfs_discard_iops_limit_showfunction btrfs_discard_iops_limit_storefunction btrfs_discard_kbps_limit_showfunction btrfs_discard_kbps_limit_storefunction btrfs_discard_max_discard_size_showfunction btrfs_discard_max_discard_size_storefunction btrfs_show_u64function global_rsv_size_showfunction global_rsv_reserved_showfunction raid_bytes_showfunction release_raid_kobjfunction btrfs_chunk_size_showfunction btrfs_chunk_size_storefunction btrfs_size_classes_showfunction list_for_each_entryfunction btrfs_force_chunk_alloc_storefunction btrfs_sinfo_bg_reclaim_threshold_showfunction btrfs_sinfo_bg_reclaim_threshold_storefunction btrfs_sinfo_dynamic_reclaim_showfunction btrfs_sinfo_dynamic_reclaim_storefunction btrfs_sinfo_periodic_reclaim_showfunction btrfs_sinfo_periodic_reclaim_storefunction space_info_releasefunction btrfs_label_showfunction btrfs_label_storefunction btrfs_nodesize_showfunction btrfs_sectorsize_showfunction btrfs_commit_stats_show
Annotated Snippet
struct btrfs_feature_attr {
struct kobj_attribute kobj_attr;
enum btrfs_feature_set feature_set;
u64 feature_bit;
};
/* For raid type sysfs entries */
struct raid_kobject {
u64 flags;
struct kobject kobj;
};
#define __INIT_KOBJ_ATTR(_name, _mode, _show, _store) \
{ \
.attr = { .name = __stringify(_name), .mode = _mode }, \
.show = _show, \
.store = _store, \
}
#define BTRFS_ATTR_W(_prefix, _name, _store) \
static struct kobj_attribute btrfs_attr_##_prefix##_##_name = \
__INIT_KOBJ_ATTR(_name, 0200, NULL, _store)
#define BTRFS_ATTR_RW(_prefix, _name, _show, _store) \
static struct kobj_attribute btrfs_attr_##_prefix##_##_name = \
__INIT_KOBJ_ATTR(_name, 0644, _show, _store)
#define BTRFS_ATTR(_prefix, _name, _show) \
static struct kobj_attribute btrfs_attr_##_prefix##_##_name = \
__INIT_KOBJ_ATTR(_name, 0444, _show, NULL)
#define BTRFS_ATTR_PTR(_prefix, _name) \
(&btrfs_attr_##_prefix##_##_name.attr)
#define BTRFS_FEAT_ATTR(_name, _feature_set, _feature_prefix, _feature_bit) \
static struct btrfs_feature_attr btrfs_attr_features_##_name = { \
.kobj_attr = __INIT_KOBJ_ATTR(_name, S_IRUGO, \
btrfs_feature_attr_show, \
btrfs_feature_attr_store), \
.feature_set = _feature_set, \
.feature_bit = _feature_prefix ##_## _feature_bit, \
}
#define BTRFS_FEAT_ATTR_PTR(_name) \
(&btrfs_attr_features_##_name.kobj_attr.attr)
#define BTRFS_FEAT_ATTR_COMPAT(name, feature) \
BTRFS_FEAT_ATTR(name, FEAT_COMPAT, BTRFS_FEATURE_COMPAT, feature)
#define BTRFS_FEAT_ATTR_COMPAT_RO(name, feature) \
BTRFS_FEAT_ATTR(name, FEAT_COMPAT_RO, BTRFS_FEATURE_COMPAT_RO, feature)
#define BTRFS_FEAT_ATTR_INCOMPAT(name, feature) \
BTRFS_FEAT_ATTR(name, FEAT_INCOMPAT, BTRFS_FEATURE_INCOMPAT, feature)
static inline struct btrfs_fs_info *to_fs_info(struct kobject *kobj);
static inline struct btrfs_fs_devices *to_fs_devs(struct kobject *kobj);
static struct kobject *get_btrfs_kobj(struct kobject *kobj);
static struct btrfs_feature_attr *to_btrfs_feature_attr(struct kobj_attribute *a)
{
return container_of(a, struct btrfs_feature_attr, kobj_attr);
}
static struct kobj_attribute *attr_to_btrfs_attr(struct attribute *attr)
{
return container_of(attr, struct kobj_attribute, attr);
}
static struct btrfs_feature_attr *attr_to_btrfs_feature_attr(
struct attribute *attr)
{
return to_btrfs_feature_attr(attr_to_btrfs_attr(attr));
}
static u64 get_features(struct btrfs_fs_info *fs_info,
enum btrfs_feature_set set)
{
struct btrfs_super_block *disk_super = fs_info->super_copy;
if (set == FEAT_COMPAT)
return btrfs_super_compat_flags(disk_super);
else if (set == FEAT_COMPAT_RO)
return btrfs_super_compat_ro_flags(disk_super);
else
return btrfs_super_incompat_flags(disk_super);
}
static void set_features(struct btrfs_fs_info *fs_info,
enum btrfs_feature_set set, u64 features)
{
struct btrfs_super_block *disk_super = fs_info->super_copy;
if (set == FEAT_COMPAT)
btrfs_set_super_compat_flags(disk_super, features);
Annotation
- Immediate include surface: `linux/sched.h`, `linux/sched/mm.h`, `linux/slab.h`, `linux/spinlock.h`, `linux/completion.h`, `linux/bug.h`, `linux/list.h`, `linux/string_choices.h`.
- Detected declarations: `struct btrfs_feature_attr`, `struct raid_kobject`, `function get_features`, `function set_features`, `function can_modify_feature`, `function btrfs_feature_attr_show`, `function btrfs_feature_attr_store`, `function btrfs_feature_visible`, `function rmdir_subvol_show`, `function supported_checksums_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.