Loading...
1#ifndef _BTRFS_SYSFS_H_
2#define _BTRFS_SYSFS_H_
3
4/*
5 * Data exported through sysfs
6 */
7extern u64 btrfs_debugfs_test;
8
9enum btrfs_feature_set {
10 FEAT_COMPAT,
11 FEAT_COMPAT_RO,
12 FEAT_INCOMPAT,
13 FEAT_MAX
14};
15
16#define __INIT_KOBJ_ATTR(_name, _mode, _show, _store) \
17{ \
18 .attr = { .name = __stringify(_name), .mode = _mode }, \
19 .show = _show, \
20 .store = _store, \
21}
22
23#define BTRFS_ATTR_RW(_name, _mode, _show, _store) \
24static struct kobj_attribute btrfs_attr_##_name = \
25 __INIT_KOBJ_ATTR(_name, _mode, _show, _store)
26#define BTRFS_ATTR(_name, _mode, _show) \
27 BTRFS_ATTR_RW(_name, _mode, _show, NULL)
28#define BTRFS_ATTR_PTR(_name) (&btrfs_attr_##_name.attr)
29
30#define BTRFS_RAID_ATTR(_name, _show) \
31static struct kobj_attribute btrfs_raid_attr_##_name = \
32 __INIT_KOBJ_ATTR(_name, 0444, _show, NULL)
33#define BTRFS_RAID_ATTR_PTR(_name) (&btrfs_raid_attr_##_name.attr)
34
35
36struct btrfs_feature_attr {
37 struct kobj_attribute kobj_attr;
38 enum btrfs_feature_set feature_set;
39 u64 feature_bit;
40};
41
42#define BTRFS_FEAT_ATTR(_name, _feature_set, _prefix, _feature_bit) \
43static struct btrfs_feature_attr btrfs_attr_##_name = { \
44 .kobj_attr = __INIT_KOBJ_ATTR(_name, S_IRUGO, \
45 btrfs_feature_attr_show, \
46 btrfs_feature_attr_store), \
47 .feature_set = _feature_set, \
48 .feature_bit = _prefix ##_## _feature_bit, \
49}
50#define BTRFS_FEAT_ATTR_PTR(_name) (&btrfs_attr_##_name.kobj_attr.attr)
51
52#define BTRFS_FEAT_ATTR_COMPAT(name, feature) \
53 BTRFS_FEAT_ATTR(name, FEAT_COMPAT, BTRFS_FEATURE_COMPAT, feature)
54#define BTRFS_FEAT_ATTR_COMPAT_RO(name, feature) \
55 BTRFS_FEAT_ATTR(name, FEAT_COMPAT_RO, BTRFS_FEATURE_COMPAT, feature)
56#define BTRFS_FEAT_ATTR_INCOMPAT(name, feature) \
57 BTRFS_FEAT_ATTR(name, FEAT_INCOMPAT, BTRFS_FEATURE_INCOMPAT, feature)
58
59/* convert from attribute */
60#define to_btrfs_feature_attr(a) \
61 container_of(a, struct btrfs_feature_attr, kobj_attr)
62#define attr_to_btrfs_attr(a) container_of(a, struct kobj_attribute, attr)
63#define attr_to_btrfs_feature_attr(a) \
64 to_btrfs_feature_attr(attr_to_btrfs_attr(a))
65char *btrfs_printable_features(enum btrfs_feature_set set, u64 flags);
66extern const char * const btrfs_feature_set_names[3];
67extern struct kobj_type space_info_ktype;
68extern struct kobj_type btrfs_raid_ktype;
69#endif /* _BTRFS_SYSFS_H_ */
1/* SPDX-License-Identifier: GPL-2.0 */
2
3#ifndef BTRFS_SYSFS_H
4#define BTRFS_SYSFS_H
5
6#include <linux/kobject.h>
7
8enum btrfs_feature_set {
9 FEAT_COMPAT,
10 FEAT_COMPAT_RO,
11 FEAT_INCOMPAT,
12 FEAT_MAX
13};
14
15char *btrfs_printable_features(enum btrfs_feature_set set, u64 flags);
16const char * const btrfs_feature_set_name(enum btrfs_feature_set set);
17int btrfs_sysfs_add_devices_dir(struct btrfs_fs_devices *fs_devices,
18 struct btrfs_device *one_device);
19int btrfs_sysfs_remove_devices_dir(struct btrfs_fs_devices *fs_devices,
20 struct btrfs_device *one_device);
21int btrfs_sysfs_add_fsid(struct btrfs_fs_devices *fs_devs);
22void btrfs_sysfs_remove_fsid(struct btrfs_fs_devices *fs_devs);
23void btrfs_sysfs_update_sprout_fsid(struct btrfs_fs_devices *fs_devices,
24 const u8 *fsid);
25void btrfs_sysfs_feature_update(struct btrfs_fs_info *fs_info,
26 u64 bit, enum btrfs_feature_set set);
27void btrfs_kobject_uevent(struct block_device *bdev, enum kobject_action action);
28
29int __init btrfs_init_sysfs(void);
30void __cold btrfs_exit_sysfs(void);
31int btrfs_sysfs_add_mounted(struct btrfs_fs_info *fs_info);
32void btrfs_sysfs_remove_mounted(struct btrfs_fs_info *fs_info);
33void btrfs_sysfs_add_block_group_type(struct btrfs_block_group *cache);
34int btrfs_sysfs_add_space_info_type(struct btrfs_fs_info *fs_info,
35 struct btrfs_space_info *space_info);
36void btrfs_sysfs_remove_space_info(struct btrfs_space_info *space_info);
37void btrfs_sysfs_update_devid(struct btrfs_device *device);
38
39int btrfs_sysfs_add_one_qgroup(struct btrfs_fs_info *fs_info,
40 struct btrfs_qgroup *qgroup);
41void btrfs_sysfs_del_qgroups(struct btrfs_fs_info *fs_info);
42int btrfs_sysfs_add_qgroups(struct btrfs_fs_info *fs_info);
43void btrfs_sysfs_del_one_qgroup(struct btrfs_fs_info *fs_info,
44 struct btrfs_qgroup *qgroup);
45
46#endif