From: Josef Bacik <josef@toxicpanda.com>
To: Naohiro Aota <naohiro.aota@wdc.com>
Cc: linux-btrfs@vger.kernel.org,
Johannes Thumshirn <johannes.thumshirn@wdc.com>
Subject: Re: [PATCH v3 07/13] btrfs: pass space_info for block group creation
Date: Thu, 17 Apr 2025 08:40:06 -0400 [thread overview]
Message-ID: <20250417124006.GB3574107@perftesting> (raw)
In-Reply-To: <e9c33853d3095c61b982bfb23bd313d8641d6797.1744813603.git.naohiro.aota@wdc.com>
On Wed, Apr 16, 2025 at 11:28:12PM +0900, Naohiro Aota wrote:
> Add btrfs_space_info parameter to btrfs_make_block_group(), its related
> functions and related struct. Passed space_info will have a new block
> group. If NULL is passed, it uses the default space_info.
>
> The parameter is used in a later commit and the behavior is unchanged now.
>
> Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> ---
> fs/btrfs/block-group.c | 18 ++++++++++--------
> fs/btrfs/block-group.h | 4 ++--
> fs/btrfs/volumes.c | 22 +++++++++++++++++-----
> fs/btrfs/volumes.h | 3 ++-
> 4 files changed, 31 insertions(+), 16 deletions(-)
>
> diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c
> index 12cc9069d4bb..846c9737ff5a 100644
> --- a/fs/btrfs/block-group.c
> +++ b/fs/btrfs/block-group.c
> @@ -2866,8 +2866,8 @@ static u64 calculate_global_root_id(const struct btrfs_fs_info *fs_info, u64 off
> }
>
> struct btrfs_block_group *btrfs_make_block_group(struct btrfs_trans_handle *trans,
> - u64 type,
> - u64 chunk_offset, u64 size)
> + struct btrfs_space_info *space_info,
> + u64 type, u64 chunk_offset, u64 size)
> {
> struct btrfs_fs_info *fs_info = trans->fs_info;
> struct btrfs_block_group *cache;
> @@ -2921,7 +2921,7 @@ struct btrfs_block_group *btrfs_make_block_group(struct btrfs_trans_handle *tran
> * assigned to our block group. We want our bg to be added to the rbtree
> * with its ->space_info set.
> */
> - cache->space_info = btrfs_find_space_info(fs_info, cache->flags);
> + cache->space_info = space_info;
> ASSERT(cache->space_info);
>
> ret = btrfs_add_block_group_cache(cache);
> @@ -3902,7 +3902,9 @@ int btrfs_force_chunk_alloc(struct btrfs_trans_handle *trans, u64 type)
> return btrfs_chunk_alloc(trans, NULL, alloc_flags, CHUNK_ALLOC_FORCE);
> }
>
> -static struct btrfs_block_group *do_chunk_alloc(struct btrfs_trans_handle *trans, u64 flags)
> +static struct btrfs_block_group *do_chunk_alloc(struct btrfs_trans_handle *trans,
> + struct btrfs_space_info *space_info,
> + u64 flags)
> {
> struct btrfs_block_group *bg;
> int ret;
> @@ -3915,7 +3917,7 @@ static struct btrfs_block_group *do_chunk_alloc(struct btrfs_trans_handle *trans
> */
> check_system_chunk(trans, flags);
>
> - bg = btrfs_create_chunk(trans, flags);
> + bg = btrfs_create_chunk(trans, space_info, flags);
> if (IS_ERR(bg)) {
> ret = PTR_ERR(bg);
> goto out;
> @@ -3964,7 +3966,7 @@ static struct btrfs_block_group *do_chunk_alloc(struct btrfs_trans_handle *trans
> const u64 sys_flags = btrfs_system_alloc_profile(trans->fs_info);
> struct btrfs_block_group *sys_bg;
>
> - sys_bg = btrfs_create_chunk(trans, sys_flags);
> + sys_bg = btrfs_create_chunk(trans, NULL, sys_flags);
> if (IS_ERR(sys_bg)) {
> ret = PTR_ERR(sys_bg);
> btrfs_abort_transaction(trans, ret);
> @@ -4214,7 +4216,7 @@ int btrfs_chunk_alloc(struct btrfs_trans_handle *trans,
> force_metadata_allocation(fs_info);
> }
>
> - ret_bg = do_chunk_alloc(trans, flags);
> + ret_bg = do_chunk_alloc(trans, space_info, flags);
> trans->allocating_chunk = false;
>
> if (IS_ERR(ret_bg)) {
> @@ -4297,7 +4299,7 @@ static void reserve_chunk_space(struct btrfs_trans_handle *trans,
> * the paths we visit in the chunk tree (they were already COWed
> * or created in the current transaction for example).
> */
> - bg = btrfs_create_chunk(trans, flags);
> + bg = btrfs_create_chunk(trans, NULL, flags);
> if (IS_ERR(bg)) {
> ret = PTR_ERR(bg);
> } else {
> diff --git a/fs/btrfs/block-group.h b/fs/btrfs/block-group.h
> index c01f3af726a1..35309b690d6f 100644
> --- a/fs/btrfs/block-group.h
> +++ b/fs/btrfs/block-group.h
> @@ -326,8 +326,8 @@ void btrfs_reclaim_bgs(struct btrfs_fs_info *fs_info);
> void btrfs_mark_bg_to_reclaim(struct btrfs_block_group *bg);
> int btrfs_read_block_groups(struct btrfs_fs_info *info);
> struct btrfs_block_group *btrfs_make_block_group(struct btrfs_trans_handle *trans,
> - u64 type,
> - u64 chunk_offset, u64 size);
> + struct btrfs_space_info *space_info,
> + u64 type, u64 chunk_offset, u64 size);
> void btrfs_create_pending_block_groups(struct btrfs_trans_handle *trans);
> int btrfs_inc_block_group_ro(struct btrfs_block_group *cache,
> bool do_chunk_alloc);
> diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
> index 7509cbe3272c..5462c832ea19 100644
> --- a/fs/btrfs/volumes.c
> +++ b/fs/btrfs/volumes.c
> @@ -3420,7 +3420,7 @@ int btrfs_remove_chunk(struct btrfs_trans_handle *trans, u64 chunk_offset)
> const u64 sys_flags = btrfs_system_alloc_profile(fs_info);
> struct btrfs_block_group *sys_bg;
>
> - sys_bg = btrfs_create_chunk(trans, sys_flags);
> + sys_bg = btrfs_create_chunk(trans, NULL, sys_flags);
> if (IS_ERR(sys_bg)) {
> ret = PTR_ERR(sys_bg);
> btrfs_abort_transaction(trans, ret);
> @@ -5216,6 +5216,8 @@ struct alloc_chunk_ctl {
> u64 stripe_size;
> u64 chunk_size;
> int ndevs;
> + /* Space_info the block group is going to belong. */
> + struct btrfs_space_info *space_info;
> };
>
> static void init_alloc_chunk_ctl_policy_regular(
> @@ -5617,7 +5619,8 @@ static struct btrfs_block_group *create_chunk(struct btrfs_trans_handle *trans,
> return ERR_PTR(ret);
> }
>
> - block_group = btrfs_make_block_group(trans, type, start, ctl->chunk_size);
> + block_group = btrfs_make_block_group(trans, ctl->space_info, type, start,
> + ctl->chunk_size);
> if (IS_ERR(block_group)) {
> btrfs_remove_chunk_map(info, map);
> return block_group;
> @@ -5643,7 +5646,8 @@ static struct btrfs_block_group *create_chunk(struct btrfs_trans_handle *trans,
> }
>
> struct btrfs_block_group *btrfs_create_chunk(struct btrfs_trans_handle *trans,
> - u64 type)
> + struct btrfs_space_info *space_info,
> + u64 type)
> {
> struct btrfs_fs_info *info = trans->fs_info;
> struct btrfs_fs_devices *fs_devices = info->fs_devices;
> @@ -5671,8 +5675,16 @@ struct btrfs_block_group *btrfs_create_chunk(struct btrfs_trans_handle *trans,
> return ERR_PTR(-EINVAL);
> }
>
> + if (!space_info) {
> + space_info = btrfs_find_space_info(info, type);
> + if (!space_info) {
> + ASSERT(0);
> + return ERR_PTR(-EINVAL);
> + }
> + }
Same comment here, make everybody send down the space_info instead of it being
optional. Thanks,
Josef
next prev parent reply other threads:[~2025-04-17 12:40 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-16 14:28 [PATCH v3 00/13] btrfs: zoned: split out space_info for dedicated block groups Naohiro Aota
2025-04-16 14:28 ` [PATCH v3 01/13] btrfs: take btrfs_space_info in btrfs_reserve_data_bytes Naohiro Aota
2025-04-16 14:28 ` [PATCH v3 02/13] btrfs: take struct btrfs_inode in btrfs_free_reserved_data_space_noquota Naohiro Aota
2025-04-16 14:28 ` [PATCH v3 03/13] btrfs: factor out init_space_info() Naohiro Aota
2025-04-16 14:28 ` [PATCH v3 04/13] btrfs: spin out do_async_reclaim_{data,metadata}_space() Naohiro Aota
2025-04-16 14:28 ` [PATCH v3 05/13] btrfs: factor out check_removing_space_info() Naohiro Aota
2025-04-16 14:28 ` [PATCH v3 06/13] btrfs: introduce space_info argument to btrfs_chunk_alloc Naohiro Aota
2025-04-17 12:38 ` Josef Bacik
2025-04-18 0:59 ` Naohiro Aota
2025-04-16 14:28 ` [PATCH v3 07/13] btrfs: pass space_info for block group creation Naohiro Aota
2025-04-17 12:40 ` Josef Bacik [this message]
2025-04-16 14:28 ` [PATCH v3 08/13] btrfs: introduce btrfs_space_info sub-group Naohiro Aota
2025-04-16 14:56 ` Johannes Thumshirn
2025-04-17 12:43 ` Josef Bacik
2025-04-16 14:28 ` [PATCH v3 09/13] btrfs: introduce tree-log sub-space_info Naohiro Aota
2025-04-16 14:57 ` Johannes Thumshirn
2025-04-17 12:44 ` Josef Bacik
2025-04-18 1:08 ` Naohiro Aota
2025-04-16 14:28 ` [PATCH v3 10/13] btrfs: tweak extent/chunk allocation for space_info sub-space Naohiro Aota
2025-04-17 5:48 ` Naohiro Aota
2025-04-16 14:28 ` [PATCH v3 11/13] btrfs: use proper data space_info Naohiro Aota
2025-04-16 14:59 ` Johannes Thumshirn
2025-04-17 4:35 ` Naohiro Aota
2025-04-16 14:28 ` [PATCH v3 12/13] btrfs: add block_rsv for treelog Naohiro Aota
2025-04-17 12:48 ` Josef Bacik
2025-04-16 14:28 ` [PATCH v3 13/13] btrfs: reclaim from sub-space space_info Naohiro Aota
2025-04-17 12:49 ` Josef Bacik
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=20250417124006.GB3574107@perftesting \
--to=josef@toxicpanda.com \
--cc=johannes.thumshirn@wdc.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=naohiro.aota@wdc.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