linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Anand Jain <anand.jain@oracle.com>
To: dsterba@suse.cz
Cc: linux-btrfs@vger.kernel.org
Subject: [PATCH 07/13] btrfs: clean up and optimize __check_raid_min_device()
Date: Sat, 13 Feb 2016 10:01:34 +0800	[thread overview]
Message-ID: <1455328900-1476-8-git-send-email-anand.jain@oracle.com> (raw)
In-Reply-To: <1455328900-1476-1-git-send-email-anand.jain@oracle.com>

__check_raid_min_device() which was pealed from btrfs_rm_device()
maintianed its original code to show the block move. This patch cleans up
__check_raid_min_device().

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

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 506d1fd..191eb82 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -1703,52 +1703,47 @@ out:
 	return ret;
 }
 
-static int __check_raid_min_devices(struct btrfs_root *root)
+static int __check_raid_min_devices(struct btrfs_fs_info *fs_info)
 {
 	u64 all_avail;
 	u64 num_devices;
 	unsigned seq;
-	int ret = 0;
 
-	num_devices = root->fs_info->fs_devices->num_devices;
-	btrfs_dev_replace_lock(&root->fs_info->dev_replace);
-	if (btrfs_dev_replace_is_ongoing(&root->fs_info->dev_replace)) {
+	num_devices = fs_info->fs_devices->num_devices;
+	btrfs_dev_replace_lock(&fs_info->dev_replace);
+	if (btrfs_dev_replace_is_ongoing(&fs_info->dev_replace)) {
 		WARN_ON(num_devices < 1);
 		num_devices--;
 	}
-	btrfs_dev_replace_unlock(&root->fs_info->dev_replace);
+	btrfs_dev_replace_unlock(&fs_info->dev_replace);
 
 	do {
-		seq = read_seqbegin(&root->fs_info->profiles_lock);
+		seq = read_seqbegin(&fs_info->profiles_lock);
 
-		all_avail = root->fs_info->avail_data_alloc_bits |
-			    root->fs_info->avail_system_alloc_bits |
-			    root->fs_info->avail_metadata_alloc_bits;
-	} while (read_seqretry(&root->fs_info->profiles_lock, seq));
+		all_avail = fs_info->avail_data_alloc_bits |
+			    fs_info->avail_system_alloc_bits |
+			    fs_info->avail_metadata_alloc_bits;
+	} while (read_seqretry(&fs_info->profiles_lock, seq));
 
 	if ((all_avail & BTRFS_BLOCK_GROUP_RAID10) && num_devices <= 4) {
-		ret = BTRFS_ERROR_DEV_RAID10_MIN_NOT_MET;
-		goto out;
+		return BTRFS_ERROR_DEV_RAID10_MIN_NOT_MET;
 	}
 
 	if ((all_avail & BTRFS_BLOCK_GROUP_RAID1) && num_devices <= 2) {
-		ret = BTRFS_ERROR_DEV_RAID1_MIN_NOT_MET;
-		goto out;
+		return BTRFS_ERROR_DEV_RAID1_MIN_NOT_MET;
 	}
 
 	if ((all_avail & BTRFS_BLOCK_GROUP_RAID5) &&
-	    root->fs_info->fs_devices->rw_devices <= 2) {
-		ret = BTRFS_ERROR_DEV_RAID5_MIN_NOT_MET;
-		goto out;
+	    fs_info->fs_devices->rw_devices <= 2) {
+		return BTRFS_ERROR_DEV_RAID5_MIN_NOT_MET;
 	}
+
 	if ((all_avail & BTRFS_BLOCK_GROUP_RAID6) &&
-	    root->fs_info->fs_devices->rw_devices <= 3) {
-		ret = BTRFS_ERROR_DEV_RAID6_MIN_NOT_MET;
-		goto out;
+	    fs_info->fs_devices->rw_devices <= 3) {
+		return BTRFS_ERROR_DEV_RAID6_MIN_NOT_MET;
 	}
 
-out:
-	return ret;
+	return 0;
 }
 
 int btrfs_rm_device(struct btrfs_root *root, char *device_path)
@@ -1767,7 +1762,7 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path)
 
 	mutex_lock(&uuid_mutex);
 
-	ret = __check_raid_min_devices(root);
+	ret = __check_raid_min_devices(root->fs_info);
 	if (ret)
 		goto out;
 
-- 
2.7.0


  parent reply	other threads:[~2016-02-13  2:02 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-13  2:01 [PATCH resend 00/13] misc patches plus Introduce device delete by devid Anand Jain
2016-02-13  2:01 ` [PATCH v2 01/13] btrfs: pass the error code to the btrfs_std_error and log ret Anand Jain
2016-02-13  2:01 ` [PATCH 02/13] btrfs: create a helper function to read the disk super Anand Jain
2016-02-13  2:01 ` [PATCH v2 03/13] btrfs: maintain consistency in logging to help debugging Anand Jain
2016-02-13  2:01 ` [PATCH v2 04/13] btrfs: device path change must be logged Anand Jain
2016-02-13  2:01 ` [PATCH 05/13] Btrfs: fix fs logging for multi device Anand Jain
2016-02-13  2:01 ` [PATCH v2 06/13] btrfs: create helper function __check_raid_min_devices() Anand Jain
2016-02-15 14:51   ` David Sterba
2016-02-13  2:01 ` Anand Jain [this message]
2016-02-13  2:01 ` [PATCH v2 08/13] btrfs: create helper btrfs_find_device_by_user_input() Anand Jain
2016-02-13  2:01 ` [PATCH 09/13] btrfs: make use of btrfs_find_device_by_user_input() Anand Jain
2016-02-15 16:47   ` David Sterba
2016-02-15 16:53     ` David Sterba
2016-02-13  2:01 ` [PATCH v2 10/13] btrfs: enhance btrfs_find_device_by_user_input() to check device path Anand Jain
2016-02-13  2:01 ` [PATCH v2 11/13] btrfs: make use of btrfs_scratch_superblocks() in btrfs_rm_device() Anand Jain
2016-02-13  2:01 ` [PATCH v4 12/13] btrfs: introduce device delete by devid Anand Jain
2016-02-17 10:49   ` David Sterba
2016-02-18  6:59     ` Anand Jain
2016-02-18  9:53       ` David Sterba
2016-02-13  2:01 ` [PATCH 13/13] btrfs: optimize check for stale device Anand Jain
2016-02-18 15:13   ` David Sterba
2016-02-19  7:10     ` Anand Jain
2016-02-19  9:15       ` Anand Jain
2016-03-22 12:21       ` David Sterba
2016-03-22 16:43         ` Anand Jain
2016-03-09  9:54     ` Anand Jain
2016-03-09 16:33       ` David Sterba

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=1455328900-1476-8-git-send-email-anand.jain@oracle.com \
    --to=anand.jain@oracle.com \
    --cc=dsterba@suse.cz \
    --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).