Btrfs: sysfs: provide framework to remove all fsid sysfs kobject
authorAnand Jain <anand.jain@oracle.com>
Mon, 9 Mar 2015 22:38:32 +0000 (06:38 +0800)
committerDavid Sterba <dsterba@suse.cz>
Wed, 27 May 2015 10:27:21 +0000 (12:27 +0200)
Just a helper function to clean up the sysfs fsid kobjects.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
fs/btrfs/sysfs.c

index 4b9a8df3faea0c86519150edddfea3a2e874eb01..333ed084090752e7fc2b9d1a1f8761b7ffffc098 100644 (file)
@@ -515,7 +515,7 @@ static int addrm_unknown_feature_attrs(struct btrfs_fs_info *fs_info, bool add)
        return 0;
 }
 
-static void btrfs_sysfs_remove_fsid(struct btrfs_fs_devices *fs_devs)
+static void __btrfs_sysfs_remove_fsid(struct btrfs_fs_devices *fs_devs)
 {
        if (fs_devs->device_dir_kobj) {
                kobject_del(fs_devs->device_dir_kobj);
@@ -528,6 +528,21 @@ static void btrfs_sysfs_remove_fsid(struct btrfs_fs_devices *fs_devs)
        wait_for_completion(&fs_devs->kobj_unregister);
 }
 
+/* when fs_devs is NULL it will remove all fsid kobject */
+static void btrfs_sysfs_remove_fsid(struct btrfs_fs_devices *fs_devs)
+{
+       struct list_head *fs_uuids = btrfs_get_fs_uuids();
+
+       if (fs_devs) {
+               __btrfs_sysfs_remove_fsid(fs_devs);
+               return;
+       }
+
+       list_for_each_entry(fs_devs, fs_uuids, list) {
+               __btrfs_sysfs_remove_fsid(fs_devs);
+       }
+}
+
 void btrfs_sysfs_remove_one(struct btrfs_fs_info *fs_info)
 {
        btrfs_reset_fs_info_ptr(fs_info);