[06/15] btrfs: sysfs, move add remove _mounted function together
diff mbox series

Message ID 20191118084656.3089-7-anand.jain@oracle.com
State New
Headers show
Series
  • btrfs: sysfs, cleanups
Related show

Commit Message

Anand Jain Nov. 18, 2019, 8:46 a.m. UTC
The functions btrfs_sysfs_add_mounted() and btrfs_sysfs_remove_mounted()
which add and remove files and directory under /sys/fs/btrfs/UUID keep
them together to improve readability. No functional changes.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 fs/btrfs/sysfs.c | 132 +++++++++++++++++++++++------------------------
 1 file changed, 66 insertions(+), 66 deletions(-)

Patch
diff mbox series

diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
index 370f30561001..724af1322dce 100644
--- a/fs/btrfs/sysfs.c
+++ b/fs/btrfs/sysfs.c
@@ -742,21 +742,6 @@  static int addrm_unknown_feature_attrs(struct btrfs_fs_info *fs_info, bool add)
 	return 0;
 }
 
-void btrfs_sysfs_remove_mounted(struct btrfs_fs_info *fs_info)
-{
-	btrfs_reset_fs_info_ptr(fs_info);
-
-	if (fs_info->space_info_kobj) {
-		sysfs_remove_files(fs_info->space_info_kobj, allocation_attrs);
-		kobject_del(fs_info->space_info_kobj);
-		kobject_put(fs_info->space_info_kobj);
-	}
-	addrm_unknown_feature_attrs(fs_info, false);
-	sysfs_remove_group(&fs_info->fs_devices->fsid_kobj, &btrfs_feature_attr_group);
-	sysfs_remove_files(&fs_info->fs_devices->fsid_kobj, btrfs_attrs);
-	btrfs_sysfs_remove_device_info(fs_info->fs_devices, NULL);
-}
-
 static const char * const btrfs_feature_set_names[FEAT_MAX] = {
 	[FEAT_COMPAT]	 = "compat",
 	[FEAT_COMPAT_RO] = "compat_ro",
@@ -1028,6 +1013,72 @@  void btrfs_kobject_uevent(struct block_device *bdev, enum kobject_action action)
 			&disk_to_dev(bdev->bd_disk)->kobj);
 }
 
+void btrfs_sysfs_remove_mounted(struct btrfs_fs_info *fs_info)
+{
+	btrfs_reset_fs_info_ptr(fs_info);
+
+	if (fs_info->space_info_kobj) {
+		sysfs_remove_files(fs_info->space_info_kobj, allocation_attrs);
+		kobject_del(fs_info->space_info_kobj);
+		kobject_put(fs_info->space_info_kobj);
+	}
+	addrm_unknown_feature_attrs(fs_info, false);
+	sysfs_remove_group(&fs_info->fs_devices->fsid_kobj, &btrfs_feature_attr_group);
+	sysfs_remove_files(&fs_info->fs_devices->fsid_kobj, btrfs_attrs);
+	btrfs_sysfs_remove_device_info(fs_info->fs_devices, NULL);
+}
+
+int btrfs_sysfs_add_mounted(struct btrfs_fs_info *fs_info)
+{
+	int error;
+	struct btrfs_fs_devices *fs_devs = fs_info->fs_devices;
+	struct kobject *fsid_kobj = &fs_devs->fsid_kobj;
+
+	btrfs_set_fs_info_ptr(fs_info);
+
+	error = btrfs_sysfs_add_device_info(fs_devs, NULL);
+	if (error)
+		return error;
+
+	error = sysfs_create_files(fsid_kobj, btrfs_attrs);
+	if (error) {
+		btrfs_sysfs_remove_device_info(fs_devs, NULL);
+		return error;
+	}
+
+	error = sysfs_create_group(fsid_kobj,
+				   &btrfs_feature_attr_group);
+	if (error)
+		goto failure;
+
+#ifdef CONFIG_BTRFS_DEBUG
+	error = sysfs_create_group(fsid_kobj,
+				   &btrfs_debug_feature_attr_group);
+	if (error)
+		goto failure;
+#endif
+
+	error = addrm_unknown_feature_attrs(fs_info, true);
+	if (error)
+		goto failure;
+
+	fs_info->space_info_kobj = kobject_create_and_add("allocation",
+						  fsid_kobj);
+	if (!fs_info->space_info_kobj) {
+		error = -ENOMEM;
+		goto failure;
+	}
+
+	error = sysfs_create_files(fs_info->space_info_kobj, allocation_attrs);
+	if (error)
+		goto failure;
+
+	return 0;
+failure:
+	btrfs_sysfs_remove_mounted(fs_info);
+	return error;
+}
+
 void btrfs_sysfs_update_sprout_fsid(struct btrfs_fs_devices *fs_devices,
 				    const u8 *fsid)
 {
@@ -1097,57 +1148,6 @@  int btrfs_sysfs_add_fsid(struct btrfs_fs_devices *fs_devs,
 	return 0;
 }
 
-int btrfs_sysfs_add_mounted(struct btrfs_fs_info *fs_info)
-{
-	int error;
-	struct btrfs_fs_devices *fs_devs = fs_info->fs_devices;
-	struct kobject *fsid_kobj = &fs_devs->fsid_kobj;
-
-	btrfs_set_fs_info_ptr(fs_info);
-
-	error = btrfs_sysfs_add_device_info(fs_devs, NULL);
-	if (error)
-		return error;
-
-	error = sysfs_create_files(fsid_kobj, btrfs_attrs);
-	if (error) {
-		btrfs_sysfs_remove_device_info(fs_devs, NULL);
-		return error;
-	}
-
-	error = sysfs_create_group(fsid_kobj,
-				   &btrfs_feature_attr_group);
-	if (error)
-		goto failure;
-
-#ifdef CONFIG_BTRFS_DEBUG
-	error = sysfs_create_group(fsid_kobj,
-				   &btrfs_debug_feature_attr_group);
-	if (error)
-		goto failure;
-#endif
-
-	error = addrm_unknown_feature_attrs(fs_info, true);
-	if (error)
-		goto failure;
-
-	fs_info->space_info_kobj = kobject_create_and_add("allocation",
-						  fsid_kobj);
-	if (!fs_info->space_info_kobj) {
-		error = -ENOMEM;
-		goto failure;
-	}
-
-	error = sysfs_create_files(fs_info->space_info_kobj, allocation_attrs);
-	if (error)
-		goto failure;
-
-	return 0;
-failure:
-	btrfs_sysfs_remove_mounted(fs_info);
-	return error;
-}
-
 
 /*
  * Change per-fs features in /sys/fs/btrfs/UUID/features to match current