From: Nikolay Borisov <nborisov@suse.com>
To: Qu Wenruo <wqu@suse.com>, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH v2 05/10] btrfs: relocation: Refactor tree backref processing into its own function
Date: Wed, 4 Mar 2020 14:23:48 +0200 [thread overview]
Message-ID: <da92b934-0463-bcdb-8c19-1de0aa763b1a@suse.com> (raw)
In-Reply-To: <20200302094553.58827-6-wqu@suse.com>
On 2.03.20 г. 11:45 ч., Qu Wenruo wrote:
> build_backref_tree() function is painfully long, as it has 3 big parts:
> - Tree backref handling
> - Weaving backref nodes
> - Useless nodes pruning
>
> This patch will move the tree backref handling into its own function,
> handle_one_tree_backref().
>
> And inside that function, the main works are determined by the backref
> key:
> - BTRFS_SHARED_BLOCK_REF_KEY
> We know the parent node bytenr directly.
> If the parent is cached, or it's root, call it a day.
> If the parent is not cached, add it pending list.
>
> - BTRFS_TREE_BLOCK_REF_KEY
> The most complex work.
> We need to grab the fs root, do a tree search to locate all its
> parent nodes, weaving all needed edges, and put all uncached edges to
> pending edge list.
>
> Signed-off-by: Qu Wenruo <wqu@suse.com>
> ---
> fs/btrfs/relocation.c | 395 +++++++++++++++++++++---------------------
> 1 file changed, 202 insertions(+), 193 deletions(-)
>
> diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
> index d1e1d613ab98..04416489d87a 100644
> --- a/fs/btrfs/relocation.c
> +++ b/fs/btrfs/relocation.c
> @@ -666,6 +666,206 @@ static struct btrfs_root *read_fs_root(struct btrfs_fs_info *fs_info,
> return btrfs_get_fs_root(fs_info, &key, false);
> }
>
> +static int handle_one_tree_backref(struct reloc_control *rc,
> + struct list_head *useless_node,
> + struct list_head *pending_edge,
> + struct btrfs_path *path,
> + struct btrfs_key *ref_key,
> + struct btrfs_key *tree_key,
> + struct backref_node *cur)
That function has 7 parameters and while @rc and @path are somewhat
self-explanatory others are not. Also it's really doing 2 distinct
things which, in my opinion, would be much better split across 2
functions - 1 handling BTRFS_SHARED_BLOCK_REF_KEY and the other handling
BTRFS_TREE_BLOCK_REF_KEY. For example the @tree_key,@useless_node and
@path are not used in BTRFS_SHARED_BLOCK_REF_KEY case. You'd have two
functions named:
handle_(in)?direct_tree_backref
One will take only 4 parameters the other will have to, unfortunately,
take all 7.
next prev parent reply other threads:[~2020-03-04 12:23 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 ` [PATCH v2 04/10] btrfs: relocation: Rename mark_block_processed() and __mark_block_processed() Qu Wenruo
2020-03-02 17:21 ` 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 [this message]
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=da92b934-0463-bcdb-8c19-1de0aa763b1a@suse.com \
--to=nborisov@suse.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=wqu@suse.com \
/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