From: Damien Le Moal <dlemoal@kernel.org>
To: Johannes Thumshirn <johannes.thumshirn@wdc.com>,
linux-btrfs@vger.kernel.org
Cc: Christoph Hellwig <hch@lst.de>,
Hans Holmberg <Hans.Holmberg@wdc.com>,
Naohiro Aota <naohiro.aota@wdc.com>,
Josef Bacik <josef@toxicpanda.com>,
Filipe Manana <fdmanana@suse.com>,
David Sterba <dsterba@suse.com>, Boris Burkov <boris@bur.io>,
Qu Wenruo <wqu@suse.com>,
Wilfred Mallawa <wilfred.opensource@gmail.com>
Subject: Re: [PATCH 4/5] btrfs: zoned: try to fill hinted block-groups
Date: Fri, 27 Nov 2026 06:25:54 +0900 [thread overview]
Message-ID: <27d2151f-7806-4bdd-9bfc-3107a04bf0d6@kernel.org> (raw)
In-Reply-To: <20261126132820.570379-5-johannes.thumshirn@wdc.com>
On 11/26/26 22:28, Johannes Thumshirn wrote:
> If the hinted block-group has less space left than the allocation, the
> allocation goes to a new block-group and the old one stays active with
> its leftover. With buffered writes this happens for nearly every
> block-group, the leftovers use up the active zones and new files fall
> back to round-robin.
>
> Shrink the allocation to the space left in the hinted block-group
> instead, as long as it is not smaller than min_alloc_size. The
> block-group becomes full, gets finished and releases its active zone.
>
> 5 parallel buffered writers on null_blk, 64M zones, max 12 active zones:
> files per zone 3.09 -> 1.46, extents per file 29.6 -> 5.8.
>
> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
One nit below. Otherwise looks good to me.
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
> ---
> fs/btrfs/extent-tree.c | 17 ++++++++++++++++-
> 1 file changed, 16 insertions(+), 1 deletion(-)
>
> diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
> index 7169f296a523..d8dc43655b16 100644
> --- a/fs/btrfs/extent-tree.c
> +++ b/fs/btrfs/extent-tree.c
> @@ -4526,8 +4526,23 @@ static int prepare_allocation_zoned(struct btrfs_fs_info *fs_info,
> &block_group->runtime_flags))
> continue;
>
> - if (avail < ffe_ctl->num_bytes)
> + /*
> + * If we have less space available in the block-group but can
> + * fit the allocation into the hinted block-group if we shrink
> + * it, fill up the block-group.
> + */
> + if (avail < ffe_ctl->num_bytes) {
> + avail = round_down(avail, fs_info->sectorsize);
> + if (avail >= ffe_ctl->min_alloc_size &&
> + in_range(ffe_ctl->hint_byte, block_group->start,
> + block_group->length)) {
This in_range() call is being repeated. It feels like an inline wrapper for it
would be nice. E.g. something like:
bg_contains_byte(block_group, ffe_ctl->hint_byte)
> + if (ffe_ctl->ram_bytes == ffe_ctl->num_bytes)
> + ffe_ctl->ram_bytes = avail;
> + ffe_ctl->num_bytes = avail;
> + break;
> + }
> continue;
> + }
>
> /*
> * Remember the first block-group that fits the allocation. Then
--
Damien Le Moal
Western Digital Research
next prev parent reply other threads:[~2026-11-26 21:25 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 13:28 [PATCH 0/5] btrfs: rework data placement on zoned devices Johannes Thumshirn
2026-11-26 13:28 ` [PATCH 1/5] btrfs: zoned: search for hinted block-group in prepare_allocation_zoned Johannes Thumshirn
2026-11-26 21:09 ` Damien Le Moal
2026-11-27 9:57 ` Johannes Thumshirn
2026-11-26 13:28 ` [PATCH 2/5] btrfs: zoned: save last allocation as placement hint Johannes Thumshirn
2026-11-26 21:11 ` Damien Le Moal
2026-11-26 13:28 ` [PATCH 3/5] btrfs: zoned: allocate a new block-group per file Johannes Thumshirn
2026-11-26 21:20 ` Damien Le Moal
2026-11-26 13:28 ` [PATCH 4/5] btrfs: zoned: try to fill hinted block-groups Johannes Thumshirn
2026-11-26 21:25 ` Damien Le Moal [this message]
2026-11-27 10:15 ` Johannes Thumshirn
2026-11-26 13:28 ` [PATCH 5/5] btrfs: zoned: break concurrent chunk allocation race Johannes Thumshirn
2026-11-26 21:30 ` Damien Le Moal
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=27d2151f-7806-4bdd-9bfc-3107a04bf0d6@kernel.org \
--to=dlemoal@kernel.org \
--cc=Hans.Holmberg@wdc.com \
--cc=boris@bur.io \
--cc=dsterba@suse.com \
--cc=fdmanana@suse.com \
--cc=hch@lst.de \
--cc=johannes.thumshirn@wdc.com \
--cc=josef@toxicpanda.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=naohiro.aota@wdc.com \
--cc=wilfred.opensource@gmail.com \
--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 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.