From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: damenly.su@gmail.com, linux-btrfs@vger.kernel.org
Cc: Su Yue <Damenly_Su@gmx.com>
Subject: Re: [PATCH 06/10] btrfs-progs: abstract function btrfs_add_block_group_cache()
Date: Thu, 5 Dec 2019 15:42:11 +0800 [thread overview]
Message-ID: <bb408d9c-446d-35e8-d1ce-0205d018fb2b@gmx.com> (raw)
In-Reply-To: <20191205042921.25316-7-Damenly_Su@gmx.com>
[-- Attachment #1.1: Type: text/plain, Size: 4455 bytes --]
On 2019/12/5 下午12:29, damenly.su@gmail.com wrote:
> From: Su Yue <Damenly_Su@gmx.com>
>
> The new function btrfs_add_block_group_cache() abstracts the old
> set_extent_bits and set_state_private operations.
>
> Rename the rb tree version to btrfs_add_block_group_cache_kernel().
>
> Signed-off-by: Su Yue <Damenly_Su@gmx.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Thanks,
Qu
> ---
> extent-tree.c | 50 ++++++++++++++++++++++++++------------------------
> 1 file changed, 26 insertions(+), 24 deletions(-)
>
> diff --git a/extent-tree.c b/extent-tree.c
> index 274dfe540b1f..ff3db5ca2e0c 100644
> --- a/extent-tree.c
> +++ b/extent-tree.c
> @@ -164,10 +164,31 @@ err:
> return 0;
> }
>
> +static int btrfs_add_block_group_cache(struct btrfs_fs_info *info,
> + struct btrfs_block_group_cache *cache,
> + int bits)
> +{
> + int ret;
> +
> + ret = set_extent_bits(&info->block_group_cache, cache->key.objectid,
> + cache->key.objectid + cache->key.offset - 1,
> + bits);
> + if (ret)
> + return ret;
> +
> + ret = set_state_private(&info->block_group_cache, cache->key.objectid,
> + (unsigned long)cache);
> + if (ret)
> + clear_extent_bits(&info->block_group_cache, cache->key.objectid,
> + cache->key.objectid + cache->key.offset - 1,
> + bits);
> + return ret;
> +}
> +
> /*
> * This adds the block group to the fs_info rb tree for the block group cache
> */
> -static int btrfs_add_block_group_cache(struct btrfs_fs_info *info,
> +static int btrfs_add_block_group_cache_kernel(struct btrfs_fs_info *info,
> struct btrfs_block_group_cache *block_group)
> {
> struct rb_node **p;
> @@ -2769,7 +2790,6 @@ error:
> static int read_one_block_group(struct btrfs_fs_info *fs_info,
> struct btrfs_path *path)
> {
> - struct extent_io_tree *block_group_cache = &fs_info->block_group_cache;
> struct extent_buffer *leaf = path->nodes[0];
> struct btrfs_space_info *space_info;
> struct btrfs_block_group_cache *cache;
> @@ -2819,11 +2839,7 @@ static int read_one_block_group(struct btrfs_fs_info *fs_info,
> }
> cache->space_info = space_info;
>
> - set_extent_bits(block_group_cache, cache->key.objectid,
> - cache->key.objectid + cache->key.offset - 1,
> - bit | EXTENT_LOCKED);
> - set_state_private(block_group_cache, cache->key.objectid,
> - (unsigned long)cache);
> + btrfs_add_block_group_cache(fs_info, cache, bit | EXTENT_LOCKED);
> return 0;
> }
>
> @@ -2875,9 +2891,6 @@ btrfs_add_block_group(struct btrfs_fs_info *fs_info, u64 bytes_used, u64 type,
> int ret;
> int bit = 0;
> struct btrfs_block_group_cache *cache;
> - struct extent_io_tree *block_group_cache;
> -
> - block_group_cache = &fs_info->block_group_cache;
>
> cache = kzalloc(sizeof(*cache), GFP_NOFS);
> BUG_ON(!cache);
> @@ -2894,13 +2907,8 @@ btrfs_add_block_group(struct btrfs_fs_info *fs_info, u64 bytes_used, u64 type,
> BUG_ON(ret);
>
> bit = block_group_state_bits(type);
> - ret = set_extent_bits(block_group_cache, chunk_offset,
> - chunk_offset + size - 1,
> - bit | EXTENT_LOCKED);
> - BUG_ON(ret);
>
> - ret = set_state_private(block_group_cache, chunk_offset,
> - (unsigned long)cache);
> + ret = btrfs_add_block_group_cache(fs_info, cache, bit | EXTENT_LOCKED);
> BUG_ON(ret);
> set_avail_alloc_bits(fs_info, type);
>
> @@ -2950,9 +2958,7 @@ int btrfs_make_block_groups(struct btrfs_trans_handle *trans,
> int bit;
> struct btrfs_root *extent_root = fs_info->extent_root;
> struct btrfs_block_group_cache *cache;
> - struct extent_io_tree *block_group_cache;
>
> - block_group_cache = &fs_info->block_group_cache;
> total_bytes = btrfs_super_total_bytes(fs_info->super_copy);
> group_align = 64 * fs_info->sectorsize;
>
> @@ -2996,12 +3002,8 @@ int btrfs_make_block_groups(struct btrfs_trans_handle *trans,
> 0, &cache->space_info);
> BUG_ON(ret);
> set_avail_alloc_bits(fs_info, group_type);
> -
> - set_extent_bits(block_group_cache, cur_start,
> - cur_start + group_size - 1,
> - bit | EXTENT_LOCKED);
> - set_state_private(block_group_cache, cur_start,
> - (unsigned long)cache);
> + btrfs_add_block_group_cache(fs_info, cache,
> + bit | EXTENT_LOCKED);
> cur_start += group_size;
> }
> /* then insert all the items */
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 520 bytes --]
next prev parent reply other threads:[~2019-12-05 7:42 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-05 4:29 [PATCH 00/10] unify origanization structure of block group cache damenly.su
2019-12-05 4:29 ` [PATCH 01/10] btrfs-progs: handle error if btrfs_write_one_block_group() failed damenly.su
2019-12-05 7:21 ` Qu Wenruo
2019-12-05 4:29 ` [PATCH 02/10] btrfs-progs: block_group: add rb tree related memebers damenly.su
2019-12-05 7:22 ` Qu Wenruo
2019-12-05 4:29 ` [PATCH 03/10] btrfs-progs: port block group cache tree insertion and lookup functions damenly.su
2019-12-05 7:29 ` Qu Wenruo
2019-12-05 8:32 ` Su Yue
2019-12-05 13:41 ` David Sterba
2019-12-05 4:29 ` [PATCH 04/10] btrfs-progs: reform the function block_group_cache_tree_search() damenly.su
2019-12-05 7:38 ` Qu Wenruo
2019-12-05 8:08 ` Su Yue
2019-12-05 4:29 ` [PATCH 05/10] btrfs-progs: adjust function btrfs_lookup_first_block_group_kernel damenly.su
2019-12-05 7:40 ` Qu Wenruo
2019-12-05 8:20 ` Su Yue
2019-12-05 4:29 ` [PATCH 06/10] btrfs-progs: abstract function btrfs_add_block_group_cache() damenly.su
2019-12-05 7:42 ` Qu Wenruo [this message]
2019-12-05 4:29 ` [PATCH 07/10] block-progs: block_group: add dirty_bgs list related memebers damenly.su
2019-12-05 7:43 ` Qu Wenruo
2019-12-05 4:29 ` [PATCH 08/10] btrfs-progs: pass @trans to functions touch dirty block groups damenly.su
2019-12-05 7:44 ` Qu Wenruo
2019-12-05 4:29 ` [PATCH 09/10] btrfs-progs: refrom block groups caches structure damenly.su
2019-12-05 7:51 ` Qu Wenruo
2019-12-05 8:09 ` Su Yue
2019-12-05 4:29 ` [PATCH 10/10] btrfs-progs: cleanups after block group cache reform damenly.su
2019-12-05 7:52 ` 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=bb408d9c-446d-35e8-d1ce-0205d018fb2b@gmx.com \
--to=quwenruo.btrfs@gmx.com \
--cc=Damenly_Su@gmx.com \
--cc=damenly.su@gmail.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