public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH v2 04/10] btrfs: relocation: Rename mark_block_processed() and __mark_block_processed()
Date: Mon,  2 Mar 2020 17:45:47 +0800	[thread overview]
Message-ID: <20200302094553.58827-5-wqu@suse.com> (raw)
In-Reply-To: <20200302094553.58827-1-wqu@suse.com>

These two functions are weirdly named, mark_block_processed() in fact
just mark a range dirty unconditionally, while __mark_block_processed()
does extra check before doing the marking.

This patch will open code old mark_block_processed, and rename
__mark_block_processed() to remove the "__" prefix.

Since we're here, also kill the forward declaration, which could also
kill in_block_group() with in_range() macro.

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 fs/btrfs/relocation.c | 55 +++++++++++++++++--------------------------
 1 file changed, 21 insertions(+), 34 deletions(-)

diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index 490d684002f9..d1e1d613ab98 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -236,8 +236,21 @@ struct reloc_control {
 
 static void remove_backref_node(struct backref_cache *cache,
 				struct backref_node *node);
-static void __mark_block_processed(struct reloc_control *rc,
-				   struct backref_node *node);
+
+static void mark_block_processed(struct reloc_control *rc,
+				 struct backref_node *node)
+{
+	u32 blocksize;
+	if (node->level == 0 ||
+	    in_range(node->bytenr, rc->block_group->start,
+		     rc->block_group->length)) {
+		blocksize = rc->extent_root->fs_info->nodesize;
+		set_extent_bits(&rc->processed_blocks, node->bytenr,
+				node->bytenr + blocksize - 1, EXTENT_DIRTY);
+	}
+	node->processed = 1;
+}
+
 
 static void mapping_tree_init(struct mapping_tree *tree)
 {
@@ -1103,7 +1116,7 @@ struct backref_node *build_backref_tree(struct reloc_control *rc,
 			if (list_empty(&lower->upper))
 				list_add(&lower->list, &useless);
 		}
-		__mark_block_processed(rc, upper);
+		mark_block_processed(rc, upper);
 		if (upper->level > 0) {
 			list_add(&upper->list, &cache->detached);
 			upper->detached = 1;
@@ -1569,14 +1582,6 @@ static struct inode *find_next_inode(struct btrfs_root *root, u64 objectid)
 	return NULL;
 }
 
-static int in_block_group(u64 bytenr, struct btrfs_block_group *block_group)
-{
-	if (bytenr >= block_group->start &&
-	    bytenr < block_group->start + block_group->length)
-		return 1;
-	return 0;
-}
-
 /*
  * get new location of data
  */
@@ -1674,7 +1679,8 @@ int replace_file_extents(struct btrfs_trans_handle *trans,
 		num_bytes = btrfs_file_extent_disk_num_bytes(leaf, fi);
 		if (bytenr == 0)
 			continue;
-		if (!in_block_group(bytenr, rc->block_group))
+		if (!in_range(bytenr, rc->block_group->start,
+			      rc->block_group->length))
 			continue;
 
 		/*
@@ -2604,7 +2610,7 @@ struct btrfs_root *select_reloc_root(struct btrfs_trans_handle *trans,
 			ASSERT(next->root);
 			list_add_tail(&next->list,
 				      &rc->backref_cache.changed);
-			__mark_block_processed(rc, next);
+			mark_block_processed(rc, next);
 			break;
 		}
 
@@ -2954,25 +2960,6 @@ static int finish_pending_nodes(struct btrfs_trans_handle *trans,
 	return err;
 }
 
-static void mark_block_processed(struct reloc_control *rc,
-				 u64 bytenr, u32 blocksize)
-{
-	set_extent_bits(&rc->processed_blocks, bytenr, bytenr + blocksize - 1,
-			EXTENT_DIRTY);
-}
-
-static void __mark_block_processed(struct reloc_control *rc,
-				   struct backref_node *node)
-{
-	u32 blocksize;
-	if (node->level == 0 ||
-	    in_block_group(node->bytenr, rc->block_group)) {
-		blocksize = rc->extent_root->fs_info->nodesize;
-		mark_block_processed(rc, node->bytenr, blocksize);
-	}
-	node->processed = 1;
-}
-
 /*
  * mark a block and all blocks directly/indirectly reference the block
  * as processed.
@@ -2991,7 +2978,7 @@ static void update_processed_blocks(struct reloc_control *rc,
 			if (next->processed)
 				break;
 
-			__mark_block_processed(rc, next);
+			mark_block_processed(rc, next);
 
 			if (list_empty(&next->upper))
 				break;
@@ -4743,7 +4730,7 @@ int btrfs_reloc_cow_block(struct btrfs_trans_handle *trans,
 		}
 
 		if (first_cow)
-			__mark_block_processed(rc, node);
+			mark_block_processed(rc, node);
 
 		if (first_cow && level > 0)
 			rc->nodes_relocated += buf->len;
-- 
2.25.1


  parent reply	other threads:[~2020-03-02  9:46 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-02  9:45 [PATCH v2 00/10] btrfs: relocation: Refactor build_backref_tree() Qu Wenruo
2020-03-02  9:45 ` [PATCH v2 01/10] btrfs: backref: Introduce the skeleton of btrfs_backref_iter Qu Wenruo
2020-03-03 17:19   ` David Sterba
2020-03-04  0:50     ` Qu Wenruo
2020-03-03 17:25   ` David Sterba
2020-03-04  0:52     ` Qu Wenruo
2020-03-04  7:41   ` Nikolay Borisov
2020-03-02  9:45 ` [PATCH v2 02/10] btrfs: backref: Implement btrfs_backref_iter_next() Qu Wenruo
2020-03-02  9:45 ` [PATCH v2 03/10] btrfs: relocation: Use btrfs_backref_iter infrastructure Qu Wenruo
2020-03-02  9:45 ` Qu Wenruo [this message]
2020-03-02 17:21   ` [PATCH v2 04/10] btrfs: relocation: Rename mark_block_processed() and __mark_block_processed() Nikolay Borisov
2020-03-02  9:45 ` [PATCH v2 05/10] btrfs: relocation: Refactor tree backref processing into its own function Qu Wenruo
2020-03-03 17:29   ` David Sterba
2020-03-04  1:00     ` Qu Wenruo
2020-03-04 12:23   ` Nikolay Borisov
2020-03-04 12:33     ` Qu Wenruo
2020-03-02  9:45 ` [PATCH v2 06/10] btrfs: relocation: Use wrapper to replace open-coded edge linking Qu Wenruo
2020-03-03 17:30   ` David Sterba
2020-03-04  1:02     ` Qu Wenruo
2020-03-04 13:02   ` Nikolay Borisov
2020-03-02  9:45 ` [PATCH v2 07/10] btrfs: relocation: Specify essential members for alloc_backref_node() Qu Wenruo
2020-03-04 13:06   ` Nikolay Borisov
2020-03-04 13:09     ` Qu Wenruo
2020-03-02  9:45 ` [PATCH v2 08/10] btrfs: relocation: Remove the open-coded goto loop for breadth-first search Qu Wenruo
2020-03-04 14:24   ` Nikolay Borisov
2020-03-05  0:40     ` Qu Wenruo
2020-03-05  8:17       ` Nikolay Borisov
2020-03-05  8:37         ` Qu Wenruo
2020-03-02  9:45 ` [PATCH v2 09/10] btrfs: relocation: Refactor the finishing part of upper linkage into finish_upper_links() Qu Wenruo
2020-03-02  9:45 ` [PATCH v2 10/10] btrfs: relocation: Refactor the useless nodes handling into its own function Qu Wenruo

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=20200302094553.58827-5-wqu@suse.com \
    --to=wqu@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