linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.com>
To: linux-btrfs@vger.kernel.org
Cc: David Sterba <dsterba@suse.com>
Subject: [PATCH 12/15] btrfs: factor out devs_max setting in __btrfs_alloc_chunk
Date: Fri, 17 May 2019 11:43:38 +0200	[thread overview]
Message-ID: <c81578fdd1de6c8967752724ea3a4a176911a703.1558085801.git.dsterba@suse.com> (raw)
In-Reply-To: <cover.1558085801.git.dsterba@suse.com>

Merge the repeated code before the if-else block.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/volumes.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 3464bf1f0c48..9ee35fe9ee0f 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -4956,6 +4956,8 @@ static int __btrfs_alloc_chunk(struct btrfs_trans_handle *trans,
 	sub_stripes = btrfs_raid_array[index].sub_stripes;
 	dev_stripes = btrfs_raid_array[index].dev_stripes;
 	devs_max = btrfs_raid_array[index].devs_max;
+	if (!devs_max)
+		devs_max = BTRFS_MAX_DEVS(info);
 	devs_min = btrfs_raid_array[index].devs_min;
 	devs_increment = btrfs_raid_array[index].devs_increment;
 	ncopies = btrfs_raid_array[index].ncopies;
@@ -4964,8 +4966,6 @@ static int __btrfs_alloc_chunk(struct btrfs_trans_handle *trans,
 	if (type & BTRFS_BLOCK_GROUP_DATA) {
 		max_stripe_size = SZ_1G;
 		max_chunk_size = BTRFS_MAX_DATA_CHUNK_SIZE;
-		if (!devs_max)
-			devs_max = BTRFS_MAX_DEVS(info);
 	} else if (type & BTRFS_BLOCK_GROUP_METADATA) {
 		/* for larger filesystems, use larger metadata chunks */
 		if (fs_devices->total_rw_bytes > 50ULL * SZ_1G)
@@ -4973,13 +4973,9 @@ static int __btrfs_alloc_chunk(struct btrfs_trans_handle *trans,
 		else
 			max_stripe_size = SZ_256M;
 		max_chunk_size = max_stripe_size;
-		if (!devs_max)
-			devs_max = BTRFS_MAX_DEVS(info);
 	} else if (type & BTRFS_BLOCK_GROUP_SYSTEM) {
 		max_stripe_size = SZ_32M;
 		max_chunk_size = 2 * max_stripe_size;
-		if (!devs_max)
-			devs_max = BTRFS_MAX_DEVS_SYS_CHUNK;
 	} else {
 		btrfs_err(info, "invalid chunk type 0x%llx requested",
 		       type);
-- 
2.21.0


  parent reply	other threads:[~2019-05-17  9:42 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-17  9:43 [PATCH 00/15] RAID/volumes code cleanups David Sterba
2019-05-17  9:43 ` [PATCH 01/15] btrfs: fix minimum number of chunk errors for DUP David Sterba
2019-05-17 14:05   ` Qu Wenruo
2019-05-17  9:43 ` [PATCH 02/15] btrfs: raid56: allow the exact minimum number of devices for balance convert David Sterba
2019-05-17  9:43 ` [PATCH 03/15] btrfs: remove mapping tree structures indirection David Sterba
2019-05-17  9:43 ` [PATCH 04/15] btrfs: use raid_attr table in get_profile_num_devs David Sterba
2019-05-17  9:43 ` [PATCH 05/15] btrfs: use raid_attr in btrfs_chunk_max_errors David Sterba
2019-05-17  9:43 ` [PATCH 06/15] btrfs: use raid_attr table in calc_stripe_length for nparity David Sterba
2019-05-17 10:06   ` Hans van Kranenburg
2019-05-17 12:54     ` David Sterba
2019-05-17 13:06       ` Hans van Kranenburg
2019-05-17  9:43 ` [PATCH 07/15] btrfs: use raid_attr to get allowed profiles for balance conversion David Sterba
2019-05-17  9:43 ` [PATCH 08/15] btrfs: use raid_attr table to find profiles for integrity lowering David Sterba
2019-05-17  9:43 ` [PATCH 09/15] btrfs: use raid_attr table for btrfs_bg_type_to_factor David Sterba
2019-05-17  9:43 ` [PATCH 10/15] btrfs: factor out helper for counting data stripes David Sterba
2019-05-17  9:43 ` [PATCH 11/15] btrfs: use u8 for raid_array members David Sterba
2019-05-17  9:43 ` David Sterba [this message]
2019-05-17  9:43 ` [PATCH 13/15] btrfs: refactor helper for bg flags to name conversion David Sterba
2019-05-17  9:43 ` [PATCH 14/15] btrfs: constify map parameter for nr_parity_stripes and nr_data_stripes David Sterba
2019-05-17  9:43 ` [PATCH 15/15] btrfs: read number of data stripes from map only once 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=c81578fdd1de6c8967752724ea3a4a176911a703.1558085801.git.dsterba@suse.com \
    --to=dsterba@suse.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).