aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnand Jain <Anand.Jain@oracle.com>2015-03-09 18:38:24 -0400
committerDavid Sterba <dsterba@suse.cz>2015-05-27 06:27:19 -0400
commitaaf13305160490531b0d5ee4d56d32fc09f9bfa0 (patch)
treeb6388608a420a3f24a3b7aa6d33cbd0ef2efd269
parent4d435731f99db87020730c4b17e1da148908340e (diff)
Btrfs: sysfs: reorder the kobject creations
As of now the order in which the kobjects are created at btrfs_sysfs_add_one() is.. fsid features unknown features (dynamic features) devices. Since we would move fsid and device kobject to fs_devices from fs_info structure, this patch will reorder in which the kobjects are created as below. fsid devices features unknown features (dynamic features) And hence the btrfs_sysfs_remove_one() will follow the same in reverse order. and the device kobject destroy now can be moved into the function __btrfs_sysfs_remove_one() Signed-off-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: David Sterba <dsterba@suse.cz>
-rw-r--r--fs/btrfs/sysfs.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
index 6218d31a6912..8eb2463c973c 100644
--- a/fs/btrfs/sysfs.c
+++ b/fs/btrfs/sysfs.c
@@ -510,6 +510,13 @@ static int addrm_unknown_feature_attrs(struct btrfs_fs_info *fs_info, bool add)
510 510
511static void __btrfs_sysfs_remove_one(struct btrfs_fs_info *fs_info) 511static void __btrfs_sysfs_remove_one(struct btrfs_fs_info *fs_info)
512{ 512{
513 if (fs_info->device_dir_kobj) {
514 btrfs_kobj_rm_device(fs_info, NULL);
515 kobject_del(fs_info->device_dir_kobj);
516 kobject_put(fs_info->device_dir_kobj);
517 fs_info->device_dir_kobj = NULL;
518 }
519
513 kobject_del(&fs_info->super_kobj); 520 kobject_del(&fs_info->super_kobj);
514 kobject_put(&fs_info->super_kobj); 521 kobject_put(&fs_info->super_kobj);
515 wait_for_completion(&fs_info->kobj_unregister); 522 wait_for_completion(&fs_info->kobj_unregister);
@@ -522,12 +529,6 @@ void btrfs_sysfs_remove_one(struct btrfs_fs_info *fs_info)
522 kobject_del(fs_info->space_info_kobj); 529 kobject_del(fs_info->space_info_kobj);
523 kobject_put(fs_info->space_info_kobj); 530 kobject_put(fs_info->space_info_kobj);
524 } 531 }
525 if (fs_info->device_dir_kobj) {
526 btrfs_kobj_rm_device(fs_info, NULL);
527 kobject_del(fs_info->device_dir_kobj);
528 kobject_put(fs_info->device_dir_kobj);
529 fs_info->device_dir_kobj = NULL;
530 }
531 addrm_unknown_feature_attrs(fs_info, false); 532 addrm_unknown_feature_attrs(fs_info, false);
532 sysfs_remove_group(&fs_info->super_kobj, &btrfs_feature_attr_group); 533 sysfs_remove_group(&fs_info->super_kobj, &btrfs_feature_attr_group);
533 __btrfs_sysfs_remove_one(fs_info); 534 __btrfs_sysfs_remove_one(fs_info);
@@ -700,6 +701,12 @@ int btrfs_sysfs_add_one(struct btrfs_fs_info *fs_info)
700 if (error) 701 if (error)
701 return error; 702 return error;
702 703
704 error = btrfs_kobj_add_device(fs_info, NULL);
705 if (error) {
706 __btrfs_sysfs_remove_one(fs_info);
707 return error;
708 }
709
703 error = sysfs_create_group(&fs_info->super_kobj, 710 error = sysfs_create_group(&fs_info->super_kobj,
704 &btrfs_feature_attr_group); 711 &btrfs_feature_attr_group);
705 if (error) { 712 if (error) {
@@ -711,10 +718,6 @@ int btrfs_sysfs_add_one(struct btrfs_fs_info *fs_info)
711 if (error) 718 if (error)
712 goto failure; 719 goto failure;
713 720
714 error = btrfs_kobj_add_device(fs_info, NULL);
715 if (error)
716 goto failure;
717
718 fs_info->space_info_kobj = kobject_create_and_add("allocation", 721 fs_info->space_info_kobj = kobject_create_and_add("allocation",
719 &fs_info->super_kobj); 722 &fs_info->super_kobj);
720 if (!fs_info->space_info_kobj) { 723 if (!fs_info->space_info_kobj) {