linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org
Cc: dsterba@suse.cz
Subject: [PATCH 1/5] btrfs-progs: Use bool parameter to determine if we're allocating data extent
Date: Wed,  3 Jan 2018 15:13:02 +0800	[thread overview]
Message-ID: <20180103071306.11500-2-wqu@suse.com> (raw)
In-Reply-To: <20180103071306.11500-1-wqu@suse.com>

btrfs_reserve_extent() uses int @data to determine if we're allocating
data extent, while reuse the parameter later to pass it as profile
(data/meta/sys).

It's a little confusing, this patch will follow kernel parameter to use
bool @is_data to replace it.
And in btrfs_reserve_extent(), use dedicated u64 @profile.

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 ctree.h       |  2 +-
 extent-tree.c | 17 +++++++++--------
 2 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/ctree.h b/ctree.h
index b92df1c1a518..61d9f9fc9dff 100644
--- a/ctree.h
+++ b/ctree.h
@@ -2435,7 +2435,7 @@ int btrfs_reserve_extent(struct btrfs_trans_handle *trans,
 			 struct btrfs_root *root,
 			 u64 num_bytes, u64 empty_size,
 			 u64 hint_byte, u64 search_end,
-			 struct btrfs_key *ins, int data);
+			 struct btrfs_key *ins, bool is_data);
 int btrfs_fix_block_accounting(struct btrfs_trans_handle *trans,
 				 struct btrfs_root *root);
 void btrfs_pin_extent(struct btrfs_fs_info *fs_info, u64 bytenr, u64 num_bytes);
diff --git a/extent-tree.c b/extent-tree.c
index 055582c36da6..58b64a21d226 100644
--- a/extent-tree.c
+++ b/extent-tree.c
@@ -2652,36 +2652,37 @@ int btrfs_reserve_extent(struct btrfs_trans_handle *trans,
 			 struct btrfs_root *root,
 			 u64 num_bytes, u64 empty_size,
 			 u64 hint_byte, u64 search_end,
-			 struct btrfs_key *ins, int data)
+			 struct btrfs_key *ins, bool is_data)
 {
 	int ret;
 	u64 search_start = 0;
 	u64 alloc_profile;
+	u64 profile;
 	struct btrfs_fs_info *info = root->fs_info;
 
-	if (data) {
+	if (is_data) {
 		alloc_profile = info->avail_data_alloc_bits &
 			        info->data_alloc_profile;
-		data = BTRFS_BLOCK_GROUP_DATA | alloc_profile;
+		profile = BTRFS_BLOCK_GROUP_DATA | alloc_profile;
 	} else if (info->system_allocs == 1 || root == info->chunk_root) {
 		alloc_profile = info->avail_system_alloc_bits &
 			        info->system_alloc_profile;
-		data = BTRFS_BLOCK_GROUP_SYSTEM | alloc_profile;
+		profile = BTRFS_BLOCK_GROUP_SYSTEM | alloc_profile;
 	} else {
 		alloc_profile = info->avail_metadata_alloc_bits &
 			        info->metadata_alloc_profile;
-		data = BTRFS_BLOCK_GROUP_METADATA | alloc_profile;
+		profile = BTRFS_BLOCK_GROUP_METADATA | alloc_profile;
 	}
 
 	if (root->ref_cows) {
-		if (!(data & BTRFS_BLOCK_GROUP_METADATA)) {
+		if (!(profile & BTRFS_BLOCK_GROUP_METADATA)) {
 			ret = do_chunk_alloc(trans, info,
 					     num_bytes,
 					     BTRFS_BLOCK_GROUP_METADATA);
 			BUG_ON(ret);
 		}
 		ret = do_chunk_alloc(trans, info,
-				     num_bytes + SZ_2M, data);
+				     num_bytes + SZ_2M, profile);
 		BUG_ON(ret);
 	}
 
@@ -2689,7 +2690,7 @@ int btrfs_reserve_extent(struct btrfs_trans_handle *trans,
 	ret = find_free_extent(trans, root, num_bytes, empty_size,
 			       search_start, search_end, hint_byte, ins,
 			       trans->alloc_exclude_start,
-			       trans->alloc_exclude_nr, data);
+			       trans->alloc_exclude_nr, profile);
 	if (ret < 0)
 		return ret;
 	clear_extent_dirty(&info->free_space_cache,
-- 
2.15.1


  reply	other threads:[~2018-01-03  7:13 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-03  7:13 [PATCH 0/5] Cleanups for later btrfs_alloc_chunk() rework Qu Wenruo
2018-01-03  7:13 ` Qu Wenruo [this message]
2018-01-03  7:13 ` [PATCH 2/5] btrfs-progs: volumes: Make find_free_dev_extent_start static Qu Wenruo
2018-01-03  7:13 ` [PATCH 3/5] btrfs-progs: volumes: Remove unnecessary trans parameter Qu Wenruo
2018-01-03  7:13 ` [PATCH 4/5] btrfs-progs: volumes: Remove unnecessary parameters when allocating device extent Qu Wenruo
2018-01-03  7:13 ` [PATCH 5/5] btrfs-progs: Remove unnecessary parameter for btrfs_add_block_group Qu Wenruo
2018-01-23 18:31   ` David Sterba
2018-01-03  9:17 ` [PATCH 0/5] Cleanups for later btrfs_alloc_chunk() rework Su Yue
2018-01-04 13:54 ` Nikolay Borisov

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=20180103071306.11500-2-wqu@suse.com \
    --to=wqu@suse.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).