From: Nikolay Borisov <nborisov@suse.com>
To: Qu Wenruo <wqu@suse.com>, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 6/8] btrfs: extent-tree: Use btrfs_ref to refactor add_pinned_bytes()
Date: Mon, 10 Dec 2018 11:45:44 +0200 [thread overview]
Message-ID: <97549f80-c947-6c07-d2a8-f43c9063997f@suse.com> (raw)
In-Reply-To: <20181206065903.11343-7-wqu@suse.com>
On 6.12.18 г. 8:59 ч., Qu Wenruo wrote:
> Since add_pinned_bytes() only needs to know if the extent is metadata
> and if it's a chunk tree extent, btrfs_ref is a perfect match for it, as
> we don't need various owner/level trick to determine extent type.
>
> Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
> ---
> fs/btrfs/extent-tree.c | 26 ++++++++++----------------
> 1 file changed, 10 insertions(+), 16 deletions(-)
>
> diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
> index 1d812bc2c7fc..70c05ca30d9a 100644
> --- a/fs/btrfs/extent-tree.c
> +++ b/fs/btrfs/extent-tree.c
> @@ -738,14 +738,15 @@ static struct btrfs_space_info *__find_space_info(struct btrfs_fs_info *info,
> return NULL;
> }
>
> -static void add_pinned_bytes(struct btrfs_fs_info *fs_info, s64 num_bytes,
> - bool metadata, u64 root_objectid)
> +static void add_pinned_bytes(struct btrfs_fs_info *fs_info,
> + struct btrfs_ref *ref)
> {
> struct btrfs_space_info *space_info;
> + s64 num_bytes = -ref->len;
> u64 flags;
>
> - if (metadata) {
> - if (root_objectid == BTRFS_CHUNK_TREE_OBJECTID)
> + if (ref->type == BTRFS_REF_METADATA) {
> + if (ref->tree_ref.root == BTRFS_CHUNK_TREE_OBJECTID)
> flags = BTRFS_BLOCK_GROUP_SYSTEM;
> else
> flags = BTRFS_BLOCK_GROUP_METADATA;
> @@ -2053,11 +2054,8 @@ int btrfs_inc_extent_ref(struct btrfs_trans_handle *trans,
>
> btrfs_ref_tree_mod(fs_info, &generic_ref);
>
> - if (ret == 0 && old_ref_mod < 0 && new_ref_mod >= 0) {
> - bool metadata = owner < BTRFS_FIRST_FREE_OBJECTID;
> -
> - add_pinned_bytes(fs_info, -num_bytes, metadata, root_objectid);
> - }
> + if (ret == 0 && old_ref_mod < 0 && new_ref_mod >= 0)
> + add_pinned_bytes(fs_info, &generic_ref);
>
> return ret;
> }
> @@ -7059,8 +7057,7 @@ void btrfs_free_tree_block(struct btrfs_trans_handle *trans,
> }
> out:
> if (pin)
> - add_pinned_bytes(fs_info, buf->len, true,
> - root->root_key.objectid);
> + add_pinned_bytes(fs_info, &generic_ref);
>
> if (last_ref) {
> /*
> @@ -7111,11 +7108,8 @@ int btrfs_free_extent(struct btrfs_trans_handle *trans,
> if (root_objectid != BTRFS_TREE_LOG_OBJECTID)
> btrfs_ref_tree_mod(fs_info, &generic_ref);
>
> - if (ret == 0 && old_ref_mod >= 0 && new_ref_mod < 0) {
> - bool metadata = owner < BTRFS_FIRST_FREE_OBJECTID;
> -
> - add_pinned_bytes(fs_info, num_bytes, metadata, root_objectid);
> - }
> + if (ret == 0 && old_ref_mod >= 0 && new_ref_mod < 0)
> + add_pinned_bytes(fs_info, &generic_ref);
>
> return ret;
> }
>
next prev parent reply other threads:[~2018-12-10 9:45 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-06 6:58 [PATCH 0/8] btrfs: Refactor delayed ref parameter list Qu Wenruo
2018-12-06 6:58 ` [PATCH 1/8] btrfs: delayed-ref: Introduce better documented delayed ref structures Qu Wenruo
2018-12-10 9:48 ` Nikolay Borisov
2018-12-10 11:20 ` Qu Wenruo
2018-12-10 11:32 ` Nikolay Borisov
2018-12-10 11:37 ` Qu Wenruo
2018-12-10 17:03 ` David Sterba
2018-12-12 5:09 ` About enum convert (Old "Re: [PATCH 1/8] btrfs: delayed-ref: Introduce better documented delayed ref structures") Qu Wenruo
2018-12-06 6:58 ` [PATCH 2/8] btrfs: extent-tree: Open-code process_func in __btrfs_mod_ref Qu Wenruo
2018-12-07 17:39 ` Nikolay Borisov
2018-12-06 6:58 ` [PATCH 3/8] btrfs: delayed-ref: Use btrfs_ref to refactor btrfs_add_delayed_tree_ref() Qu Wenruo
2018-12-10 9:21 ` Nikolay Borisov
2018-12-12 5:50 ` Qu Wenruo
2018-12-06 6:58 ` [PATCH 4/8] btrfs: delayed-ref: Use btrfs_ref to refactor btrfs_add_delayed_data_ref() Qu Wenruo
2018-12-10 9:23 ` Nikolay Borisov
2018-12-06 6:59 ` [PATCH 5/8] btrfs: ref-verify: Use btrfs_ref to refactor btrfs_ref_tree_mod() Qu Wenruo
2018-12-06 6:59 ` [PATCH 6/8] btrfs: extent-tree: Use btrfs_ref to refactor add_pinned_bytes() Qu Wenruo
2018-12-10 9:45 ` Nikolay Borisov [this message]
2018-12-06 6:59 ` [PATCH 7/8] btrfs: extent-tree: Use btrfs_ref to refactor btrfs_inc_extent_ref() Qu Wenruo
2018-12-10 9:52 ` Nikolay Borisov
2018-12-10 17:28 ` David Sterba
2018-12-11 2:02 ` Qu Wenruo
2018-12-06 6:59 ` [PATCH 8/8] btrfs: extent-tree: Use btrfs_ref to refactor btrfs_free_extent() 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=97549f80-c947-6c07-d2a8-f43c9063997f@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;
as well as URLs for NNTP newsgroup(s).