From: "Naohiro Aota" <Naohiro.Aota@wdc.com>
To: "Johannes Thumshirn" <johannes.thumshirn@wdc.com>,
<linux-btrfs@vger.kernel.org>
Cc: "Filipe Manana" <fdmanana@suse.com>,
"David Sterba" <dsterba@suse.com>,
"Hans Holmberg" <Hans.Holmberg@wdc.com>,
"Boris Burkov" <boris@bur.io>,
"Damien Le Moal" <dlemoal@kernel.org>,
"Naohiro Aota" <naohiro.aota@wdc.com>,
"Christoph Hellwig" <hch@lst.de>
Subject: Re: [PATCH v3 3/5] btrfs: zoned: always set data_relocation_bg
Date: Mon, 25 May 2026 11:36:00 +0900 [thread overview]
Message-ID: <DIREOT147OSP.YY2ABOT2IFNJ@wdc.com> (raw)
In-Reply-To: <20260522090247.27445-4-johannes.thumshirn@wdc.com>
On Fri May 22, 2026 at 6:02 PM JST, Johannes Thumshirn wrote:
> When searching for a data relocation block-group on mount,
> btrfs_zoned_reserve_data_reloc_bg() is looking for the first empty DATA
> block-group. But it first checks if the block-group is empty and if yes
> continues the search, and then checks if it is the first DATA block-group.
>
> There is actually no point in looking for the second empty DATA block
> group as new DATA allocations will just allocate a new chunk for it. Pick
> the first DATA block-group without any allocations done and set it as
> relocation block-group.
I think we can add context here.
At first, the commit 694ce5e143d6 ("btrfs: zoned: reserve data_reloc
block group on mount") introduced the functionality. At that time, we
took second unused (used == 0) block group, as the first one might be
a block group used for normal data.
Later, commit daa0fde32235 ("btrfs: zoned: fix data relocation block
group reservation") switched to look for an empty block group
(alloc_offset == 0). At this point, there is no reason taking the second
one anymore. So, this commit is fixing an issue in commit daa0fde32235.
>
> Singed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> ---
> fs/btrfs/zoned.c | 8 +-------
> 1 file changed, 1 insertion(+), 7 deletions(-)
>
> diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
> index 16dd87aa06f2..a4d2fb774f72 100644
> --- a/fs/btrfs/zoned.c
> +++ b/fs/btrfs/zoned.c
> @@ -2763,7 +2763,6 @@ void btrfs_zoned_reserve_data_reloc_bg(struct btrfs_fs_info *fs_info)
> struct btrfs_block_group *bg;
> struct list_head *bg_list;
> u64 alloc_flags;
> - bool first = true;
> bool did_chunk_alloc = false;
> int index;
> int ret;
> @@ -2784,13 +2783,9 @@ void btrfs_zoned_reserve_data_reloc_bg(struct btrfs_fs_info *fs_info)
Could you please fix the comment here?
/* Scan the data space_info to find empty block groups. Take the second one. */
Other than that,
Reviewed-by: Naohiro Aota <naohiro.aota@wdc.com>
> again:
> bg_list = &space_info->block_groups[index];
> list_for_each_entry(bg, bg_list, list) {
> - if (bg->alloc_offset != 0)
> - continue;
>
> - if (first) {
> - first = false;
> + if (bg->alloc_offset != 0)
> continue;
> - }
>
> if (space_info == data_sinfo) {
> /* Migrate the block group to the data relocation space_info. */
> @@ -2849,7 +2844,6 @@ void btrfs_zoned_reserve_data_reloc_bg(struct btrfs_fs_info *fs_info)
> * We allocated a new block group in the data relocation space_info. We
> * can take that one.
> */
> - first = false;
> did_chunk_alloc = true;
> goto again;
> }
next prev parent reply other threads:[~2026-05-25 2:36 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-22 9:02 [PATCH v3 0/5] btrfs: zoned: fix deadlock and space reporting issues for zoned filesystems Johannes Thumshirn
2026-05-22 9:02 ` [PATCH v3 1/5] btrfs: zoned: document RECLAIM_ZONES flush state Johannes Thumshirn
2026-05-22 9:02 ` [PATCH v3 2/5] btrfs: zoned: decode 'RECLAIM_ZONES' state in tracepoints Johannes Thumshirn
2026-05-22 9:02 ` [PATCH v3 3/5] btrfs: zoned: always set data_relocation_bg Johannes Thumshirn
2026-05-22 18:27 ` Boris Burkov
2026-05-25 2:36 ` Naohiro Aota [this message]
2026-05-22 9:02 ` [PATCH v3 4/5] btrfs: zoned: don't account data relocation space-info in statfs free space Johannes Thumshirn
2026-05-22 9:02 ` [PATCH v3 5/5] btrfs: zoned: fix deadlock waiting for ticket during data relocation Johannes Thumshirn
2026-05-25 3:57 ` [PATCH v3 0/5] btrfs: zoned: fix deadlock and space reporting issues for zoned filesystems Naohiro Aota
2026-05-25 11:35 ` David Sterba
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=DIREOT147OSP.YY2ABOT2IFNJ@wdc.com \
--to=naohiro.aota@wdc.com \
--cc=Hans.Holmberg@wdc.com \
--cc=boris@bur.io \
--cc=dlemoal@kernel.org \
--cc=dsterba@suse.com \
--cc=fdmanana@suse.com \
--cc=hch@lst.de \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.