diff options
author | Jeff Mahoney <jeffm@suse.com> | 2013-11-01 13:06:58 -0400 |
---|---|---|
committer | Chris Mason <clm@fb.com> | 2014-01-28 16:19:25 -0500 |
commit | 5ac1d209f11271fbfad0fa31ba56ec64c142d9ea (patch) | |
tree | 15f67ec6c85caa87b3358df2876f51becdf04b49 /fs/btrfs/sysfs.c | |
parent | 079b72bca30dbc74c86c7c7825b8c34eb86ce3ee (diff) |
btrfs: publish per-super attributes in sysfs
This patch adds per-super attributes to sysfs.
It doesn't publish any attributes yet, but does the proper lifetime
handling as well as the basic infrastructure to add new attributes.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Signed-off-by: Chris Mason <clm@fb.com>
Diffstat (limited to 'fs/btrfs/sysfs.c')
-rw-r--r-- | fs/btrfs/sysfs.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c index 9e217b581903..79be4a187af9 100644 --- a/fs/btrfs/sysfs.c +++ b/fs/btrfs/sysfs.c | |||
@@ -28,6 +28,25 @@ | |||
28 | #include "transaction.h" | 28 | #include "transaction.h" |
29 | #include "sysfs.h" | 29 | #include "sysfs.h" |
30 | 30 | ||
31 | static void btrfs_release_super_kobj(struct kobject *kobj); | ||
32 | static struct kobj_type btrfs_ktype = { | ||
33 | .sysfs_ops = &kobj_sysfs_ops, | ||
34 | .release = btrfs_release_super_kobj, | ||
35 | }; | ||
36 | |||
37 | static inline struct btrfs_fs_info *to_fs_info(struct kobject *kobj) | ||
38 | { | ||
39 | if (kobj->ktype != &btrfs_ktype) | ||
40 | return NULL; | ||
41 | return container_of(kobj, struct btrfs_fs_info, super_kobj); | ||
42 | } | ||
43 | |||
44 | static void btrfs_release_super_kobj(struct kobject *kobj) | ||
45 | { | ||
46 | struct btrfs_fs_info *fs_info = to_fs_info(kobj); | ||
47 | complete(&fs_info->kobj_unregister); | ||
48 | } | ||
49 | |||
31 | static ssize_t btrfs_feature_attr_show(struct kobject *kobj, | 50 | static ssize_t btrfs_feature_attr_show(struct kobject *kobj, |
32 | struct kobj_attribute *a, char *buf) | 51 | struct kobj_attribute *a, char *buf) |
33 | { | 52 | { |
@@ -65,6 +84,23 @@ static const struct attribute_group btrfs_feature_attr_group = { | |||
65 | /* /sys/fs/btrfs/ entry */ | 84 | /* /sys/fs/btrfs/ entry */ |
66 | static struct kset *btrfs_kset; | 85 | static struct kset *btrfs_kset; |
67 | 86 | ||
87 | void btrfs_sysfs_remove_one(struct btrfs_fs_info *fs_info) | ||
88 | { | ||
89 | kobject_del(&fs_info->super_kobj); | ||
90 | kobject_put(&fs_info->super_kobj); | ||
91 | wait_for_completion(&fs_info->kobj_unregister); | ||
92 | } | ||
93 | |||
94 | int btrfs_sysfs_add_one(struct btrfs_fs_info *fs_info) | ||
95 | { | ||
96 | int error; | ||
97 | |||
98 | init_completion(&fs_info->kobj_unregister); | ||
99 | error = kobject_init_and_add(&fs_info->super_kobj, &btrfs_ktype, NULL, | ||
100 | "%pU", fs_info->fsid); | ||
101 | return error; | ||
102 | } | ||
103 | |||
68 | int btrfs_init_sysfs(void) | 104 | int btrfs_init_sysfs(void) |
69 | { | 105 | { |
70 | int ret; | 106 | int ret; |