#include <linux/sched.h>
#include <linux/sched/mm.h>
#include <linux/slab.h>
#include <linux/spinlock.h>
#include <linux/completion.h>
#include <linux/bug.h>
#include <linux/list.h>
#include <crypto/hash.h>
#include "messages.h"
#include "ctree.h"
#include "discard.h"
#include "disk-io.h"
#include "send.h"
#include "transaction.h"
#include "sysfs.h"
#include "volumes.h"
#include "space-info.h"
#include "block-group.h"
#include "qgroup.h"
#include "misc.h"
#include "fs.h"
#include "accessors.h"
struct btrfs_feature_attr { … };
struct raid_kobject { … };
#define __INIT_KOBJ_ATTR(_name, _mode, _show, _store) …
#define BTRFS_ATTR_W(_prefix, _name, _store) …
#define BTRFS_ATTR_RW(_prefix, _name, _show, _store) …
#define BTRFS_ATTR(_prefix, _name, _show) …
#define BTRFS_ATTR_PTR(_prefix, _name) …
#define BTRFS_FEAT_ATTR(_name, _feature_set, _feature_prefix, _feature_bit) …
#define BTRFS_FEAT_ATTR_PTR(_name) …
#define BTRFS_FEAT_ATTR_COMPAT(name, feature) …
#define BTRFS_FEAT_ATTR_COMPAT_RO(name, feature) …
#define BTRFS_FEAT_ATTR_INCOMPAT(name, 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)
{ … }
static struct kobj_attribute *attr_to_btrfs_attr(struct attribute *attr)
{ … }
static struct btrfs_feature_attr *attr_to_btrfs_feature_attr(
struct attribute *attr)
{ … }
static u64 get_features(struct btrfs_fs_info *fs_info,
enum btrfs_feature_set set)
{ … }
static void set_features(struct btrfs_fs_info *fs_info,
enum btrfs_feature_set set, u64 features)
{ … }
static int can_modify_feature(struct btrfs_feature_attr *fa)
{ … }
static ssize_t btrfs_feature_attr_show(struct kobject *kobj,
struct kobj_attribute *a, char *buf)
{ … }
static ssize_t btrfs_feature_attr_store(struct kobject *kobj,
struct kobj_attribute *a,
const char *buf, size_t count)
{ … }
static umode_t btrfs_feature_visible(struct kobject *kobj,
struct attribute *attr, int unused)
{ … }
BTRFS_FEAT_ATTR_INCOMPAT(…);
BTRFS_FEAT_ATTR_INCOMPAT(…);
BTRFS_FEAT_ATTR_INCOMPAT(…);
BTRFS_FEAT_ATTR_INCOMPAT(…);
BTRFS_FEAT_ATTR_INCOMPAT(…);
BTRFS_FEAT_ATTR_INCOMPAT(…);
BTRFS_FEAT_ATTR_INCOMPAT(…);
BTRFS_FEAT_ATTR_INCOMPAT(…);
BTRFS_FEAT_ATTR_INCOMPAT(…);
BTRFS_FEAT_ATTR_COMPAT_RO(…);
BTRFS_FEAT_ATTR_COMPAT_RO(…);
BTRFS_FEAT_ATTR_INCOMPAT(…);
BTRFS_FEAT_ATTR_INCOMPAT(…);
#ifdef CONFIG_BLK_DEV_ZONED
BTRFS_FEAT_ATTR_INCOMPAT(…);
#endif
#ifdef CONFIG_BTRFS_DEBUG
BTRFS_FEAT_ATTR_INCOMPAT(…);
BTRFS_FEAT_ATTR_INCOMPAT(…);
#endif
#ifdef CONFIG_FS_VERITY
BTRFS_FEAT_ATTR_COMPAT_RO(…);
#endif
static struct attribute *btrfs_supported_feature_attrs[] = …;
static const struct attribute_group btrfs_feature_attr_group = …;
static ssize_t rmdir_subvol_show(struct kobject *kobj,
struct kobj_attribute *ka, char *buf)
{ … }
BTRFS_ATTR(…);
static ssize_t supported_checksums_show(struct kobject *kobj,
struct kobj_attribute *a, char *buf)
{ … }
BTRFS_ATTR(…);
static ssize_t send_stream_version_show(struct kobject *kobj,
struct kobj_attribute *ka, char *buf)
{ … }
BTRFS_ATTR(…);
static const char *rescue_opts[] = …;
static ssize_t supported_rescue_options_show(struct kobject *kobj,
struct kobj_attribute *a,
char *buf)
{ … }
BTRFS_ATTR(…);
static ssize_t supported_sectorsizes_show(struct kobject *kobj,
struct kobj_attribute *a,
char *buf)
{ … }
BTRFS_ATTR(…);
static ssize_t acl_show(struct kobject *kobj, struct kobj_attribute *a, char *buf)
{ … }
BTRFS_ATTR(…);
static ssize_t temp_fsid_supported_show(struct kobject *kobj,
struct kobj_attribute *a, char *buf)
{ … }
BTRFS_ATTR(…);
static struct attribute *btrfs_supported_static_feature_attrs[] = …;
static const struct attribute_group btrfs_static_feature_attr_group = …;
#define discard_to_fs_info(_kobj) …
static ssize_t btrfs_discardable_bytes_show(struct kobject *kobj,
struct kobj_attribute *a,
char *buf)
{ … }
BTRFS_ATTR(…);
static ssize_t btrfs_discardable_extents_show(struct kobject *kobj,
struct kobj_attribute *a,
char *buf)
{ … }
BTRFS_ATTR(…);
static ssize_t btrfs_discard_bitmap_bytes_show(struct kobject *kobj,
struct kobj_attribute *a,
char *buf)
{ … }
BTRFS_ATTR(…);
static ssize_t btrfs_discard_bytes_saved_show(struct kobject *kobj,
struct kobj_attribute *a,
char *buf)
{ … }
BTRFS_ATTR(…);
static ssize_t btrfs_discard_extent_bytes_show(struct kobject *kobj,
struct kobj_attribute *a,
char *buf)
{ … }
BTRFS_ATTR(…);
static ssize_t btrfs_discard_iops_limit_show(struct kobject *kobj,
struct kobj_attribute *a,
char *buf)
{ … }
static ssize_t btrfs_discard_iops_limit_store(struct kobject *kobj,
struct kobj_attribute *a,
const char *buf, size_t len)
{ … }
BTRFS_ATTR_RW(…);
static ssize_t btrfs_discard_kbps_limit_show(struct kobject *kobj,
struct kobj_attribute *a,
char *buf)
{ … }
static ssize_t btrfs_discard_kbps_limit_store(struct kobject *kobj,
struct kobj_attribute *a,
const char *buf, size_t len)
{ … }
BTRFS_ATTR_RW(…);
static ssize_t btrfs_discard_max_discard_size_show(struct kobject *kobj,
struct kobj_attribute *a,
char *buf)
{ … }
static ssize_t btrfs_discard_max_discard_size_store(struct kobject *kobj,
struct kobj_attribute *a,
const char *buf, size_t len)
{ … }
BTRFS_ATTR_RW(…);
static const struct attribute *discard_attrs[] = …;
#ifdef CONFIG_BTRFS_DEBUG
static const struct attribute *btrfs_debug_mount_attrs[] = …;
static struct attribute *btrfs_debug_feature_attrs[] = …;
static const struct attribute_group btrfs_debug_feature_attr_group = …;
#endif
static ssize_t btrfs_show_u64(u64 *value_ptr, spinlock_t *lock, char *buf)
{ … }
static ssize_t global_rsv_size_show(struct kobject *kobj,
struct kobj_attribute *ka, char *buf)
{ … }
BTRFS_ATTR(…);
static ssize_t global_rsv_reserved_show(struct kobject *kobj,
struct kobj_attribute *a, char *buf)
{ … }
BTRFS_ATTR(…);
#define to_space_info(_kobj) …
#define to_raid_kobj(_kobj) …
static ssize_t raid_bytes_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf);
BTRFS_ATTR(…);
BTRFS_ATTR(…);
static ssize_t raid_bytes_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf)
{ … }
static struct attribute *raid_attrs[] = …;
ATTRIBUTE_GROUPS(…);
static void release_raid_kobj(struct kobject *kobj)
{ … }
static const struct kobj_type btrfs_raid_ktype = …;
#define SPACE_INFO_ATTR(field) …
static ssize_t btrfs_chunk_size_show(struct kobject *kobj,
struct kobj_attribute *a, char *buf)
{ … }
static ssize_t btrfs_chunk_size_store(struct kobject *kobj,
struct kobj_attribute *a,
const char *buf, size_t len)
{ … }
static ssize_t btrfs_size_classes_show(struct kobject *kobj,
struct kobj_attribute *a, char *buf)
{ … }
#ifdef CONFIG_BTRFS_DEBUG
static ssize_t btrfs_force_chunk_alloc_store(struct kobject *kobj,
struct kobj_attribute *a,
const char *buf, size_t len)
{ … }
BTRFS_ATTR_W(…);
#endif
SPACE_INFO_ATTR(…);
SPACE_INFO_ATTR(…);
SPACE_INFO_ATTR(…);
SPACE_INFO_ATTR(…);
SPACE_INFO_ATTR(…);
SPACE_INFO_ATTR(…);
SPACE_INFO_ATTR(…);
SPACE_INFO_ATTR(…);
SPACE_INFO_ATTR(…);
SPACE_INFO_ATTR(…);
SPACE_INFO_ATTR(…);
SPACE_INFO_ATTR(…);
SPACE_INFO_ATTR(…);
BTRFS_ATTR_RW(…);
BTRFS_ATTR(…);
static ssize_t btrfs_sinfo_bg_reclaim_threshold_show(struct kobject *kobj,
struct kobj_attribute *a,
char *buf)
{ … }
static ssize_t btrfs_sinfo_bg_reclaim_threshold_store(struct kobject *kobj,
struct kobj_attribute *a,
const char *buf, size_t len)
{ … }
BTRFS_ATTR_RW(…);
static ssize_t btrfs_sinfo_dynamic_reclaim_show(struct kobject *kobj,
struct kobj_attribute *a,
char *buf)
{ … }
static ssize_t btrfs_sinfo_dynamic_reclaim_store(struct kobject *kobj,
struct kobj_attribute *a,
const char *buf, size_t len)
{ … }
BTRFS_ATTR_RW(…);
static ssize_t btrfs_sinfo_periodic_reclaim_show(struct kobject *kobj,
struct kobj_attribute *a,
char *buf)
{ … }
static ssize_t btrfs_sinfo_periodic_reclaim_store(struct kobject *kobj,
struct kobj_attribute *a,
const char *buf, size_t len)
{ … }
BTRFS_ATTR_RW(…);
static struct attribute *space_info_attrs[] = …;
ATTRIBUTE_GROUPS(…);
static void space_info_release(struct kobject *kobj)
{ … }
static const struct kobj_type space_info_ktype = …;
static const struct attribute *allocation_attrs[] = …;
static ssize_t btrfs_label_show(struct kobject *kobj,
struct kobj_attribute *a, char *buf)
{ … }
static ssize_t btrfs_label_store(struct kobject *kobj,
struct kobj_attribute *a,
const char *buf, size_t len)
{ … }
BTRFS_ATTR_RW(…);
static ssize_t btrfs_nodesize_show(struct kobject *kobj,
struct kobj_attribute *a, char *buf)
{ … }
BTRFS_ATTR(…);
static ssize_t btrfs_sectorsize_show(struct kobject *kobj,
struct kobj_attribute *a, char *buf)
{ … }
BTRFS_ATTR(…);
static ssize_t btrfs_commit_stats_show(struct kobject *kobj,
struct kobj_attribute *a, char *buf)
{ … }
static ssize_t btrfs_commit_stats_store(struct kobject *kobj,
struct kobj_attribute *a,
const char *buf, size_t len)
{ … }
BTRFS_ATTR_RW(…);
static ssize_t btrfs_clone_alignment_show(struct kobject *kobj,
struct kobj_attribute *a, char *buf)
{ … }
BTRFS_ATTR(…);
static ssize_t quota_override_show(struct kobject *kobj,
struct kobj_attribute *a, char *buf)
{ … }
static ssize_t quota_override_store(struct kobject *kobj,
struct kobj_attribute *a,
const char *buf, size_t len)
{ … }
BTRFS_ATTR_RW(…);
static ssize_t btrfs_metadata_uuid_show(struct kobject *kobj,
struct kobj_attribute *a, char *buf)
{ … }
BTRFS_ATTR(…);
static ssize_t btrfs_checksum_show(struct kobject *kobj,
struct kobj_attribute *a, char *buf)
{ … }
BTRFS_ATTR(…);
static ssize_t btrfs_exclusive_operation_show(struct kobject *kobj,
struct kobj_attribute *a, char *buf)
{ … }
BTRFS_ATTR(…);
static ssize_t btrfs_generation_show(struct kobject *kobj,
struct kobj_attribute *a, char *buf)
{ … }
BTRFS_ATTR(…);
static ssize_t btrfs_temp_fsid_show(struct kobject *kobj,
struct kobj_attribute *a, char *buf)
{ … }
BTRFS_ATTR(…);
static const char * const btrfs_read_policy_name[] = …;
static ssize_t btrfs_read_policy_show(struct kobject *kobj,
struct kobj_attribute *a, char *buf)
{ … }
static ssize_t btrfs_read_policy_store(struct kobject *kobj,
struct kobj_attribute *a,
const char *buf, size_t len)
{ … }
BTRFS_ATTR_RW(…);
static ssize_t btrfs_bg_reclaim_threshold_show(struct kobject *kobj,
struct kobj_attribute *a,
char *buf)
{ … }
static ssize_t btrfs_bg_reclaim_threshold_store(struct kobject *kobj,
struct kobj_attribute *a,
const char *buf, size_t len)
{ … }
BTRFS_ATTR_RW(…);
#ifdef CONFIG_BTRFS_DEBUG
static ssize_t btrfs_offload_csum_show(struct kobject *kobj,
struct kobj_attribute *a, char *buf)
{ … }
static ssize_t btrfs_offload_csum_store(struct kobject *kobj,
struct kobj_attribute *a, const char *buf,
size_t len)
{ … }
BTRFS_ATTR_RW(…);
#endif
static const struct attribute *btrfs_attrs[] = …;
static void btrfs_release_fsid_kobj(struct kobject *kobj)
{ … }
static const struct kobj_type btrfs_ktype = …;
static inline struct btrfs_fs_devices *to_fs_devs(struct kobject *kobj)
{ … }
static inline struct btrfs_fs_info *to_fs_info(struct kobject *kobj)
{ … }
static struct kobject *get_btrfs_kobj(struct kobject *kobj)
{ … }
#define NUM_FEATURE_BITS …
#define BTRFS_FEATURE_NAME_MAX …
static char btrfs_unknown_feature_names[FEAT_MAX][NUM_FEATURE_BITS][BTRFS_FEATURE_NAME_MAX];
static struct btrfs_feature_attr btrfs_feature_attrs[FEAT_MAX][NUM_FEATURE_BITS];
static_assert(…);
static_assert(…);
static const u64 supported_feature_masks[FEAT_MAX] = …;
static int addrm_unknown_feature_attrs(struct btrfs_fs_info *fs_info, bool add)
{ … }
static void __btrfs_sysfs_remove_fsid(struct btrfs_fs_devices *fs_devs)
{ … }
void btrfs_sysfs_remove_fsid(struct btrfs_fs_devices *fs_devs)
{ … }
static void btrfs_sysfs_remove_fs_devices(struct btrfs_fs_devices *fs_devices)
{ … }
void btrfs_sysfs_remove_mounted(struct btrfs_fs_info *fs_info)
{ … }
static const char * const btrfs_feature_set_names[FEAT_MAX] = …;
const char *btrfs_feature_set_name(enum btrfs_feature_set set)
{ … }
char *btrfs_printable_features(enum btrfs_feature_set set, u64 flags)
{ … }
static void init_feature_attrs(void)
{ … }
void btrfs_sysfs_add_block_group_type(struct btrfs_block_group *cache)
{ … }
void btrfs_sysfs_remove_space_info(struct btrfs_space_info *space_info)
{ … }
static const char *alloc_name(u64 flags)
{ … }
int btrfs_sysfs_add_space_info_type(struct btrfs_fs_info *fs_info,
struct btrfs_space_info *space_info)
{ … }
void btrfs_sysfs_remove_device(struct btrfs_device *device)
{ … }
static ssize_t btrfs_devinfo_in_fs_metadata_show(struct kobject *kobj,
struct kobj_attribute *a,
char *buf)
{ … }
BTRFS_ATTR(…);
static ssize_t btrfs_devinfo_missing_show(struct kobject *kobj,
struct kobj_attribute *a, char *buf)
{ … }
BTRFS_ATTR(…);
static ssize_t btrfs_devinfo_replace_target_show(struct kobject *kobj,
struct kobj_attribute *a,
char *buf)
{ … }
BTRFS_ATTR(…);
static ssize_t btrfs_devinfo_scrub_speed_max_show(struct kobject *kobj,
struct kobj_attribute *a,
char *buf)
{ … }
static ssize_t btrfs_devinfo_scrub_speed_max_store(struct kobject *kobj,
struct kobj_attribute *a,
const char *buf, size_t len)
{ … }
BTRFS_ATTR_RW(…);
static ssize_t btrfs_devinfo_writeable_show(struct kobject *kobj,
struct kobj_attribute *a, char *buf)
{ … }
BTRFS_ATTR(…);
static ssize_t btrfs_devinfo_fsid_show(struct kobject *kobj,
struct kobj_attribute *a, char *buf)
{ … }
BTRFS_ATTR(…);
static ssize_t btrfs_devinfo_error_stats_show(struct kobject *kobj,
struct kobj_attribute *a, char *buf)
{ … }
BTRFS_ATTR(…);
static struct attribute *devid_attrs[] = …;
ATTRIBUTE_GROUPS(…);
static void btrfs_release_devid_kobj(struct kobject *kobj)
{ … }
static const struct kobj_type devid_ktype = …;
int btrfs_sysfs_add_device(struct btrfs_device *device)
{ … }
static int btrfs_sysfs_add_fs_devices(struct btrfs_fs_devices *fs_devices)
{ … }
void btrfs_kobject_uevent(struct block_device *bdev, enum kobject_action action)
{ … }
void btrfs_sysfs_update_sprout_fsid(struct btrfs_fs_devices *fs_devices)
{ … }
void btrfs_sysfs_update_devid(struct btrfs_device *device)
{ … }
static struct kset *btrfs_kset;
int btrfs_sysfs_add_fsid(struct btrfs_fs_devices *fs_devs)
{ … }
int btrfs_sysfs_add_mounted(struct btrfs_fs_info *fs_info)
{ … }
static ssize_t qgroup_enabled_show(struct kobject *qgroups_kobj,
struct kobj_attribute *a,
char *buf)
{ … }
BTRFS_ATTR(…);
static ssize_t qgroup_mode_show(struct kobject *qgroups_kobj,
struct kobj_attribute *a,
char *buf)
{ … }
BTRFS_ATTR(…);
static ssize_t qgroup_inconsistent_show(struct kobject *qgroups_kobj,
struct kobj_attribute *a,
char *buf)
{ … }
BTRFS_ATTR(…);
static ssize_t qgroup_drop_subtree_thres_show(struct kobject *qgroups_kobj,
struct kobj_attribute *a,
char *buf)
{ … }
static ssize_t qgroup_drop_subtree_thres_store(struct kobject *qgroups_kobj,
struct kobj_attribute *a,
const char *buf, size_t len)
{ … }
BTRFS_ATTR_RW(…);
static struct attribute *qgroups_attrs[] = …;
ATTRIBUTE_GROUPS(…);
static void qgroups_release(struct kobject *kobj)
{ … }
static const struct kobj_type qgroups_ktype = …;
static inline struct btrfs_fs_info *qgroup_kobj_to_fs_info(struct kobject *kobj)
{ … }
#define QGROUP_ATTR(_member, _show_name) …
#define QGROUP_RSV_ATTR(_name, _type) …
QGROUP_ATTR(…);
QGROUP_ATTR(…);
QGROUP_ATTR(…);
QGROUP_ATTR(…);
QGROUP_ATTR(…);
QGROUP_RSV_ATTR(…);
QGROUP_RSV_ATTR(…);
QGROUP_RSV_ATTR(…);
static struct attribute *qgroup_attrs[] = …;
ATTRIBUTE_GROUPS(…);
static void qgroup_release(struct kobject *kobj)
{ … }
static const struct kobj_type qgroup_ktype = …;
int btrfs_sysfs_add_one_qgroup(struct btrfs_fs_info *fs_info,
struct btrfs_qgroup *qgroup)
{ … }
void btrfs_sysfs_del_qgroups(struct btrfs_fs_info *fs_info)
{ … }
int btrfs_sysfs_add_qgroups(struct btrfs_fs_info *fs_info)
{ … }
void btrfs_sysfs_del_one_qgroup(struct btrfs_fs_info *fs_info,
struct btrfs_qgroup *qgroup)
{ … }
void btrfs_sysfs_feature_update(struct btrfs_fs_info *fs_info)
{ … }
int __init btrfs_init_sysfs(void)
{ … }
void __cold btrfs_exit_sysfs(void)
{ … }