From: Nikolay Borisov <nborisov@suse.com>
To: Qu Wenruo <wqu@suse.com>, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH v2 07/10] btrfs: relocation: Specify essential members for alloc_backref_node()
Date: Wed, 4 Mar 2020 15:06:41 +0200 [thread overview]
Message-ID: <d416797a-c174-55a3-2fc4-4e7d31ab33ac@suse.com> (raw)
In-Reply-To: <20200302094553.58827-8-wqu@suse.com>
On 2.03.20 г. 11:45 ч., Qu Wenruo wrote:
> Bytenr and level are essential parameters for backref_node, thus it
> makes sense to initial them at alloc time.
>
> Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
> ---
> fs/btrfs/relocation.c | 25 ++++++++++++-------------
> 1 file changed, 12 insertions(+), 13 deletions(-)
>
> diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
> index c76849409c81..67a4a61eb86a 100644
> --- a/fs/btrfs/relocation.c
> +++ b/fs/btrfs/relocation.c
> @@ -308,10 +308,12 @@ static void backref_cache_cleanup(struct backref_cache *cache)
> ASSERT(!cache->nr_edges);
> }
>
> -static struct backref_node *alloc_backref_node(struct backref_cache *cache)
> +static struct backref_node *alloc_backref_node(struct backref_cache *cache,
> + u64 bytenr, int level)
> {
> struct backref_node *node;
>
> + ASSERT(level >= 0 && level < BTRFS_MAX_LEVEL);
> node = kzalloc(sizeof(*node), GFP_NOFS);
> if (node) {
> INIT_LIST_HEAD(&node->list);
> @@ -319,6 +321,9 @@ static struct backref_node *alloc_backref_node(struct backref_cache *cache)
> INIT_LIST_HEAD(&node->lower);
> RB_CLEAR_NODE(&node->rb_node);
> cache->nr_nodes++;
> +
> + node->level = level;
> + node->bytenr = bytenr;
> }
nit: One suggestion for this function, feel free to ignore:
What if you do it:
if (!node)
return NULL
and then have the initialization happen with just 1 level of nesting
inside the function and not 2. That function is short and easy to
understand but it might be a good time to refactor like that. If you
think it's redundant then don't bother.
> return node;
> }
<snip>
next prev parent reply other threads:[~2020-03-04 13:06 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
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 [this message]
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=d416797a-c174-55a3-2fc4-4e7d31ab33ac@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