just a helper function to clean up the sysfs fsid kobjects

v2: update commit
Signed-off-by: Anand Jain <anand.j...@oracle.com>
---
 fs/btrfs/sysfs.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
index 95d6257..a8ee136 100644
--- a/fs/btrfs/sysfs.c
+++ b/fs/btrfs/sysfs.c
@@ -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);
-- 
2.0.0.153.g79dcccc

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to