linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Anand Jain <anand.jain@oracle.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH 06/15] btrfs: sysfs, move add remove _mounted function together
Date: Mon, 18 Nov 2019 16:46:47 +0800	[thread overview]
Message-ID: <20191118084656.3089-7-anand.jain@oracle.com> (raw)
In-Reply-To: <20191118084656.3089-1-anand.jain@oracle.com>

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(-)

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
-- 
2.23.0


  parent reply	other threads:[~2019-11-18  8:47 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-18  8:46 [PATCH 00/15] btrfs: sysfs, cleanups Anand Jain
2019-11-18  8:46 ` [PATCH 01/15] btrfs: sysfs, rename device_link add,remove functions Anand Jain
2019-11-18  8:46 ` [PATCH 02/15] btrfs: sysfs, rename btrfs_sysfs_add_device() Anand Jain
2019-11-18  8:46 ` [PATCH 03/15] btrfs: sysfs, rename btrfs_device member device_dir_kobj Anand Jain
2019-11-18  8:46 ` [PATCH 04/15] btrfs: sysfs, move declared struct near its use Anand Jain
2019-11-18 15:40   ` David Sterba
2019-11-18  8:46 ` [PATCH 05/15] btrfs: sysfs, move /sys/fs/btrfs/UUID related functions together Anand Jain
2019-11-19  9:24   ` Nikolay Borisov
2019-11-19 10:58     ` David Sterba
2019-11-20  5:56       ` Anand Jain
2019-11-22 17:48         ` David Sterba
2019-11-25  3:18           ` Anand Jain
2019-11-18  8:46 ` Anand Jain [this message]
2019-11-18  8:46 ` [PATCH 07/15] btrfs: sysfs, delete code in a comment Anand Jain
2019-11-18 15:39   ` David Sterba
2019-11-18  8:46 ` [PATCH 08/15] btrfs: sysfs, btrfs_sysfs_add_fsid() drop unused argument parent Anand Jain
2019-11-18  8:46 ` [PATCH 09/15] btrfs: sysfs, merge btrfs_sysfs_add device_dir and fsid Anand Jain
2019-11-18  8:46 ` [PATCH 10/15] btrfs: volume, btrfs_free_stale_devices() cleanup unreachable code Anand Jain
2019-11-18  8:46 ` [PATCH 11/15] btrfs: sysfs, migrate fs_decvices::fsid_kobject to struct btrfs_fs_info Anand Jain
2019-11-18  8:46 ` [PATCH 12/15] btrfs: sysfs, unexport btrfs_sysfs_add_mounted() Anand Jain
2019-11-18  8:46 ` [PATCH 13/15] btrfs: sysfs, cleanup btrfs_sysfs_remove_fsid() Anand Jain
2019-11-18  8:46 ` [PATCH 14/15] btrfs: sysfs, merge btrfs_sysfs_remove_fsid() helper function Anand Jain
2019-11-18  8:46 ` [PATCH 15/15] btrfs: sysfs, unexport btrfs_sysfs_remove_mounted() Anand Jain
2019-11-18 15:45 ` [PATCH 00/15] btrfs: sysfs, cleanups David Sterba
2019-11-19  6:44   ` Anand Jain
2019-11-19 12:37     ` David Sterba
2019-11-20  6:44       ` Anand Jain

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191118084656.3089-7-anand.jain@oracle.com \
    --to=anand.jain@oracle.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).