From: Naohiro Aota <Naohiro.Aota@wdc.com>
To: Johannes Thumshirn <Johannes.Thumshirn@wdc.com>,
"linux-btrfs@vger.kernel.org" <linux-btrfs@vger.kernel.org>
Subject: Re: [PATCH v2 08/13] btrfs: introduce btrfs_space_info sub-group
Date: Wed, 16 Apr 2025 14:17:19 +0000 [thread overview]
Message-ID: <D984LOF83ZW8.26YW45VOYTT85@wdc.com> (raw)
In-Reply-To: <a97c2dc4-f83a-4db3-9655-db353bd44864@wdc.com>
On Fri Mar 21, 2025 at 1:11 AM JST, Johannes Thumshirn wrote:
> On 19.03.25 07:17, Naohiro Aota wrote:
>> diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c
>> index 56c3aa0e7fe2..f5f0485d37b6 100644
>> --- a/fs/btrfs/block-group.c
>> +++ b/fs/btrfs/block-group.c
>> @@ -4537,6 +4537,12 @@ int btrfs_free_block_groups(struct btrfs_fs_info *info)
>> struct btrfs_space_info,
>> list);
>>
>> + for (int i = 0; i < BTRFS_SPACE_INFO_SUB_GROUP_MAX; i++) {
>> + if (space_info->sub_group[i]) {
>> + check_removing_space_info(space_info->sub_group[i]);
>> + kfree(space_info->sub_group[i]);
>> + }
>> + }
>> check_removing_space_info(space_info);
>
> you could move the loop into check_removing_space_info(). As long as
> sub_groups don't have sub_groups the recursion won't be too bad for the
> kernel's stack constraints.
>
>> list_del(&space_info->list);
>> btrfs_sysfs_remove_space_info(space_info);
>> diff --git a/fs/btrfs/space-info.c b/fs/btrfs/space-info.c
>> index c421161f4237..53eea3cd2bf3 100644
>> --- a/fs/btrfs/space-info.c
>> +++ b/fs/btrfs/space-info.c
>> @@ -249,6 +249,7 @@ static void init_space_info(struct btrfs_fs_info *info,
>> INIT_LIST_HEAD(&space_info->priority_tickets);
>> space_info->clamp = 1;
>> btrfs_update_space_info_chunk_size(space_info, calc_chunk_size(info, flags));
>> + space_info->subgroup_id = SUB_GROUP_PRIMARY;
>>
>> if (btrfs_is_zoned(info))
>> space_info->bg_reclaim_threshold = BTRFS_DEFAULT_ZONED_RECLAIM_THRESH;
>> @@ -266,6 +267,22 @@ static int create_space_info(struct btrfs_fs_info *info, u64 flags)
>>
>> init_space_info(info, space_info, flags);
>>
>> + if (btrfs_is_zoned(info)) {
>> + if (flags & BTRFS_BLOCK_GROUP_DATA) {
>> + struct btrfs_space_info *reloc = kzalloc(sizeof(*reloc), GFP_NOFS);
>> +
>> + if (!reloc)
>> + return -ENOMEM;
>
> I'd prefer:
>
> struct btrfs_space_info *reloc;
>
> reloc = kzalloc(sizeof(*reloc), GFP_NOFS);
> if (!reloc)
> return -ENOMEM;
>
> Also maybe add as the next patch also adds a case for METADATA, maybe
> factor that out into:
>
> if (btrfs_is_zoned(info)) {
> ret = btrfs_create_zone_sub_space_info(info);
> /* or create_sub_info_for_zoned? */
> if (ret)
> return ret;
> }
Indeed. I'll factor out the code into a function.
>
>> + init_space_info(info, reloc, flags);
>> + space_info->sub_group[SUB_GROUP_DATA_RELOC] = reloc;
>> + reloc->parent = space_info;
>> + reloc->subgroup_id = SUB_GROUP_DATA_RELOC;
>> +
>> + ret = btrfs_sysfs_add_space_info_type(info, reloc);
>> + ASSERT(!ret);
>> + }
>> + }
>> +
next prev parent reply other threads:[~2025-04-16 14:17 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-19 6:14 [PATCH v2 00/13] btrfs: zoned: split out space_info for dedicated block groups Naohiro Aota
2025-03-19 6:14 ` [PATCH v2 01/13] btrfs: take btrfs_space_info in btrfs_reserve_data_bytes Naohiro Aota
2025-03-20 12:04 ` Johannes Thumshirn
2025-03-19 6:14 ` [PATCH v2 02/13] btrfs: take struct btrfs_inode in btrfs_free_reserved_data_space_noquota Naohiro Aota
2025-03-20 12:04 ` Johannes Thumshirn
2025-03-19 6:14 ` [PATCH v2 03/13] btrfs: factor out init_space_info() Naohiro Aota
2025-03-20 12:04 ` Johannes Thumshirn
2025-03-19 6:14 ` [PATCH v2 04/13] btrfs: spin out do_async_reclaim_{data,metadata}_space() Naohiro Aota
2025-03-20 12:03 ` Johannes Thumshirn
2025-03-19 6:14 ` [PATCH v2 05/13] btrfs: factor out check_removing_space_info() Naohiro Aota
2025-03-20 12:03 ` Johannes Thumshirn
2025-03-19 6:14 ` [PATCH v2 06/13] btrfs: introduce space_info argument to btrfs_chunk_alloc Naohiro Aota
2025-03-20 12:12 ` Johannes Thumshirn
2025-03-19 6:14 ` [PATCH v2 07/13] btrfs: pass space_info for block group creation Naohiro Aota
2025-03-20 12:21 ` Johannes Thumshirn
2025-04-16 14:16 ` Naohiro Aota
2025-03-19 6:14 ` [PATCH v2 08/13] btrfs: introduce btrfs_space_info sub-group Naohiro Aota
2025-03-20 16:11 ` Johannes Thumshirn
2025-03-27 17:38 ` David Sterba
2025-04-16 14:17 ` Naohiro Aota [this message]
2025-03-19 6:14 ` [PATCH v2 09/13] btrfs: introduce tree-log sub-space_info Naohiro Aota
2025-03-20 16:12 ` Johannes Thumshirn
2025-03-19 6:14 ` [PATCH v2 10/13] btrfs: tweak extent/chunk allocation for space_info sub-space Naohiro Aota
2025-03-20 16:21 ` Johannes Thumshirn
2025-03-19 6:14 ` [PATCH v2 11/13] btrfs: use proper data space_info Naohiro Aota
2025-03-20 16:34 ` Johannes Thumshirn
2025-03-19 6:14 ` [PATCH v2 12/13] btrfs: add block_rsv for treelog Naohiro Aota
2025-03-20 16:38 ` Johannes Thumshirn
2025-03-19 6:14 ` [PATCH v2 13/13] btrfs: reclaim from sub-space space_info Naohiro Aota
2025-03-20 16:39 ` Johannes Thumshirn
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=D984LOF83ZW8.26YW45VOYTT85@wdc.com \
--to=naohiro.aota@wdc.com \
--cc=Johannes.Thumshirn@wdc.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