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 07/15] btrfs: cleanup btrfs_rm_device() promote fs_devices pointer
Date: Thu, 12 Apr 2018 10:29:30 +0800	[thread overview]
Message-ID: <20180412022938.8257-8-anand.jain@oracle.com> (raw)
In-Reply-To: <20180412022938.8257-1-anand.jain@oracle.com>

This function uses fs_info::fs_devices number of time, however we declare
and use it only at the end, instead do it in the beginning of the function
and use it.

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

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 5714cdaf9c03..db077c505fe0 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -1918,12 +1918,13 @@ int btrfs_rm_device(struct btrfs_fs_info *fs_info, const char *device_path,
 {
 	struct btrfs_device *device;
 	struct btrfs_fs_devices *cur_devices;
+	struct btrfs_fs_devices *fs_devices = fs_info->fs_devices;
 	u64 num_devices;
 	int ret = 0;
 
 	mutex_lock(&uuid_mutex);
 
-	num_devices = fs_info->fs_devices->num_devices;
+	num_devices = fs_devices->num_devices;
 	btrfs_dev_replace_read_lock(&fs_info->dev_replace);
 	if (btrfs_dev_replace_is_ongoing(&fs_info->dev_replace)) {
 		WARN_ON(num_devices < 1);
@@ -1987,7 +1988,7 @@ int btrfs_rm_device(struct btrfs_fs_info *fs_info, const char *device_path,
 	 */
 
 	cur_devices = device->fs_devices;
-	mutex_lock(&fs_info->fs_devices->device_list_mutex);
+	mutex_lock(&fs_devices->device_list_mutex);
 	list_del_rcu(&device->dev_list);
 
 	device->fs_devices->num_devices--;
@@ -2001,12 +2002,12 @@ int btrfs_rm_device(struct btrfs_fs_info *fs_info, const char *device_path,
 	if (device->bdev) {
 		device->fs_devices->open_devices--;
 		/* remove sysfs entry */
-		btrfs_sysfs_rm_device_link(fs_info->fs_devices, device);
+		btrfs_sysfs_rm_device_link(fs_devices, device);
 	}
 
 	num_devices = btrfs_super_num_devices(fs_info->super_copy) - 1;
 	btrfs_set_super_num_devices(fs_info->super_copy, num_devices);
-	mutex_unlock(&fs_info->fs_devices->device_list_mutex);
+	mutex_unlock(&fs_devices->device_list_mutex);
 
 	/*
 	 * at this point, the device is zero sized and detached from
@@ -2020,8 +2021,6 @@ int btrfs_rm_device(struct btrfs_fs_info *fs_info, const char *device_path,
 	call_rcu(&device->rcu, free_device_rcu);
 
 	if (cur_devices->open_devices == 0) {
-		struct btrfs_fs_devices *fs_devices;
-		fs_devices = fs_info->fs_devices;
 		while (fs_devices) {
 			if (fs_devices->seed == cur_devices) {
 				fs_devices->seed = cur_devices->seed;
@@ -2042,7 +2041,7 @@ int btrfs_rm_device(struct btrfs_fs_info *fs_info, const char *device_path,
 	if (test_bit(BTRFS_DEV_STATE_WRITEABLE, &device->dev_state)) {
 		mutex_lock(&fs_info->chunk_mutex);
 		list_add(&device->dev_alloc_list,
-			 &fs_info->fs_devices->alloc_list);
+			 &fs_devices->alloc_list);
 		device->fs_devices->rw_devices++;
 		mutex_unlock(&fs_info->chunk_mutex);
 	}
-- 
2.7.0


  parent reply	other threads:[~2018-04-12  2:27 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-12  2:29 [PATCH 0/15] Review uuid_mutex usage Anand Jain
2018-04-12  2:29 ` [PATCH 01/15] btrfs: optimize move uuid_mutex closer to the critical section Anand Jain
2018-04-12  2:29 ` [PATCH 02/15] btrfs: rename struct btrfs_fs_devices::list Anand Jain
2018-04-12  2:29 ` [PATCH 03/15] btrfs: cleanup __btrfs_open_devices() drop head pointer Anand Jain
2018-04-12  2:29 ` [PATCH 04/15] btrfs: rename __btrfs_close_devices to close_fs_devices Anand Jain
2018-04-12  2:29 ` [PATCH 05/15] btrfs: rename __btrfs_open_devices to open_fs_devices Anand Jain
2018-04-12  2:29 ` [PATCH 06/15] btrfs: cleanup find_device() drop list_head pointer Anand Jain
2018-04-12  2:29 ` Anand Jain [this message]
2018-04-12  2:29 ` [PATCH 08/15] btrfs: cleanup btrfs_rm_device() use cur_devices Anand Jain
2018-04-12  2:29 ` [PATCH 09/15] btrfs: uuid_mutex in read_chunk_tree, add a comment Anand Jain
2018-04-12  2:29 ` [PATCH 10/15] btrfs: drop uuid_mutex in btrfs_free_extra_devids() Anand Jain
2018-05-15 16:26   ` David Sterba
2018-05-22  9:11     ` Anand Jain
2018-05-23  2:54   ` [PATCH v3] " Anand Jain
2018-05-25 15:55     ` David Sterba
2018-05-28 10:14   ` [PATCH v4] " Anand Jain
2018-04-12  2:29 ` [PATCH 11/15] btrfs: drop uuid_mutex in btrfs_open_devices() Anand Jain
2018-04-12  2:29 ` [PATCH 12/15] btrfs: drop uuid_mutex in close_fs_devices() Anand Jain
2018-05-15 16:30   ` David Sterba
2018-05-22  9:12     ` Anand Jain
2018-04-12  2:29 ` [PATCH 13/15] btrfs: drop uuid_mutex in btrfs_dev_replace_finishing() Anand Jain
2018-04-12  2:29 ` [PATCH 14/15] btrfs: drop uuid_mutex in btrfs_destroy_dev_replace_tgtdev() Anand Jain
2018-04-12  2:29 ` [PATCH 15/15] btrfs: cleanup btrfs_destroy_dev_replace_tgtdev() localize btrfs_fs_devices Anand Jain
2018-04-16 19:52 ` [PATCH 0/15] Review uuid_mutex usage David Sterba
2018-04-18  9:56 ` [PATCH] btrfs: update uuid_mutex and device_list_mutex comments Anand Jain
2018-04-24 15:48   ` David Sterba
2018-05-16  5:09     ` Anand Jain
2018-04-19 15:22 ` [PATCH 0/15] Review uuid_mutex usage David Sterba
2018-05-15 16:33 ` David Sterba
2018-05-22  9:27   ` 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=20180412022938.8257-8-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).