Commit 6c52157f authored by Tomohiro Misono's avatar Tomohiro Misono Committed by David Sterba

btrfs: sysfs: Use enum/define value for feature array definitions

Use existing named values instead of the raw numbers.
Signed-off-by: default avatarTomohiro Misono <misono.tomohiro@jp.fujitsu.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 6dac13f8
...@@ -514,10 +514,11 @@ static inline struct btrfs_fs_info *to_fs_info(struct kobject *kobj) ...@@ -514,10 +514,11 @@ static inline struct btrfs_fs_info *to_fs_info(struct kobject *kobj)
} }
#define NUM_FEATURE_BITS 64 #define NUM_FEATURE_BITS 64
static char btrfs_unknown_feature_names[3][NUM_FEATURE_BITS][13]; #define BTRFS_FEATURE_NAME_MAX 13
static struct btrfs_feature_attr btrfs_feature_attrs[3][NUM_FEATURE_BITS]; 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 const u64 supported_feature_masks[3] = { static const u64 supported_feature_masks[FEAT_MAX] = {
[FEAT_COMPAT] = BTRFS_FEATURE_COMPAT_SUPP, [FEAT_COMPAT] = BTRFS_FEATURE_COMPAT_SUPP,
[FEAT_COMPAT_RO] = BTRFS_FEATURE_COMPAT_RO_SUPP, [FEAT_COMPAT_RO] = BTRFS_FEATURE_COMPAT_RO_SUPP,
[FEAT_INCOMPAT] = BTRFS_FEATURE_INCOMPAT_SUPP, [FEAT_INCOMPAT] = BTRFS_FEATURE_INCOMPAT_SUPP,
...@@ -609,7 +610,7 @@ void btrfs_sysfs_remove_mounted(struct btrfs_fs_info *fs_info) ...@@ -609,7 +610,7 @@ void btrfs_sysfs_remove_mounted(struct btrfs_fs_info *fs_info)
btrfs_sysfs_rm_device_link(fs_info->fs_devices, NULL); btrfs_sysfs_rm_device_link(fs_info->fs_devices, NULL);
} }
const char * const btrfs_feature_set_names[3] = { const char * const btrfs_feature_set_names[FEAT_MAX] = {
[FEAT_COMPAT] = "compat", [FEAT_COMPAT] = "compat",
[FEAT_COMPAT_RO] = "compat_ro", [FEAT_COMPAT_RO] = "compat_ro",
[FEAT_INCOMPAT] = "incompat", [FEAT_INCOMPAT] = "incompat",
...@@ -673,7 +674,7 @@ static void init_feature_attrs(void) ...@@ -673,7 +674,7 @@ static void init_feature_attrs(void)
if (fa->kobj_attr.attr.name) if (fa->kobj_attr.attr.name)
continue; continue;
snprintf(name, 13, "%s:%u", snprintf(name, BTRFS_FEATURE_NAME_MAX, "%s:%u",
btrfs_feature_set_names[set], i); btrfs_feature_set_names[set], i);
fa->kobj_attr.attr.name = name; fa->kobj_attr.attr.name = name;
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
extern u64 btrfs_debugfs_test; extern u64 btrfs_debugfs_test;
enum btrfs_feature_set { enum btrfs_feature_set {
FEAT_COMPAT, FEAT_COMPAT = 0,
FEAT_COMPAT_RO, FEAT_COMPAT_RO,
FEAT_INCOMPAT, FEAT_INCOMPAT,
FEAT_MAX FEAT_MAX
...@@ -77,7 +77,7 @@ attr_to_btrfs_feature_attr(struct attribute *attr) ...@@ -77,7 +77,7 @@ attr_to_btrfs_feature_attr(struct attribute *attr)
} }
char *btrfs_printable_features(enum btrfs_feature_set set, u64 flags); char *btrfs_printable_features(enum btrfs_feature_set set, u64 flags);
extern const char * const btrfs_feature_set_names[3]; extern const char * const btrfs_feature_set_names[FEAT_MAX];
extern struct kobj_type space_info_ktype; extern struct kobj_type space_info_ktype;
extern struct kobj_type btrfs_raid_ktype; extern struct kobj_type btrfs_raid_ktype;
int btrfs_sysfs_add_device_link(struct btrfs_fs_devices *fs_devices, int btrfs_sysfs_add_device_link(struct btrfs_fs_devices *fs_devices,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment