aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/btrfs/sysfs.c39
1 files changed, 15 insertions, 24 deletions
diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
index cd673ca9bb98..973d56e05698 100644
--- a/fs/btrfs/sysfs.c
+++ b/fs/btrfs/sysfs.c
@@ -184,7 +184,8 @@ static struct kobj_type btrfs_super_ktype = {
184 .release = btrfs_super_release, 184 .release = btrfs_super_release,
185}; 185};
186 186
187static struct kset btrfs_kset; 187/* /sys/fs/btrfs/ entry */
188static struct kset *btrfs_kset;
188 189
189int btrfs_sysfs_add_super(struct btrfs_fs_info *fs) 190int btrfs_sysfs_add_super(struct btrfs_fs_info *fs)
190{ 191{
@@ -208,14 +209,9 @@ int btrfs_sysfs_add_super(struct btrfs_fs_info *fs)
208 } 209 }
209 name[len] = '\0'; 210 name[len] = '\0';
210 211
211 fs->super_kobj.kset = &btrfs_kset; 212 fs->super_kobj.kset = btrfs_kset;
212 fs->super_kobj.ktype = &btrfs_super_ktype; 213 error = kobject_init_and_add(&fs->super_kobj, &btrfs_super_ktype,
213 214 NULL, "%s", name);
214 error = kobject_set_name(&fs->super_kobj, "%s", name);
215 if (error)
216 goto fail;
217
218 error = kobject_register(&fs->super_kobj);
219 if (error) 215 if (error)
220 goto fail; 216 goto fail;
221 217
@@ -232,15 +228,9 @@ int btrfs_sysfs_add_root(struct btrfs_root *root)
232{ 228{
233 int error; 229 int error;
234 230
235 root->root_kobj.ktype = &btrfs_root_ktype; 231 error = kobject_init_and_add(&root->root_kobj, &btrfs_root_ktype,
236 root->root_kobj.parent = &root->fs_info->super_kobj; 232 &root->fs_info->super_kobj,
237 233 "%s", root->name);
238 error = kobject_set_name(&root->root_kobj, "%s", root->name);
239 if (error) {
240 goto fail;
241 }
242
243 error = kobject_register(&root->root_kobj);
244 if (error) 234 if (error)
245 goto fail; 235 goto fail;
246 236
@@ -253,24 +243,25 @@ fail:
253 243
254void btrfs_sysfs_del_root(struct btrfs_root *root) 244void btrfs_sysfs_del_root(struct btrfs_root *root)
255{ 245{
256 kobject_unregister(&root->root_kobj); 246 kobject_put(&root->root_kobj);
257 wait_for_completion(&root->kobj_unregister); 247 wait_for_completion(&root->kobj_unregister);
258} 248}
259 249
260void btrfs_sysfs_del_super(struct btrfs_fs_info *fs) 250void btrfs_sysfs_del_super(struct btrfs_fs_info *fs)
261{ 251{
262 kobject_unregister(&fs->super_kobj); 252 kobject_put(&fs->super_kobj);
263 wait_for_completion(&fs->kobj_unregister); 253 wait_for_completion(&fs->kobj_unregister);
264} 254}
265 255
266int btrfs_init_sysfs() 256int btrfs_init_sysfs()
267{ 257{
268 kobj_set_kset_s(&btrfs_kset, fs_subsys); 258 btrfs_kset = kset_create_and_add("btrfs", NULL, fs_kobj);
269 kobject_set_name(&btrfs_kset.kobj, "btrfs"); 259 if (!btrfs_kset)
270 return kset_register(&btrfs_kset); 260 return -ENOMEM;
261 return 0;
271} 262}
272 263
273void btrfs_exit_sysfs() 264void btrfs_exit_sysfs()
274{ 265{
275 kset_unregister(&btrfs_kset); 266 kset_unregister(btrfs_kset);
276} 267}